[vlc-devel] [PATCH] contrib:ffmpeg: fix SAR not set early enough when starting the decoder

Steve Lhomme robux4 at ycbcr.xyz
Fri Jan 19 13:06:15 CET 2018


Fixes #19435
---
 contrib/src/ffmpeg/h264_early_SAR.patch | 33 +++++++++++++++++++++++++++++++++
 contrib/src/ffmpeg/rules.mak            |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 contrib/src/ffmpeg/h264_early_SAR.patch

diff --git a/contrib/src/ffmpeg/h264_early_SAR.patch b/contrib/src/ffmpeg/h264_early_SAR.patch
new file mode 100644
index 0000000000..045eac42eb
--- /dev/null
+++ b/contrib/src/ffmpeg/h264_early_SAR.patch
@@ -0,0 +1,33 @@
+From 9ace07a594b55cb564b39d704835a191387ba277 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 19 Jan 2018 12:55:52 +0100
+Subject: [PATCH] avcodec/h264_slice: use the new SAR early when setting the
+ decoder
+
+If we don't do that get_format might not be called for a while and the proper
+SAR not used.
+
+See the sample mentioned here: https://trac.videolan.org/vlc/ticket/19435
+---
+ libavcodec/h264_slice.c | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
+index e6b7998834..319a37f5b6 100644
+--- a/libavcodec/h264_slice.c
++++ b/libavcodec/h264_slice.c
+@@ -1050,8 +1050,10 @@ static int h264_init_ps(H264Context *h, const H264SliceContext *sl, int first_sl
+         || (non_j_pixfmt(h->avctx->pix_fmt) != non_j_pixfmt(get_pixel_format(h, 0))))
+         must_reinit = 1;
+ 
+-    if (first_slice && av_cmp_q(sps->sar, h->avctx->sample_aspect_ratio))
++    if (first_slice && av_cmp_q(sps->sar, h->avctx->sample_aspect_ratio)) {
+         must_reinit = 1;
++        ff_set_sar(h->avctx, sps->sar);
++    }
+ 
+     if (!h->setup_finished) {
+         h->avctx->profile = ff_h264_get_profile(sps);
+-- 
+2.14.2
+
diff --git a/contrib/src/ffmpeg/rules.mak b/contrib/src/ffmpeg/rules.mak
index 0fc063a501..85e4b6e2ba 100644
--- a/contrib/src/ffmpeg/rules.mak
+++ b/contrib/src/ffmpeg/rules.mak
@@ -233,6 +233,7 @@ ffmpeg: ffmpeg-$(FFMPEG_BASENAME).tar.xz .sum-ffmpeg
 ifdef USE_FFMPEG
 	$(APPLY) $(SRC)/ffmpeg/armv7_fixup.patch
 	$(APPLY) $(SRC)/ffmpeg/dxva_vc1_crash.patch
+	$(APPLY) $(SRC)/ffmpeg/h264_early_SAR.patch
 endif
 ifdef USE_LIBAV
 	$(APPLY) $(SRC)/ffmpeg/libav_gsm.patch
-- 
2.14.2



More information about the vlc-devel mailing list