Skip to content

Commit

Permalink
EncodePipelineVAAPI: Add support for disabling filler data
Browse files Browse the repository at this point in the history
  • Loading branch information
nowrep committed Aug 5, 2023
1 parent 5a85b8a commit 1e51f61
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions alvr/server/cpp/platform/linux/EncodePipelineVAAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ alvr::EncodePipelineVAAPI::EncodePipelineVAAPI(Renderer *render, VkContext &vk_c
break;
}

av_opt_set_int(encoder_ctx->priv_data, "filler_data", settings.m_fillerData, 0);

encoder_ctx->width = width;
encoder_ctx->height = height;
encoder_ctx->time_base = {1, (int)1e9};
Expand Down
53 changes: 53 additions & 0 deletions alvr/xtask/patches/0001-vaapi_encode-Add-filler_data-option.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 920a052dbf4ffd92b25df68acbb2b36f5b51128d Mon Sep 17 00:00:00 2001
From: David Rosca <[email protected]>
Date: Sat, 5 Aug 2023 11:09:35 +0200
Subject: [PATCH] vaapi_encode: Add filler_data option

---
libavcodec/vaapi_encode.c | 1 +
libavcodec/vaapi_encode.h | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index bfca315a7a..895e12a6a8 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1861,6 +1861,7 @@ rc_mode_found:
.quality_factor = rc_quality,
#endif
};
+ ctx->rc_params.rc_flags.bits.disable_bit_stuffing = !ctx->filler_data;
vaapi_encode_add_global_param(avctx,
VAEncMiscParameterTypeRateControl,
&ctx->rc_params,
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index a1e639f56b..682b943475 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -198,6 +198,9 @@ typedef struct VAAPIEncodeContext {
// Max Frame Size
int max_frame_size;

+ // Filler Data
+ int filler_data;
+
// Explicitly set RC mode (otherwise attempt to pick from
// available modes).
int explicit_rc_mode;
@@ -490,7 +493,12 @@ int ff_vaapi_encode_close(AVCodecContext *avctx);
{ "max_frame_size", \
"Maximum frame size (in bytes)",\
OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \
- { .i64 = 0 }, 0, INT_MAX, FLAGS }
+ { .i64 = 0 }, 0, INT_MAX, FLAGS }, \
+ { "filler_data", \
+ "Enable filler data", \
+ OFFSET(common.filler_data), AV_OPT_TYPE_BOOL, \
+ { .i64 = 1 }, 0, 1, FLAGS }
+

#define VAAPI_ENCODE_RC_MODE(name, desc) \
{ #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_ ## name }, \
--
2.41.0

0 comments on commit 1e51f61

Please sign in to comment.