[FFmpeg-devel] [PATCH] missing last frame for h264 decoding + CODEC_FLAG_TRUNCATED

Michael Niedermayer michaelni
Sat May 24 23:53:43 CEST 2008


On Fri, May 23, 2008 at 01:36:13PM -0700, Pascal Massimino wrote:
>   Hi everybody,
> 
>   attached a patch for h264 decoding in CODEC_FLAG_TRUNCATED mode:
>   even during the last call to decode_frame() with buf_size = 0, i'd say
>   we need to flush the buffers in the ParseContext before calling it
> quit for good.
> 
>   Also: when flushing (for seek), we need to wipe the ParseContext too, to
>   get rid of pending frame fragments.
> 
>   I've uploaded a very small 'test_2frames.264' raw h264 file into incoming/
>   on the ftp.
>   Without this patch, repeated call to decode_frame() wouldn't decode the
>   last frame.
> 
> skal

> --- h264.c.orig	2008-05-20 08:15:32.673356000 -0700
> +++ h264.c	2008-05-23 13:26:22.272216000 -0700
> @@ -3314,6 +3314,9 @@
>          h->s.current_picture_ptr->reference= 0;
>      h->s.first_field= 0;
>      ff_mpeg_flush(avctx);
> +    if (h->s.flags&CODEC_FLAG_TRUNCATED){
> +        memset(&h->s.parse_context, 0, sizeof(h->s.parse_context));
> +    }

ff_mpeg_flush() should already clean parse_context, the memset might
instead result in a memleak


>  }
>  
>  /**
> @@ -7655,6 +7658,21 @@
>      s->flags= avctx->flags;
>      s->flags2= avctx->flags2;
>  
> +    if(s->flags&CODEC_FLAG_TRUNCATED){
> +        int next;
> +        uint8_t tmp[FF_INPUT_BUFFER_PADDING_SIZE] = { 0 };

> +        if (buf_size > 0) {
> +            next= ff_h264_find_frame_end(h, buf, buf_size);
> +        } else {
> +            buf= tmp;
> +            next= END_NOT_FOUND;
> +        }

ff_h264_find_frame_end(, , 0) should return END_NOT_FOUND
and buf should not be used with buf_size=0 thus it shouldnt matter what its
value is i think

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- 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/20080524/ab95e904/attachment.pgp>



More information about the ffmpeg-devel mailing list