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

Janusz Krzysztofik jkrzyszt
Sun Feb 28 14:13:49 CET 2010


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. The 
same applies to playing vdr caputured samples of this transmission with 
ffplay.

This patch corrects the problem for me by reinitializing the decoder context 
on every aspect ratio change in addition to geometry changes.

Created against ffmpeg svn revision 22110 dated 2010-02-28.
Tested using this revision ffplay on x86_64.

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

---

--- ffmpeg/libavcodec/h264.c.orig	2010-02-28 13:54:12.000000000 +0100
+++ ffmpeg/libavcodec/h264.c	2010-02-28 14:04:02.000000000 +0100
@@ -1775,7 +1775,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