diff options
author | wm4 <wm4@nowhere> | 2013-11-10 23:39:29 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-12 23:34:35 +0100 |
commit | 824e6550f8ef1f361701eae469ada35d3889ab83 (patch) | |
tree | 7170184cfcdce814fde9308941fd2b4ff74d126c /audio/filter/af_scaletempo.c | |
parent | 7510caa0c5ef3db320d1065f869d14c0eddecf79 (diff) | |
download | mpv-824e6550f8ef1f361701eae469ada35d3889ab83.tar.bz2 mpv-824e6550f8ef1f361701eae469ada35d3889ab83.tar.xz |
audio/filter: fix mul/delay scale and values
Before this commit, the af_instance->mul/delay values were in bytes.
Using bytes is confusing for non-interleaved audio, so switch mul to
samples, and delay to seconds. For delay, seconds are more intuitive
than bytes or samples, because it's used for the latency calculation.
We also might want to replace the delay mechanism with real PTS
tracking inside the filter chain some time in the future, and PTS
will also require time-adjustments to be done in seconds.
For most filters, we just remove the redundant mul=1 initialization.
(Setting this used to be required, but not anymore.)
Diffstat (limited to 'audio/filter/af_scaletempo.c')
-rw-r--r-- | audio/filter/af_scaletempo.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/audio/filter/af_scaletempo.c b/audio/filter/af_scaletempo.c index 456de89812..c8560af502 100644 --- a/audio/filter/af_scaletempo.c +++ b/audio/filter/af_scaletempo.c @@ -256,7 +256,8 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data) // This filter can have a negative delay when scale > 1: // output corresponding to some length of input can be decided and written // after receiving only a part of that input. - af->delay = s->bytes_queued - s->bytes_to_slide; + af->delay = (s->bytes_queued - s->bytes_to_slide) / s->scale + / af->data->sstride / af->data->rate; data->planes[0] = af->data->planes[0]; data->samples = (pout - (int8_t *)af->data->planes[0]) / af->data->sstride; @@ -299,9 +300,8 @@ static int control(struct af_instance *af, int cmd, void *arg) s->frames_stride = srate * s->ms_stride; s->bytes_stride = s->frames_stride * bps * nch; s->frames_stride_scaled = s->scale * s->frames_stride; - int bytes_stride_scaled = s->scale * s->bytes_stride; s->frames_stride_error = 0; - af->mul = (double)s->bytes_stride / bytes_stride_scaled; + af->mul = 1.0 / s->scale; af->delay = 0; int frames_overlap = s->frames_stride * s->percent_overlap; @@ -462,7 +462,6 @@ static int af_open(struct af_instance *af) af->control = control; af->uninit = uninit; af->play = play; - af->mul = 1; s->speed_tempo = !!(s->speed_opt & SCALE_TEMPO); s->speed_pitch = !!(s->speed_opt & SCALE_PITCH); |