From 824e6550f8ef1f361701eae469ada35d3889ab83 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 10 Nov 2013 23:39:29 +0100 Subject: 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.) --- audio/filter/af_lavrresample.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'audio/filter/af_lavrresample.c') 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); -- cgit v1.2.3