summaryrefslogtreecommitdiffstats
path: root/filters
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-02-12 18:00:23 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-02-13 17:45:29 -0800
commit02f9087de9103784a236f50d4b0990069ae9cf1e (patch)
treeffedf5a29e66ab95494a67e69e761383441a44cf /filters
parent562f563ff1835daa0d749d1e9bcbe389412ffd98 (diff)
downloadmpv-02f9087de9103784a236f50d4b0990069ae9cf1e.tar.bz2
mpv-02f9087de9103784a236f50d4b0990069ae9cf1e.tar.xz
audio: move back PTS jump detection to before filter chain
The recent changes to player/audio.c moved PTS jump detection to after audio filtering. This was mostly done for convenience, because dataflow between decoder and filters was made "automatic", and jump detection would have to be done as filter. Now move it back to after decoders, again out of convenience. The future direction is to make the dataflow between filters and AO automatic, so this is a bit in the way. Another reason is that speed changes tend to cause jumps - these are legitimate, but get annoying quickly.
Diffstat (limited to 'filters')
-rw-r--r--filters/f_decoder_wrapper.c14
-rw-r--r--filters/f_decoder_wrapper.h3
2 files changed, 16 insertions, 1 deletions
diff --git a/filters/f_decoder_wrapper.c b/filters/f_decoder_wrapper.c
index 0e078c0575..061f056a1e 100644
--- a/filters/f_decoder_wrapper.c
+++ b/filters/f_decoder_wrapper.c
@@ -105,6 +105,7 @@ static void reset_decoder(struct priv *p)
p->last_format = p->fixed_format = (struct mp_image_params){0};
p->public.dropped_frames = 0;
p->public.attempt_framedrops = 0;
+ p->public.pts_reset = false;
p->packets_without_output = 0;
mp_frame_unref(&p->packet);
talloc_free(p->new_segment);
@@ -402,9 +403,20 @@ static void process_audio_frame(struct priv *p, struct mp_aframe *aframe)
if (p->pts != MP_NOPTS_VALUE)
MP_STATS(p, "value %f audio-pts-err", p->pts - frame_pts);
+ double diff = fabs(p->pts - frame_pts);
+
+ // Attempt to detect jumps in PTS. Even for the lowest sample rates and
+ // with worst container rounded timestamp, this should be a margin more
+ // than enough.
+ if (p->pts != MP_NOPTS_VALUE && diff > 0.1) {
+ MP_WARN(p, "Invalid audio PTS: %f -> %f\n", p->pts, frame_pts);
+ if (diff >= 5)
+ p->public.pts_reset = true;
+ }
+
// Keep the interpolated timestamp if it doesn't deviate more
// than 1 ms from the real one. (MKV rounded timestamps.)
- if (p->pts == MP_NOPTS_VALUE || fabs(p->pts - frame_pts) > 0.001)
+ if (p->pts == MP_NOPTS_VALUE || diff > 0.001)
p->pts = frame_pts;
}
diff --git a/filters/f_decoder_wrapper.h b/filters/f_decoder_wrapper.h
index e6601052a2..119e0f9eb6 100644
--- a/filters/f_decoder_wrapper.h
+++ b/filters/f_decoder_wrapper.h
@@ -51,6 +51,9 @@ struct mp_decoder_wrapper {
// Prefer spdif wrapper over real decoders.
bool try_spdif;
+
+ // A pts reset was observed (audio only, heuristic).
+ bool pts_reset;
};
// Create the decoder wrapper for the given stream, plus underlying decoder.