summaryrefslogtreecommitdiffstats
path: root/audio/filter/af.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.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.c')
-rw-r--r--audio/filter/af.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/audio/filter/af.c b/audio/filter/af.c
index 182ed27d03..63013e81d9 100644
--- a/audio/filter/af.c
+++ b/audio/filter/af.c
@@ -703,12 +703,12 @@ struct mp_audio *af_play(struct af_stream *s, struct mp_audio *data)
return data;
}
-// Calculate average ratio of filter output size to input size
+// Calculate average ratio of filter output samples to input samples.
+// e.g: num_output_samples = mul * num_input_samples
double af_calc_filter_multiplier(struct af_stream *s)
{
struct af_instance *af = s->first;
double mul = 1;
- // Iterate through all filters and calculate total multiplication factor
do {
mul *= af->mul;
af = af->next;
@@ -721,11 +721,9 @@ double af_calc_filter_multiplier(struct af_stream *s)
double af_calc_delay(struct af_stream *s)
{
struct af_instance *af = s->first;
- register double delay = 0.0;
- // Iterate through all filters
+ double delay = 0.0;
while (af) {
delay += af->delay;
- delay *= af->mul;
af = af->next;
}
return delay;