From b3804e71af34fa76e17d9bf6d6575383a3a4aa21 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 19 Feb 2016 18:28:46 +0100 Subject: video: move packet timestamp fudging There is some strange code which sets the DTS of the packet to PTS (but only if it's not AVI), which apparently helps with timestamp determination with some broken files. This code is annoying because it tries to avoid mutating the packet (which it logically doesn't own). Move it to where it does and get rid of the packet_copy mess. Needed for the following commit. --- video/decode/dec_video.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'video/decode') diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index ecba84f6a7..42c7e873ad 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -248,18 +248,10 @@ static struct mp_image *decode_packet(struct dec_video *d_video, int drop_frame) { struct MPOpts *opts = d_video->opts; - bool avi_pts = d_video->codec->avi_dts && opts->correct_pts; if (!d_video->vd_driver) return NULL; - struct demux_packet packet_copy; - if (packet && packet->dts == MP_NOPTS_VALUE && !avi_pts) { - packet_copy = *packet; - packet = &packet_copy; - packet->dts = packet->pts; - } - double pkt_pts = packet ? packet->pts : MP_NOPTS_VALUE; double pkt_dts = packet ? packet->dts : MP_NOPTS_VALUE; @@ -338,7 +330,9 @@ static struct mp_image *decode_packet(struct dec_video *d_video, d_video->decoded_pts = pts; // Compensate for incorrectly using mpeg-style DTS for avi timestamps. - if (avi_pts && mpi->pts != MP_NOPTS_VALUE && d_video->fps > 0) { + if (d_video->codec->avi_dts && opts->correct_pts && + mpi->pts != MP_NOPTS_VALUE && d_video->fps > 0) + { int delay = -1; video_vd_control(d_video, VDCTRL_GET_BFRAMES, &delay); mpi->pts -= MPMAX(delay, 0) / d_video->fps; @@ -391,6 +385,11 @@ void video_work(struct dec_video *d_video) return; } + if (d_video->packet) { + if (d_video->packet->dts == MP_NOPTS_VALUE && !d_video->codec->avi_dts) + d_video->packet->dts = d_video->packet->pts; + } + if (d_video->packet && d_video->packet->new_segment) { assert(!d_video->new_segment); d_video->new_segment = d_video->packet; -- cgit v1.2.3