aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpeg12.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2009-03-02 14:53:18 +0000
committerMichael Niedermayer <michaelni@gmx.at>2009-03-02 14:53:18 +0000
commita4c7a5ea27050a28625eabf1ba98cfef9ac6620d (patch)
treed726c914a687295f52aa1e27913a50e019f2187f /libavcodec/mpeg12.c
parent873b092353f95a852e4f2f7639fc13bc8b81cb41 (diff)
downloadffmpeg-a4c7a5ea27050a28625eabf1ba98cfef9ac6620d.tar.gz
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
Diffstat (limited to 'libavcodec/mpeg12.c')
-rw-r--r--libavcodec/mpeg12.c7
1 files changed, 5 insertions, 2 deletions
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;