aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/afir_template.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-04-24 17:31:18 +0200
committerPaul B Mahol <onemda@gmail.com>2023-04-24 22:30:55 +0200
commita0cb29261cddb2b62ee57fbeb689a0234f0cc735 (patch)
tree6259264d3d909556eac5d9b20297a0d6af0edf61 /libavfilter/afir_template.c
parent0b352e350e773673f11ea380f3507923c70e1175 (diff)
downloadffmpeg-a0cb29261cddb2b62ee57fbeb689a0234f0cc735.tar.gz
avfilter/af_afir: cache xfade coefficients
Diffstat (limited to 'libavfilter/afir_template.c')
-rw-r--r--libavfilter/afir_template.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libavfilter/afir_template.c b/libavfilter/afir_template.c
index 63d95de900..5ddc79f6c1 100644
--- a/libavfilter/afir_template.c
+++ b/libavfilter/afir_template.c
@@ -292,6 +292,8 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame *out, int ch, int offse
ftype *blockout, *ptr = (ftype *)out->extended_data[ch] + offset;
const int min_part_size = s->min_part_size;
const int nb_samples = FFMIN(min_part_size, out->nb_samples - offset);
+ const ftype *xfade0 = (const ftype *)s->xfade[0]->extended_data[ch];
+ const ftype *xfade1 = (const ftype *)s->xfade[1]->extended_data[ch];
const int nb_segments = s->nb_segments[selir];
const float dry_gain = s->dry_gain;
@@ -370,7 +372,7 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame *out, int ch, int offse
if (selir == s->selir) {
if (s->loading[ch] <= min_part_size) {
for (int n = 0; n < nb_samples; n++)
- ptr[n] += dst[n] * ((n + 1.f) / nb_samples);
+ ptr[n] += dst[n] * xfade0[n];
}
} else {
fn(fir_fadd)(s, ptr, dst, nb_samples);
@@ -388,7 +390,7 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame *out, int ch, int offse
if (selir != s->selir) {
if (s->loading[ch] <= min_part_size) {
for (int n = 0; n < nb_samples; n++)
- ptr[n] *= (nb_samples - n * 1.f) / nb_samples;
+ ptr[n] *= xfade1[n];
}
return 0;
}