Skip to content

Instantly share code, notes, and snippets.

@tmm1
Last active August 1, 2019 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmm1/cf7d047f8f2ad591f865647cc7d4921c to your computer and use it in GitHub Desktop.
Save tmm1/cf7d047f8f2ad591f865647cc7d4921c to your computer and use it in GitHub Desktop.
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 9152af4fb3..896a945470 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -64,6 +64,7 @@ typedef struct VAAPIEncodeH264Context {
H264RawSEIPicTiming pic_timing;
H264RawSEIRecoveryPoint recovery_point;
H264RawSEIUserDataUnregistered identifier;
+ H264RawSEIUserDataRegistered a53_cc;
char *identifier_string;
int frame_num;
@@ -244,6 +245,11 @@ static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
priv->sei.payload[i].payload.recovery_point = priv->recovery_point;
++i;
}
+ if (priv->a53_cc.data_length) {
+ priv->sei.payload[i].payload_type = H264_SEI_TYPE_USER_DATA_REGISTERED;
+ priv->sei.payload[i].payload.user_data_registered = priv->a53_cc;
+ ++i;
+ }
priv->sei.payload_count = i;
av_assert0(priv->sei.payload_count > 0);
@@ -581,6 +587,7 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
VAAPIEncodeH264Options *opt = ctx->codec_options;
H264RawSPS *sps = &priv->sps;
VAEncPictureParameterBufferH264 *vpic = pic->codec_picture_params;
+ AVFrameSideData *side_data = NULL;
int i;
memset(&priv->current_access_unit, 0,
@@ -652,6 +659,16 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
priv->sei_needed = 1;
}
+ side_data = av_frame_get_side_data(pic->input_image, AV_FRAME_DATA_A53_CC);
+ if (side_data && side_data->size) {
+ priv->a53_cc.itu_t_t35_country_code = 181;
+ priv->a53_cc.data_ref = av_buffer_ref(side_data->buf);
+ priv->a53_cc.data = side_data->data;
+ priv->a53_cc.data_length = side_data->size;
+
+ priv->sei_needed = 1;
+ }
+
vpic->CurrPic = (VAPictureH264) {
.picture_id = pic->recon_surface,
.frame_idx = priv->frame_num,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment