[FFmpeg-devel] [PATCH] correct MPEG video parser not to return incomplete frames

Michael Niedermayer michaelni
Sun Aug 2 16:53:06 CEST 2009

On Sun, Aug 02, 2009 at 03:58:59PM +0200, Ivan Schreter wrote:
> @@ -146,7 +153,12 @@
>      /* we have a full frame : we just parse the first few MPEG headers
>         to have the full timing information. The time take by this
>         function should be negligible for uncorrupted streams */
> -    mpegvideo_extract_headers(s, avctx, buf, buf_size);
> +    if (mpegvideo_extract_headers(s, avctx, buf, buf_size) < 0) {
> +        /* garbled frame, ignore (possibly first read after seek) */
> +        *poutbuf = NULL;
> +        *poutbuf_size = 0;
> +        return next;
> +    }
>  #if 0
>      printf("pict_type=%d frame_rate=%0.3f repeat_pict=%d\n",
>             s->pict_type, (double)avctx->time_base.den / avctx->time_base.num, s->repeat_pict);

as already said elsewhere, its not the job of parsers to discard data
it would break decoders that are capable to decode damaged frames, like
our decoder.
in addition to this your patch is VERY broken in a subtile and hard to
debug way, that is it will detect 99% of the incomplete frames but not
all from what it doesnt detect again most but not all would be fine,
that would be a nightmare to debug as it would occur so rarely and
require exact seeking to the problematic spot to reproduce ...
the issue and that might not be the only one is that there can be
things prior to the picture start code that can matter ...

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I wish the Xiph folks would stop pretending they've got something they
do not.  Somehow I fear this will remain a wish. -- M?ns Rullg?rd
-------------- 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/20090802/b77aea05/attachment.pgp>

More information about the ffmpeg-devel mailing list