summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_lavrresample.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-10 23:39:29 +0100
committerwm4 <wm4@nowhere>2013-11-12 23:34:35 +0100
commit824e6550f8ef1f361701eae469ada35d3889ab83 (patch)
tree7170184cfcdce814fde9308941fd2b4ff74d126c /audio/filter/af_lavrresample.c
parent7510caa0c5ef3db320d1065f869d14c0eddecf79 (diff)
downloadmpv-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_lavrresample.c')
-rw-r--r--audio/filter/af_lavrresample.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c
index 02d58122fb..2e298a3f39 100644
--- a/audio/filter/af_lavrresample.c
+++ b/audio/filter/af_lavrresample.c
@@ -249,8 +249,7 @@ static int control(struct af_instance *af, int cmd, void *arg)
if (af_to_avformat(out->format) == AV_SAMPLE_FMT_NONE)
mp_audio_set_format(out, in->format);
- af->mul = (double) (out->rate * out->nch) / (in->rate * in->nch);
- af->delay = out->nch * s->opts.filter_size / FFMIN(af->mul, 1);
+ af->mul = out->rate / (double)in->rate;
int r = ((in->format == orig_in.format) &&
mp_chmap_equals(&in->channels, &orig_in.channels))
@@ -333,9 +332,7 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data)
mp_audio_realloc_min(out, out->samples);
- af->delay = out->bps * av_rescale_rnd(get_delay(s),
- s->ctx.out_rate, s->ctx.in_rate,
- AV_ROUND_UP);
+ af->delay = get_delay(s) / (double)s->ctx.in_rate;
#if !USE_SET_CHANNEL_MAPPING
do_reorder(in, s->reorder_in);
@@ -380,7 +377,6 @@ static int af_open(struct af_instance *af)
af->control = control;
af->uninit = uninit;
af->play = play;
- af->mul = 1;
if (s->opts.cutoff <= 0.0)
s->opts.cutoff = af_resample_default_cutoff(s->opts.filter_size);