From 9f72a9753e68c4064796f2361fb12492a85a8e0b Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Nov 2013 23:13:01 +0100 Subject: demux: export dts from demux_lavf, use it for avi Having the DTS directly can be useful for restoring PTS values. The avi file format doesn't actually store PTS values, just DTS. An older hack explicitly exported the DTS as PTS (ignoring the [I assume] genpts generated non-sense PTS), which is not necessary anymore due to this change. --- demux/demux_lavf.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'demux/demux_lavf.c') diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index fe0b3efdd2..98efbc32f3 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -82,7 +82,6 @@ typedef struct lavf_priv { struct sh_stream **streams; // NULL for unknown streams int num_streams; int cur_program; - bool use_dts; char *mime_type; bool genpts_hack; AVPacket *packets[MAX_PKT_QUEUE]; @@ -541,8 +540,6 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) if (matches_avinputformat_name(priv, "avi")) { /* for avi libavformat returns the avi timestamps in .dts, * some made-up stuff that's not really pts in .pts */ - priv->use_dts = true; - demuxer->timestamp_type = TIMESTAMP_TYPE_SORT; } else { int mode = lavfdopts->genptsmode; if (mode == 0 && opts->correct_pts) @@ -785,14 +782,18 @@ static int demux_lavf_fill_buffer(demuxer_t *demux) dp = new_demux_packet_fromdata(pkt->data, pkt->size); dp->avpacket = talloc_steal(dp, pkt); - int64_t ts = priv->use_dts ? pkt->dts : pkt->pts; - if (ts != AV_NOPTS_VALUE) { - dp->pts = ts * av_q2d(st->time_base); - priv->last_pts = dp->pts * AV_TIME_BASE; - dp->duration = pkt->duration * av_q2d(st->time_base); - if (pkt->convergence_duration > 0) - dp->duration = pkt->convergence_duration * av_q2d(st->time_base); + if (pkt->pts != AV_NOPTS_VALUE) { + dp->pts = pkt->pts * av_q2d(st->time_base); + priv->last_pts = dp->pts; } + if (pkt->dts != AV_NOPTS_VALUE) { + dp->dts = pkt->dts * av_q2d(st->time_base); + if (priv->last_pts == AV_NOPTS_VALUE) + priv->last_pts = pkt->dts; + } + dp->duration = pkt->duration * av_q2d(st->time_base); + if (pkt->convergence_duration > 0) + dp->duration = pkt->convergence_duration * av_q2d(st->time_base); dp->pos = pkt->pos; dp->keyframe = pkt->flags & AV_PKT_FLAG_KEY; // Use only one stream for stream_pts, otherwise PTS might be jumpy. -- cgit v1.2.3