FFTContext *fft[2], *ifft[2];
FFTComplex *data_hrtf[2];
- AVFloatDSPContext *fdsp;
+ float (*scalarproduct_float)(const float *v1, const float *v2, int len);
struct hrir_inputs {
int ir_len;
int eof;
- } *hrir_in;
+ } hrir_in[64];
uint64_t mapping[64];
} HeadphoneContext;
}
for (i = 0; i < in->nb_samples; i++) {
- const float *temp_ir = ir;
+ const float *cur_ir = ir;
*dst = 0;
for (l = 0; l < in_channels; l++) {
*(buffer[l] + wr) = src[l];
}
- for (l = 0; l < in_channels; l++) {
+ for (l = 0; l < in_channels; cur_ir += air_len, l++) {
const float *const bptr = buffer[l];
if (l == s->lfe_channel) {
*dst += *(buffer[s->lfe_channel] + wr) * s->gain_lfe;
- temp_ir += air_len;
continue;
}
- read = (wr - (ir_len - 1) + buffer_length) & modulo;
+ read = (wr - (ir_len - 1)) & modulo;
if (read + ir_len < buffer_length) {
memcpy(temp_src, bptr + read, ir_len * sizeof(*temp_src));
memcpy(temp_src + len, bptr, (air_len - len) * sizeof(*temp_src));
}
- dst[0] += s->fdsp->scalarproduct_float(temp_ir, temp_src, FFALIGN(ir_len, 32));
- temp_ir += air_len;
+ dst[0] += s->scalarproduct_float(cur_ir, temp_src, FFALIGN(ir_len, 32));
}
if (fabsf(dst[0]) > 1)
for (j = 0; j < in->nb_samples; j++) {
dst[2 * j] += fft_acc[j].re * fft_scale;
+ if (fabsf(dst[2 * j]) > 1)
+ n_clippings[0]++;
}
for (j = 0; j < ir_len - 1; j++) {
*(ringbuffer + write_pos) += fft_acc[in->nb_samples + j].re * fft_scale;
}
- for (i = 0; i < out->nb_samples; i++) {
- if (fabsf(dst[0]) > 1) {
- n_clippings[0]++;
- }
-
- dst += 2;
- }
-
*write = wr;
return 0;
parse_map(ctx);
- s->hrir_in = av_calloc(s->nb_hrir_inputs, sizeof(*s->hrir_in));
- if (!s->hrir_in)
- return AVERROR(ENOMEM);
-
for (i = 0; i < s->nb_hrir_inputs; i++) {
char *name = av_asprintf("hrir%d", i);
AVFilterPad pad = {
}
}
- s->fdsp = avpriv_float_dsp_alloc(0);
- if (!s->fdsp)
- return AVERROR(ENOMEM);
+ if (s->type == TIME_DOMAIN) {
+ AVFloatDSPContext *fdsp = avpriv_float_dsp_alloc(0);
+ if (!fdsp)
+ return AVERROR(ENOMEM);
+ s->scalarproduct_float = fdsp->scalarproduct_float;
+ av_free(fdsp);
+ }
return 0;
}
av_freep(&s->temp_afft[1]);
av_freep(&s->data_hrtf[0]);
av_freep(&s->data_hrtf[1]);
- av_freep(&s->fdsp);
- av_freep(&s->hrir_in);
for (unsigned i = 1; i < ctx->nb_inputs; i++)
av_freep(&ctx->input_pads[i].name);
}