From a4c7a5ea27050a28625eabf1ba98cfef9ac6620d Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Mon, 2 Mar 2009 14:53:18 +0000 Subject: Call ff_fetch_timestamp() for mpeg1/2 when a picture start code is found instead of calling it at the end of a frame with a large negative offset. This significantly reduces the maximal distance in container packets between the point where the first byte of the "access unit" was stored and where we call ff_fetch_timestamp() thus reducing the constraints on our parser. Also change the parser from next_frame_offset to cur, this is needed because now the reference is from container packet start instead of frame start. (i previously misinterpreted this as bug) Originally committed as revision 17731 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/mpeg12.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libavcodec/mpeg12.c') diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 9e67ee5c61..b353b88f4c 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -2196,7 +2196,7 @@ static void mpeg_decode_gop(AVCodecContext *avctx, * Finds the end of the current frame in the bitstream. * @return the position of the first byte of the next frame, or -1 */ -int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) +int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size, AVCodecParserContext *s) { int i; uint32_t state= pc->state; @@ -2244,6 +2244,9 @@ int ff_mpeg1_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size) return i-3; } } + if(s && state == PICTURE_START_CODE){ + ff_fetch_timestamp(s, i-4, 1); + } } } pc->state= state; @@ -2276,7 +2279,7 @@ static int mpeg_decode_frame(AVCodecContext *avctx, } if(s2->flags&CODEC_FLAG_TRUNCATED){ - int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size); + int next= ff_mpeg1_find_frame_end(&s2->parse_context, buf, buf_size, NULL); if( ff_combine_frame(&s2->parse_context, next, (const uint8_t **)&buf, &buf_size) < 0 ) return buf_size; -- cgit v1.2.3