summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-02-19 18:28:46 +0100
committerwm4 <wm4@nowhere>2016-02-19 18:28:46 +0100
commitb3804e71af34fa76e17d9bf6d6575383a3a4aa21 (patch)
tree3b25aa697066039ec32d19b37e97dbcfdbfcc770
parentee5ba9678a17368428e0f69029786dfd767d9a63 (diff)
downloadmpv-b3804e71af34fa76e17d9bf6d6575383a3a4aa21.tar.bz2
mpv-b3804e71af34fa76e17d9bf6d6575383a3a4aa21.tar.xz
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.
-rw-r--r--video/decode/dec_video.c17
1 files changed, 8 insertions, 9 deletions
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;