summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-01-29 22:44:20 +0100
committerwm4 <wm4@nowhere>2016-01-29 22:44:20 +0100
commitc5a48c63321de00bb8cb6b91a8d6ed22caa3b36f (patch)
treeb01e6e28b78819a782119049bcbfa717ed88aa75
parent340deb4e6eb1cf09c19cef5bd19c7eab51d6862b (diff)
downloadmpv-c5a48c63321de00bb8cb6b91a8d6ed22caa3b36f.tar.bz2
mpv-c5a48c63321de00bb8cb6b91a8d6ed22caa3b36f.tar.xz
audio: move pts reset check
Reduces the dependency of the filter/output code on the decoder.
-rw-r--r--audio/decode/dec_audio.c12
-rw-r--r--audio/decode/dec_audio.h3
-rw-r--r--player/audio.c17
-rw-r--r--player/core.h1
4 files changed, 17 insertions, 16 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c
index 9fe09ae89f..9e136f2e3b 100644
--- a/audio/decode/dec_audio.c
+++ b/audio/decode/dec_audio.c
@@ -167,7 +167,6 @@ void audio_reset_decoding(struct dec_audio *d_audio)
if (d_audio->ad_driver)
d_audio->ad_driver->control(d_audio, ADCTRL_RESET, NULL);
d_audio->pts = MP_NOPTS_VALUE;
- d_audio->pts_reset = false;
talloc_free(d_audio->current_frame);
d_audio->current_frame = NULL;
talloc_free(d_audio->packet);
@@ -183,17 +182,8 @@ static void fix_audio_pts(struct dec_audio *da)
double newpts = da->current_frame->pts;
// Keep the interpolated timestamp if it doesn't deviate more
// than 1 ms from the real one. (MKV rounded timestamps.)
- if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - newpts) > 0.001) {
- // 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 (da->pts != MP_NOPTS_VALUE && fabs(newpts - da->pts) > 0.1) {
- MP_WARN(da, "Invalid audio PTS: %f -> %f\n",
- da->pts, newpts);
- da->pts_reset = true;
- }
+ if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - newpts) > 0.001)
da->pts = da->current_frame->pts;
- }
}
if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps)
diff --git a/audio/decode/dec_audio.h b/audio/decode/dec_audio.h
index 27752f7be1..90451ef787 100644
--- a/audio/decode/dec_audio.h
+++ b/audio/decode/dec_audio.h
@@ -36,9 +36,6 @@ struct dec_audio {
bool try_spdif;
- // set every time a jump in timestamps is encountered
- bool pts_reset;
-
// For free use by the ad_driver
void *priv;
diff --git a/player/audio.c b/player/audio.c
index ddf32fb277..e9320d5117 100644
--- a/player/audio.c
+++ b/player/audio.c
@@ -166,6 +166,7 @@ void update_playback_speed(struct MPContext *mpctx)
static void ao_chain_reset_state(struct ao_chain *ao_c)
{
ao_c->pts = MP_NOPTS_VALUE;
+ ao_c->pts_reset = false;
talloc_free(ao_c->input_frame);
ao_c->input_frame = NULL;
af_seek_reset(ao_c->af);
@@ -611,7 +612,19 @@ static int filter_audio(struct ao_chain *ao_c, struct mp_audio_buffer *outbuf,
struct mp_audio *mpa = ao_c->input_frame;
ao_c->input_frame = NULL;
- ao_c->pts = mpa->pts + mpa->samples / (double)mpa->rate;
+ if (mpa->pts == MP_NOPTS_VALUE) {
+ ao_c->pts = MP_NOPTS_VALUE;
+ } else {
+ // 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 (ao_c->pts != MP_NOPTS_VALUE && fabs(mpa->pts - ao_c->pts) > 0.1) {
+ MP_WARN(ao_c, "Invalid audio PTS: %f -> %f\n",
+ ao_c->pts, mpa->pts);
+ ao_c->pts_reset = true;
+ }
+ ao_c->pts = mpa->pts + mpa->samples / (double)mpa->rate;
+ }
if (af_filter_frame(afs, mpa) < 0)
return AD_ERR;
}
@@ -660,7 +673,7 @@ void fill_audio_out_buffers(struct MPContext *mpctx, double endpts)
return; // try again next iteration
}
- if (mpctx->vo_chain && ao_c->audio_src->pts_reset) {
+ if (mpctx->vo_chain && ao_c->pts_reset) {
MP_VERBOSE(mpctx, "Reset playback due to audio timestamp reset.\n");
reset_playback_state(mpctx);
mpctx->sleeptime = 0;
diff --git a/player/core.h b/player/core.h
index 7d34380e87..b144ab6936 100644
--- a/player/core.h
+++ b/player/core.h
@@ -179,6 +179,7 @@ struct ao_chain {
double pts; // timestamp of first sample output by decoder
bool spdif_passthrough, spdif_failed;
+ bool pts_reset;
struct af_stream *af;
struct ao *ao;