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

Stefano Sabatini stefano.sabatini-lala
Fri Mar 19 00:36:01 CET 2010


On date Wednesday 2010-03-17 17:46:56 +0100, Janusz Krzysztofik encoded:
> Tuesday 16 March 2010 14:16:19 Michael Niedermayer napisa?(a):
> > On Tue, Mar 16, 2010 at 12:24:13PM +0100, Janusz Krzysztofik wrote:
> > > 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 (channel) startup, any following picture aspect ratio changes were
> > > not processed. The same can be seen while playing vdr caputured samples
> > > of this transmission with ffplay.
> > >
> > > This patch corrects the problem for me by reinitializing the decoder
> > > context on every valid aspect ratio change, not only size changes.
> > >
> > > Created against ffmpeg svn revision 22565.
> > > Tested with this revision ffplay.
> > >
> > > Signed-off-by: Janusz Krzysztofik <jkrzyszt at tis.icnet.pl>
> > > ---
> > > v5 changes:
> > > - drop non-zero checks introuduced in v3, those appeared not necessary
> > > for correct playback of cathedral-beta2-400extra-crop-avc.mp4 test sample
> > > (apparently num/den==0/0 case) after v4 changes.
> > >
> > > v4 changes:
> > > - use av_cmp_q() instead of comparing numerators and denominators
> > > separately (thanks to Michael Niedermayer for advising this).
> > >
> > > v3 changes:
> > > - check for non-zero values of both new numerator and denominator to
> > > avoid problems with some test samples (ie.
> > > cathedral-beta2-400extra-crop-avc.mp4).
> > >
> > > v2 changes: none (refresh only)
> > >
> > > --- trunk/libavcodec/h264.c.orig	2010-03-16 12:09:27.000000000 +0100
> > > +++ trunk/libavcodec/h264.c	2010-03-16 12:09:57.000000000 +0100
> > > @@ -1774,7 +1774,8 @@ 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 +            || av_cmp_q(h->sps.sar,
> > > s->avctx->sample_aspect_ratio))) { if(h != h0)
> > >              return -1;   // width / height changed during parallelized
> > > decoding free_tables(h);
> >
> > looks ok if it works
> 
> Obviously, works for me ;).
> 
> Could some of you, ffmpeg-devel guys, please give it a try as well?

Applied, thanks for the patch.
-- 
FFmpeg = Friendly & Formidable Minimalistic Peaceless Extensive Guru



More information about the ffmpeg-devel mailing list