summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-28 13:34:56 +0100
committerwm4 <wm4@nowhere>2013-11-28 15:20:33 +0100
commit3bed78fdfd425c4d5652c5811eb37d47a65d33cc (patch)
tree6320b11f8f6a543b58e281e46236ec983cd87894 /video
parente8677aa36333206f59fae610e9b94ad5d2c3c7e2 (diff)
downloadmpv-3bed78fdfd425c4d5652c5811eb37d47a65d33cc.tar.bz2
mpv-3bed78fdfd425c4d5652c5811eb37d47a65d33cc.tar.xz
video: add heuristic to prevent framedrop during hrseek if pts broken
Using --start with files that use DTS only, or which simply have broken PTS timestamps, would incorrectly drop frames and possibly not execute the seek correctly. Add yet another heuristic to detect this. The intent is that --start and hr-seeks in general should work correctly, but in order to keep things fast, we still want to allow frame dropping during hr-seek if there are no problems doing so. Do this by disabling frame dropping by default, but re-enabling it if there are no problems found for a while. As a consequence, --start might be somewhat slower, but normal user interaction should remain as fast as before. Note that there's something subtle about the added code: the has_broken_packet_pts field is checked even before the first packet is fed to dec_video.c, so the field must not be set to 0 right on start. It's not initially set to 0 anyway, because the heuristic requires decoding some images before enabling frame drop anyway. Note 2: it's not clear whether frame dropping during hr-seek really helps; I didn't benchmark it.
Diffstat (limited to 'video')
-rw-r--r--video/decode/dec_video.c6
-rw-r--r--video/decode/dec_video.h3
2 files changed, 9 insertions, 0 deletions
diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c
index 1802e19fbf..ec4cd5b775 100644
--- a/video/decode/dec_video.c
+++ b/video/decode/dec_video.c
@@ -171,6 +171,7 @@ bool video_init_best_codec(struct dec_video *d_video, char* video_decoders)
{
assert(!d_video->vd_driver);
video_reset_decoding(d_video);
+ d_video->has_broken_packet_pts = -10; // needs 10 packets to reach decision
struct mp_decoder_entry *decoder = NULL;
struct mp_decoder_list *list =
@@ -363,6 +364,11 @@ struct mp_image *video_decode(struct dec_video *d_video,
pts = d_video->decoded_pts;
}
+ if (d_video->has_broken_packet_pts < 0)
+ d_video->has_broken_packet_pts++;
+ if (d_video->num_codec_pts_problems || pkt_pts == MP_NOPTS_VALUE)
+ d_video->has_broken_packet_pts = 1;
+
mpi->pts = pts;
d_video->decoded_pts = pts;
return mpi;
diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h
index d411717a32..090b60bc1c 100644
--- a/video/decode/dec_video.h
+++ b/video/decode/dec_video.h
@@ -62,6 +62,9 @@ struct dec_video {
// PTS or DTS of packet last read
double last_packet_pdts;
+ // There was at least one packet with non-sense timestamps.
+ int has_broken_packet_pts; // <0: uninitialized, 0: no problems, 1: broken
+
// Final PTS of previously decoded image
double decoded_pts;