[FFmpeg-cvslog] Merge commit 'ff007e30d8d45ba1ff2b2a4615f1cd5bafb50626'
Mark Thompson
git at videolan.org
Thu Nov 16 01:53:54 EET 2017
ffmpeg | branch: master | Mark Thompson <sw at jkqxz.net> | Wed Nov 15 23:43:56 2017 +0000| [4251e25272d6a51433805956ea26425d7ccd74cb] | committer: Mark Thompson
Merge commit 'ff007e30d8d45ba1ff2b2a4615f1cd5bafb50626'
* commit 'ff007e30d8d45ba1ff2b2a4615f1cd5bafb50626':
vaapi_h264: Add workaround for bad SEI in old Intel drivers
Merged-by: Mark Thompson <sw at jkqxz.net>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4251e25272d6a51433805956ea26425d7ccd74cb
---
libavcodec/vaapi_encode_h264.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 1d43e934ef..5fd0bf7796 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -82,6 +82,7 @@ typedef struct VAAPIEncodeH264Context {
CodedBitstreamFragment current_access_unit;
int aud_needed;
int sei_needed;
+ int sei_cbr_workaround_needed;
} VAAPIEncodeH264Context;
typedef struct VAAPIEncodeH264Options {
@@ -258,6 +259,19 @@ static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx,
*type = VAEncPackedHeaderRawData;
return 0;
+
+#if !CONFIG_VAAPI_1
+ } else if (priv->sei_cbr_workaround_needed) {
+ // Insert a zero-length header using the old SEI type. This is
+ // required to avoid triggering broken behaviour on Intel platforms
+ // in CBR mode where an invalid SEI message is generated by the
+ // driver and inserted into the stream.
+ *data_len = 0;
+ *type = VAEncPackedHeaderH264_SEI;
+ priv->sei_cbr_workaround_needed = 0;
+ return 0;
+#endif
+
} else {
return AVERROR_EOF;
}
@@ -614,6 +628,10 @@ static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx,
if (opt->sei & SEI_IDENTIFIER && pic->encode_order == 0)
priv->sei_needed = 1;
+#if !CONFIG_VAAPI_1
+ if (ctx->va_rc_mode == VA_RC_CBR)
+ priv->sei_cbr_workaround_needed = 1;
+#endif
if (opt->sei & SEI_TIMING) {
memset(&priv->pic_timing, 0, sizeof(priv->pic_timing));
======================================================================
diff --cc libavcodec/vaapi_encode_h264.c
index 1d43e934ef,377e3652de..5fd0bf7796
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@@ -254,10 -251,23 +255,23 @@@ static int vaapi_encode_h264_write_extr
if (err < 0)
goto fail;
- ff_cbs_fragment_uninit(&priv->cbc, au);
+ ff_cbs_fragment_uninit(priv->cbc, au);
- *type = VAEncPackedHeaderH264_SEI;
+ *type = VAEncPackedHeaderRawData;
return 0;
+
-#if !HAVE_VAAPI_1
++#if !CONFIG_VAAPI_1
+ } else if (priv->sei_cbr_workaround_needed) {
+ // Insert a zero-length header using the old SEI type. This is
+ // required to avoid triggering broken behaviour on Intel platforms
+ // in CBR mode where an invalid SEI message is generated by the
+ // driver and inserted into the stream.
+ *data_len = 0;
+ *type = VAEncPackedHeaderH264_SEI;
+ priv->sei_cbr_workaround_needed = 0;
+ return 0;
+ #endif
+
} else {
return AVERROR_EOF;
}
@@@ -614,6 -622,10 +628,10 @@@ static int vaapi_encode_h264_init_pictu
if (opt->sei & SEI_IDENTIFIER && pic->encode_order == 0)
priv->sei_needed = 1;
-#if !HAVE_VAAPI_1
++#if !CONFIG_VAAPI_1
+ if (ctx->va_rc_mode == VA_RC_CBR)
+ priv->sei_cbr_workaround_needed = 1;
+ #endif
if (opt->sei & SEI_TIMING) {
memset(&priv->pic_timing, 0, sizeof(priv->pic_timing));
More information about the ffmpeg-cvslog
mailing list