summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--filters/f_decoder_wrapper.c14
-rw-r--r--filters/f_decoder_wrapper.h3
-rw-r--r--player/audio.c23
-rw-r--r--player/core.h1
4 files changed, 20 insertions, 21 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.
diff --git a/player/audio.c b/player/audio.c
index 5b061efca1..37c5446bd9 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -179,7 +179,6 @@ void update_playback_speed(struct MPContext *mpctx)
static void ao_chain_reset_state(struct ao_chain *ao_c)
{
ao_c->last_out_pts = MP_NOPTS_VALUE;
- ao_c->pts_reset = false;
TA_FREEP(&ao_c->output_frame);
ao_c->out_eof = false;
@@ -658,21 +657,6 @@ static bool copy_output(struct MPContext *mpctx, struct ao_chain *ao_c,
if (frame.type == MP_FRAME_AUDIO) {
ao_c->output_frame = frame.data;
ao_c->out_eof = false;
-
- double pts = mp_aframe_get_pts(ao_c->output_frame);
- if (pts != MP_NOPTS_VALUE) {
- // 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.
- double desync = pts - ao_c->last_out_pts;
- if (ao_c->last_out_pts != MP_NOPTS_VALUE && fabs(desync) > 0.1)
- {
- MP_WARN(ao_c, "Invalid audio PTS: %f -> %f\n",
- ao_c->last_out_pts, pts);
- if (desync >= 5)
- ao_c->pts_reset = true;
- }
- }
ao_c->last_out_pts = mp_aframe_end_pts(ao_c->output_frame);
} else if (frame.type == MP_FRAME_EOF) {
ao_c->out_eof = true;
@@ -786,8 +770,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
// (if AO is set due to gapless from previous file, then we can try to
// filter normally until the filter tells us to change the AO)
if (!mpctx->ao) {
- // Probe the initial audio format. Returns AD_OK (and does nothing) if
- // the format is already known.
+ // Probe the initial audio format.
mp_pin_out_request_data(ao_c->filter->f->pins[1]);
reinit_audio_filters_and_output(mpctx);
return; // try again next iteration
@@ -799,7 +782,9 @@ void fill_audio_out_buffers(struct MPContext *mpctx)
return;
}
- if (mpctx->vo_chain && ao_c->pts_reset) {
+ if (mpctx->vo_chain && ao_c->track && ao_c->track->dec &&
+ ao_c->track->dec->pts_reset)
+ {
MP_VERBOSE(mpctx, "Reset playback due to audio timestamp reset.\n");
reset_playback_state(mpctx);
mp_wakeup_core(mpctx);
diff --git a/player/core.h b/player/core.h
index 104d26cd48..27696e8f06 100644
--- a/player/core.h
+++ b/player/core.h
@@ -187,7 +187,6 @@ struct ao_chain {
struct mp_log *log;
bool spdif_passthrough, spdif_failed;
- bool pts_reset;
struct mp_output_chain *filter;