diff options
author | Ivan Schreter <schreter@gmx.net> | 2009-02-24 22:19:09 +0000 |
---|---|---|
committer | Carl Eugen Hoyos <cehoyos@rainbow.studorg.tuwien.ac.at> | 2009-02-24 22:19:09 +0000 |
commit | 27ca0a79c9d68059cdac610cdddb7039e6281529 (patch) | |
tree | 47514685538f6f49152e10898168b4bf90193f4e /libavformat/utils.c | |
parent | 4d8f8301254c7734182acd129c7e232e53bbca08 (diff) | |
download | ffmpeg-27ca0a79c9d68059cdac610cdddb7039e6281529.tar.gz |
Add timestamp computation if values are exported by decoder.
Patch by Ivan Schreter, schreter gmx net
Originally committed as revision 17574 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 61f74c3c18..073e6dacdc 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -834,6 +834,25 @@ static void compute_pkt_fields(AVFormatContext *s, AVStream *st, pkt->dts += offset; } + if (pc && pc->dts_sync_point >= 0) { + // we have synchronization info from the parser + int64_t den = st->codec->time_base.den * (int64_t) st->time_base.num; + if (den > 0) { + int64_t num = st->codec->time_base.num * (int64_t) st->time_base.den; + if (pkt->dts != AV_NOPTS_VALUE) { + // got DTS from the stream, update reference timestamp + st->reference_dts = pkt->dts - pc->dts_ref_dts_delta * num / den; + pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; + } else if (st->reference_dts != AV_NOPTS_VALUE) { + // compute DTS based on reference timestamp + pkt->dts = st->reference_dts + pc->dts_ref_dts_delta * num / den; + pkt->pts = pkt->dts + pc->pts_dts_delta * num / den; + } + if (pc->dts_sync_point > 0) + st->reference_dts = pkt->dts; // new reference + } + } + /* This may be redundant, but it should not hurt. */ if(pkt->dts != AV_NOPTS_VALUE && pkt->pts != AV_NOPTS_VALUE && pkt->pts > pkt->dts) presentation_delayed = 1; @@ -1157,6 +1176,7 @@ static void av_read_frame_flush(AVFormatContext *s) } st->last_IP_pts = AV_NOPTS_VALUE; st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */ + st->reference_dts = AV_NOPTS_VALUE; /* fail safe */ st->cur_ptr = NULL; st->cur_len = 0; @@ -2332,6 +2352,7 @@ AVStream *av_new_stream(AVFormatContext *s, int id) st->last_IP_pts = AV_NOPTS_VALUE; for(i=0; i<MAX_REORDER_DELAY+1; i++) st->pts_buffer[i]= AV_NOPTS_VALUE; + st->reference_dts = AV_NOPTS_VALUE; st->sample_aspect_ratio = (AVRational){0,1}; |