diff options
author | Joakim Plate <elupus@ecce.se> | 2007-04-13 07:50:04 +0000 |
---|---|---|
committer | Benoit Fouet <benoit.fouet@free.fr> | 2007-04-13 07:50:04 +0000 |
commit | a74008a4c3b23707e610db0b2f042c2c8347b08f (patch) | |
tree | a558adf1257e89c36b0d64864dd9ff19490e9c46 /libavformat/utils.c | |
parent | 946d3b12a14ba661a2cdeaa1e85af224310b5753 (diff) | |
download | ffmpeg-a74008a4c3b23707e610db0b2f042c2c8347b08f.tar.gz |
timestamps generation improvement when parsing avi
patch by Joakim \ elupus chez ecce dot se /
original thread:
date: 03/19/2007 01:47 AM
subject: [Ffmpeg-devel] [RFC] Improvement for the odd timestamp generation when parser is in use.
Originally committed as revision 8725 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index c82d7dac84..b748b546ca 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -584,6 +584,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt) { int num, den, presentation_delayed, delay, i; + int64_t offset; /* handle wrapping */ if(st->cur_dts != AV_NOPTS_VALUE){ if(pkt->pts != AV_NOPTS_VALUE) @@ -599,6 +600,16 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, } } + /* correct timestamps with byte offset if demuxers only have timestamps on packet boundaries */ + if(pc && st->need_parsing == AVSTREAM_PARSE_TIMESTAMPS && pkt->size){ + /* this will estimate bitrate based on this frame's duration and size */ + offset = av_rescale(pc->offset, pkt->duration, pkt->size); + if(pkt->pts != AV_NOPTS_VALUE) + pkt->pts += offset; + if(pkt->dts != AV_NOPTS_VALUE) + pkt->dts += offset; + } + if(is_intra_only(st->codec)) pkt->flags |= PKT_FLAG_KEY; |