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

Michael Niedermayer michaelni
Tue Mar 16 01:25:40 CET 2010


On Thu, Mar 04, 2010 at 12:26:24AM +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 
> 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 valid aspect ratio change, not only size 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>
> 
> ---
> Hi,
> 
> I'v noticed that there were problems with the previous version of this patch 
> and it has been reverted.
> 
> This version should correct this problem, I've tested it successfully with 
> every sample from http://samples.ffmpeg.org/V-codecs/h264/ that also played 
> for me without the patch.
> 
> Thanks,
> Janusz
> 
> 
> --- trunk/libavcodec/h264.c.orig	2010-03-03 22:57:53.000000000 +0100
> +++ trunk/libavcodec/h264.c	2010-03-03 23:20:44.000000000 +0100
> @@ -1774,7 +1774,11 @@ 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
> +                && h->sps.sar.num != s->avctx->sample_aspect_ratio.num)
> +            || (h->sps.sar.den
> +                && h->sps.sar.den != s->avctx->sample_aspect_ratio.den))) {

should use av_cmp_q() unless that doesnt work

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100316/e437c54f/attachment.pgp>



More information about the ffmpeg-devel mailing list