[FFmpeg-devel] [PATCH] H.264: reinitialize context on aspect ratio change as well

Janusz Krzysztofik jkrzyszt
Sat Feb 27 13:46:20 CET 2010


Hi,

While using ffmpeg based vdr softdevice plugin for watching h.264 encoded live 
tv, I found that after correct picture aspect ratio setup on a new stream 
startup, any following picture aspect ratio changes were not processed. This 
patch corrects the problem for me by reinitializing the decoder context on 
every aspect ratio change in addition to geometry changes.

Created and tested against gentoo ffmpeg-0.4.9_p20090201 ebuild (0.5 did not 
yet work for me with vdr softdevice plugin flawlessly enough).
Refreshed and compile tested on top of svn revision 22026 dated 2010-02-24.

Signed-off-by: Janusz Krzysztofik <jkrzyszt at tis.icnet.pl>

---

--- ffmpeg/libavcodec/h264.c.orig	2009-02-24 15:55:12.000000000 +0100
+++ ffmpeg/libavcodec/h264.c	2010-02-27 13:34:33.000000000 +0100
@@ -1776,7 +1776,9 @@ static int decode_slice_header(H264Conte
         s->height= 16*s->mb_height - 4*FFMIN(h->sps.crop_bottom, 3);
 
     if (s->context_initialized
-        && (   s->width != s->avctx->width || s->height != s->avctx->height)) {
+        && (   s->width != s->avctx->width || s->height != s->avctx->height
+		|| h->sps.sar.num != s->avctx->sample_aspect_ratio.num
+		|| h->sps.sar.den != s->avctx->sample_aspect_ratio.den)) {
         if(h != h0)
             return -1;   // width / height changed during parallelized decoding
         free_tables(h);



More information about the ffmpeg-devel mailing list