33 #define SAMPLE_FORMAT float
36 #define ctype AVComplexFloat
38 #define TX_TYPE AV_TX_FLOAT_RDFT
40 #define SAMPLE_FORMAT double
43 #define ctype AVComplexDouble
45 #define TX_TYPE AV_TX_DOUBLE_RDFT
48 #define fn3(a,b) a##_##b
49 #define fn2(a,b) fn3(a,b)
50 #define fn(a) fn2(a, SAMPLE_FORMAT)
55 ftype *mag, *phase, *delay,
min = FLT_MAX,
max = FLT_MIN;
56 ftype min_delay = FLT_MAX, max_delay = FLT_MIN;
57 int prev_ymag = -1, prev_yphase = -1, prev_ydelay = -1;
61 for (
int y = 0; y <
s->h; y++)
62 memset(
out->data[0] + y *
out->linesize[0], 0,
s->w * 4);
67 if (!mag || !phase || !delay)
71 for (
i = 0;
i <
s->w;
i++) {
73 double w =
i *
M_PI / (
s->w - 1);
74 double div, real_num = 0., imag_num = 0., real = 0., imag = 0.;
76 for (x = 0; x <
s->nb_taps[
s->selir]; x++) {
77 real += cos(-x *
w) *
src[x];
78 imag += sin(-x *
w) *
src[x];
79 real_num += cos(-x *
w) *
src[x] * x;
80 imag_num += sin(-x *
w) *
src[x] * x;
83 mag[
i] =
hypot(real, imag);
84 phase[
i] = atan2(imag, real);
85 div = real * real + imag * imag;
86 delay[
i] = (real_num * real + imag_num * imag) / div;
89 min_delay =
fminf(min_delay, delay[
i]);
90 max_delay =
fmaxf(max_delay, delay[
i]);
93 for (
i = 0;
i <
s->w;
i++) {
94 int ymag = mag[
i] /
max * (
s->h - 1);
95 int ydelay = (delay[
i] - min_delay) / (max_delay - min_delay) * (
s->h - 1);
96 int yphase = (0.5 * (1. + phase[
i] /
M_PI)) * (
s->h - 1);
98 ymag =
s->h - 1 -
av_clip(ymag, 0,
s->h - 1);
99 yphase =
s->h - 1 -
av_clip(yphase, 0,
s->h - 1);
100 ydelay =
s->h - 1 -
av_clip(ydelay, 0,
s->h - 1);
105 prev_yphase = yphase;
107 prev_ydelay = ydelay;
114 prev_yphase = yphase;
115 prev_ydelay = ydelay;
118 if (
s->w > 400 &&
s->h > 100) {
123 drawtext(
out, 2, 12,
"Min Magnitude:", 0xDDDDDDDD);
128 snprintf(text,
sizeof(text),
"%.2f", max_delay);
132 snprintf(text,
sizeof(text),
"%.2f", min_delay);
143 int cur_nb_taps,
int ch,
156 for (
int i = 0;
i < cur_nb_taps;
i++)
165 for (
int i = 0;
i < cur_nb_taps;
i++)
174 for (
int i = 0;
i < cur_nb_taps;
i++)
175 sum += time[
i] * time[
i];
176 ch_gain = 1. /
SQRT(sum);
210 for (
int i = 0;
i <
size / 2 + 1;
i++)
214 for (
int i = 0;
i <
size / 2 + 1;
i++)
215 sum +=
HYPOT(outc[
i * 2], outc[
i * 2 + 1]);
219 ch_gain = 1. /
power;
231 if (ch_gain != 1. ||
s->ir_gain != 1.) {
232 ftype gain = ch_gain *
s->ir_gain;
236 s->fdsp->vector_fmul_scalar(time, time, gain,
FFALIGN(cur_nb_taps, 4));
238 s->fdsp->vector_dmul_scalar(time, time, gain,
FFALIGN(cur_nb_taps, 8));
248 const int coffset = coeff_partition * seg->coeff_size;
249 const int nb_taps =
s->nb_taps[selir];
250 ftype *time = (
ftype *)
s->norm_ir[selir]->extended_data[ch];
251 ftype *tempin = (
ftype *)seg->tempin->extended_data[ch];
252 ftype *tempout = (
ftype *)seg->tempout->extended_data[ch];
254 const int remaining = nb_taps - (seg->input_offset + coeff_partition * seg->part_size);
255 const int size = remaining >= seg->part_size ? seg->part_size : remaining;
257 memset(tempin +
size, 0,
sizeof(*tempin) * (seg->block_size -
size));
258 memcpy(tempin, time + seg->input_offset + coeff_partition * seg->part_size,
259 size *
sizeof(*tempin));
260 seg->ctx_fn(seg->ctx[ch], tempout, tempin,
sizeof(*tempin));
261 memcpy(
coeff + coffset, tempout, seg->coeff_size *
sizeof(*
coeff));
275 if ((nb_samples & 15) == 0 && nb_samples >= 8) {
277 s->fdsp->vector_fmac_scalar(dst,
src, 1.
f, nb_samples);
279 s->fdsp->vector_dmac_scalar(dst,
src, 1.0, nb_samples);
282 for (
int n = 0; n < nb_samples; n++)
290 const ftype *in = (
const ftype *)
s->in->extended_data[ch] + ioffset;
292 const int min_part_size =
s->min_part_size;
293 const int nb_samples =
FFMIN(min_part_size,
out->nb_samples -
offset);
294 const int nb_segments =
s->nb_segments[selir];
295 const float dry_gain =
s->dry_gain;
296 const float wet_gain =
s->wet_gain;
313 if (dry_gain == 1.
f) {
314 memcpy(
src + input_offset, in, nb_samples *
sizeof(*
src));
315 }
else if (min_part_size >= 8) {
317 s->fdsp->vector_fmul_scalar(
src + input_offset, in, dry_gain,
FFALIGN(nb_samples, 4));
319 s->fdsp->vector_dmul_scalar(
src + input_offset, in, dry_gain,
FFALIGN(nb_samples, 8));
323 for (
int n = 0; n < nb_samples; n++)
324 src2[n] = in[n] * dry_gain;
327 output_offset[0] += min_part_size;
328 if (output_offset[0] >= part_size) {
329 output_offset[0] = 0;
333 dst += output_offset[0];
338 memset(sumin, 0,
sizeof(*sumin) * seg->
fft_length);
341 memset(tempin + part_size, 0,
sizeof(*tempin) * (seg->
block_size - part_size));
342 memcpy(tempin,
src,
sizeof(*
src) * part_size);
343 seg->
tx_fn(seg->
tx[ch], blockout, tempin,
sizeof(
ftype));
346 for (
int i = 0;
i < nb_partitions;
i++) {
347 const int input_partition = j;
348 const int coeff_partition =
i;
349 const int coffset = coeff_partition * seg->
coeff_size;
358 s->afirdsp.fcmul_add(sumin, blockout, (
const ftype *)
coeff, part_size);
360 s->afirdsp.dcmul_add(sumin, blockout, (
const ftype *)
coeff, part_size);
367 memcpy(dst, buf, part_size *
sizeof(*dst));
368 memcpy(buf, sumout + part_size, part_size *
sizeof(*buf));
372 if (part_size != min_part_size)
381 if (min_part_size >= 8) {
383 s->fdsp->vector_fmul_scalar(ptr, ptr, wet_gain,
FFALIGN(nb_samples, 4));
385 s->fdsp->vector_dmul_scalar(ptr, ptr, wet_gain,
FFALIGN(nb_samples, 8));
388 for (
int n = 0; n < nb_samples; n++)