summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_lavcac3enc.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_lavcac3enc.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_lavcac3enc.c')
-rw-r--r--audio/filter/af_lavcac3enc.c8
1 files changed, 4 insertions, 4 deletions
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");