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_lavcac3enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'audio/filter/af_lavcac3enc.c') diff --git a/audio/filter/af_lavcac3enc.c b/audio/filter/af_lavcac3enc.c index 6ecefa0d8f..2820e71f41 100644 --- a/audio/filter/af_lavcac3enc.c +++ b/audio/filter/af_lavcac3enc.c @@ -88,12 +88,13 @@ static int control(struct af_instance *af, int cmd, void *arg) test_output_res = af_test_output(af, data); s->pending_len = 0; - s->expect_len = AC3_FRAME_SIZE * data->nch * af->data->bps; + int expect_samples = AC3_FRAME_SIZE; + s->expect_len = expect_samples * data->nch * af->data->bps; assert(s->expect_len <= s->pending_data_size); if (s->add_iec61937_header) - af->mul = (double)AC3_FRAME_SIZE * 2 * 2 / s->expect_len; + af->mul = 1; else - af->mul = (double)AC3_MAX_CODED_FRAME_SIZE / s->expect_len; + af->mul = (double)(AC3_MAX_CODED_FRAME_SIZE / (2 * 2)) / expect_samples; mp_msg(MSGT_AFILTER, MSGL_DBG2, "af_lavcac3enc reinit: %d, %d, %f, %d.\n", data->nch, data->rate, af->mul, s->expect_len); @@ -306,7 +307,6 @@ static int af_open(struct af_instance* af){ af->control=control; af->uninit=uninit; af->play=play; - af->mul=1; af->setup=s; s->lavc_acodec = avcodec_find_encoder_by_name("ac3"); -- cgit v1.2.3