# HG changeset patch # User michael # Date 1174141621 0 # Node ID 2949180856b05495c5888ae16be338a9914c8909 # Parent 5e66b1924b43ca6d0972277031ef2af065270978 reorder pts into dts support diff -r 5e66b1924b43 -r 2949180856b0 utils.c --- a/utils.c Sat Mar 17 02:23:53 2007 +0000 +++ b/utils.c Sat Mar 17 14:27:01 2007 +0000 @@ -578,7 +578,7 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, AVCodecParserContext *pc, AVPacket *pkt) { - int num, den, presentation_delayed, delay; + int num, den, presentation_delayed, delay, i; /* handle wrapping */ if(st->cur_dts != AV_NOPTS_VALUE){ if(pkt->pts != AV_NOPTS_VALUE) @@ -615,6 +615,7 @@ // av_log(NULL, AV_LOG_DEBUG, "IN delayed:%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64" st:%d pc:%p\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts, pkt->stream_index, pc); /* interpolate PTS and DTS if they are not present */ + if(delay <=1){ if (presentation_delayed) { /* DTS = decompression time stamp */ /* PTS = presentation time stamp */ @@ -650,7 +651,21 @@ pkt->dts = pkt->pts; st->cur_dts = pkt->pts + pkt->duration; } -// av_log(NULL, AV_LOG_DEBUG, "OUTdelayed:%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, pkt->pts, pkt->dts, st->cur_dts); + } + + if(pkt->pts != AV_NOPTS_VALUE){ + st->pts_buffer[0]= pkt->pts; + for(i=1; ipts_buffer[i] == AV_NOPTS_VALUE; i++) + st->pts_buffer[i]= (i-delay-1) * pkt->duration; + for(i=0; ipts_buffer[i] > st->pts_buffer[i+1]; i++) + FFSWAP(int64_t, st->pts_buffer[i], st->pts_buffer[i+1]); + if(pkt->dts == AV_NOPTS_VALUE) + pkt->dts= st->pts_buffer[0]; + if(pkt->dts > st->cur_dts) + st->cur_dts = pkt->dts; + } + +// av_log(NULL, AV_LOG_ERROR, "OUTdelayed:%d/%d pts:%"PRId64", dts:%"PRId64" cur_dts:%"PRId64"\n", presentation_delayed, delay, pkt->pts, pkt->dts, st->cur_dts); /* update flags */ if (pc) {