[FFmpeg-devel] [PATCH] correct MPEG video parser not to return incomplete frames
Baptiste Coudurier
baptiste.coudurier
Sun Aug 2 21:39:25 CEST 2009
On 08/02/2009 07:53 AM, Michael Niedermayer wrote:
> 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.
Well there is another problem, the partial frame it will be kept during
stream copy, I don't think anybody will want that when extracting mpeg-2
from TS or PS.
IMHO if picture start code is missing, if pict_type is 0 after
extract_headers, you can reasonably discard the data.
[...]
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list