Adds a new private option to enable them (off by default).
---
libavcodec/vaapi_encode_h264.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 69f17dac2..66f8e2490 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -52,6 +52,7 @@ typedef struct VAAPIEncodeH264Context {
int fixed_qp_p;
int fixed_qp_b;
+ H264RawAUD aud;
H264RawSPS sps;
H264RawPPS pps;
H264RawSEI sei;
@@ -76,6 +77,7 @@ typedef struct VAAPIEncodeH264Context {
CodedBitstreamContext cbc;
CodedBitstreamFragment current_access_unit;
+ int aud_needed;
int sei_needed;
#if VA_CHECK_VERSION(0, 36, 0)
@@ -91,6 +93,7 @@ typedef struct VAAPIEncodeH264Options {
int qp;
int quality;
int low_power;
+ int aud;
int sei;
} VAAPIEncodeH264Options;
@@ -145,9 +148,17 @@ static int
vaapi_encode_h264_write_sequence_header(AVCodecContext *avctx,
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeH264Context *priv = ctx->priv_data;
+ VAAPIEncodeH264Options *opt = ctx->codec_options;
CodedBitstreamFragment *au = &priv->current_access_unit;
int err;
+ if (opt->aud && priv->aud_needed) {
+ err = vaapi_encode_h264_add_nal(avctx, au, H264_NAL_AUD, &priv->aud);
+ if (err < 0)
+ goto fail;
+ priv->aud_needed = 0;
+ }
+
err = vaapi_encode_h264_add_nal(avctx, au, H264_NAL_SPS, &priv->sps);
if (err < 0)
goto fail;
@@ -169,9 +180,17 @@ static int
vaapi_encode_h264_write_slice_header(AVCodecContext *avctx,
{
VAAPIEncodeContext *ctx = avctx->priv_data;
VAAPIEncodeH264Context *priv = ctx->priv_data;
+ VAAPIEncodeH264Options *opt = ctx->codec_options;
CodedBitstreamFragment *au = &priv->current_access_unit;
int err;
+ if (opt->aud && priv->aud_needed) {
+ err = vaapi_encode_h264_add_nal(avctx, au, H264_NAL_AUD, &priv->aud);
+ if (err < 0)
+ goto fail;
+ priv->aud_needed = 0;
+ }
+
err = vaapi_encode_h264_add_nal(avctx, au,
priv->slice.header.nal_unit_type,
&priv->slice);
@@ -196,6 +215,11 @@ static int
vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
int err, i;
if (priv->sei_needed) {
+ if (opt->aud && priv->aud_needed) {
+ vaapi_encode_h264_add_nal(avctx, au, H264_NAL_AUD, &priv->aud);
+ priv->aud_needed = 0;
+ }
+
memset(&priv->sei, 0, sizeof(priv->sei));
priv->sei.nal_unit_type = H264_NAL_SEI;
@@ -576,6 +600,12 @@ static int
vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
priv->pic_order_cnt = pic->display_order - priv->last_idr_frame;
priv->dpb_delay = pic->display_order - pic->encode_order + 1;
+ if (opt->aud) {
+ priv->aud_needed = 1;
+ priv->aud.nal_unit_type = H264_NAL_AUD;
+ priv->aud.primary_pic_type = priv->primary_pic_type;
+ }
+
if (opt->sei & SEI_IDENTIFIER && pic->encode_order == 0)
priv->sei_needed = 1;
@@ -933,6 +963,9 @@ static const AVOption vaapi_encode_h264_options[] = {
"on some platforms, does not support all features)",
OFFSET(low_power), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
+ { "aud", "Include AUD",
+ OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
+
{ "sei", "Set SEI to include",
OFFSET(sei), AV_OPT_TYPE_FLAGS,
{ .i64 = SEI_IDENTIFIER | SEI_HRD },
--
2.11.0
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel