Mercurial > libavformat.hg
changeset 3048:a100291d922c libavformat
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.
author | michael |
---|---|
date | Fri, 15 Feb 2008 20:32:32 +0000 |
parents | 3c374f48768d |
children | df47846972da |
files | utils.c |
diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/utils.c Fri Feb 15 13:21:00 2008 +0000 +++ b/utils.c Fri Feb 15 20:32:32 2008 +0000 @@ -632,6 +632,24 @@ 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 @@ 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); } }