diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2008-02-15 20:32:32 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2008-02-15 20:32:32 +0000 |
commit | 83a9db42a38dda5bf2124faf9ffe4abd16641719 (patch) | |
tree | 8ab03d8e64c8c5ed4bae5bf4bcac253e7d80bd04 /libavformat/utils.c | |
parent | db7ae7d1b96bec521793a200ad46574bca728b6e (diff) | |
download | ffmpeg-83a9db42a38dda5bf2124faf9ffe4abd16641719.tar.gz |
Fix timestamps and durations if the first packets have no durations nor timestamps,
and the information needed to guess the duration only becomes known at a later packet.
Originally committed as revision 11963 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index 04a33a0405..79d502cd9e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -632,6 +632,24 @@ static void update_initial_timestamps(AVFormatContext *s, int stream_index, st->start_time = pts; } +static void update_initial_durations(AVFormatContext *s, AVStream *st, AVPacket *pkt) +{ + AVPacketList *pktl= s->packet_buffer; + + assert(pkt->duration && !st->cur_dts); + + for(; pktl; pktl= pktl->next){ + if(pktl->pkt.stream_index != pkt->stream_index) + continue; + if(pktl->pkt.pts == pktl->pkt.dts && pktl->pkt.dts == AV_NOPTS_VALUE){ + pktl->pkt.pts= pktl->pkt.dts= st->cur_dts; + st->cur_dts += pkt->duration; + pktl->pkt.duration= pkt->duration; + }else + break; + } +} + static void compute_pkt_fields(AVFormatContext *s, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt) { @@ -647,6 +665,9 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, compute_frame_duration(&num, &den, st, pc, pkt); if (den && num) { pkt->duration = av_rescale(1, num * (int64_t)st->time_base.den, den * (int64_t)st->time_base.num); + + if(pkt->dts == AV_NOPTS_VALUE && pkt->pts == AV_NOPTS_VALUE && st->cur_dts == 0) + update_initial_durations(s, st, pkt); } } |