+ if (idx == -1)
+ continue;
+ if (s->type == TIME_DOMAIN) {
+ offset = idx * s->air_len;
+ for (j = 0; j < len; j++) {
+ data_ir_l[offset + j] = ptr[len * 2 - j * 2 - 2] * gain_lin;
+ data_ir_r[offset + j] = ptr[len * 2 - j * 2 - 1] * gain_lin;
+ }
+ } else {
+ memset(fft_in_l, 0, n_fft * sizeof(*fft_in_l));
+ memset(fft_in_r, 0, n_fft * sizeof(*fft_in_r));
+
+ offset = idx * n_fft;
+ for (j = 0; j < len; j++) {
+ fft_in_l[delay_l + j].re = ptr[j * 2 ] * gain_lin;
+ fft_in_r[delay_r + j].re = ptr[j * 2 + 1] * gain_lin;
+ }
+
+ av_fft_permute(s->fft[0], fft_in_l);
+ av_fft_calc(s->fft[0], fft_in_l);
+ memcpy(data_hrtf_l + offset, fft_in_l, n_fft * sizeof(*fft_in_l));
+ av_fft_permute(s->fft[0], fft_in_r);
+ av_fft_calc(s->fft[0], fft_in_r);
+ memcpy(data_hrtf_r + offset, fft_in_r, n_fft * sizeof(*fft_in_r));
+ }
+ } else {
+ int I, N = ctx->inputs[1]->channels;
+
+ for (k = 0; k < N / 2; k++) {
+ int idx = -1;
+
+ for (j = 0; j < inlink->channels; j++) {
+ if (s->mapping[k] < 0) {
+ continue;
+ }
+
+ if ((av_channel_layout_extract_channel(inlink->channel_layout, j)) == (1LL << s->mapping[k])) {
+ idx = k;
+ break;
+ }
+ }
+ if (idx == -1)
+ continue;
+
+ I = idx * 2;
+ if (s->type == TIME_DOMAIN) {
+ offset = idx * s->air_len;
+ for (j = 0; j < len; j++) {
+ data_ir_l[offset + j] = ptr[len * N - j * N - N + I ] * gain_lin;
+ data_ir_r[offset + j] = ptr[len * N - j * N - N + I + 1] * gain_lin;
+ }
+ } else {
+ memset(fft_in_l, 0, n_fft * sizeof(*fft_in_l));
+ memset(fft_in_r, 0, n_fft * sizeof(*fft_in_r));
+
+ offset = idx * n_fft;
+ for (j = 0; j < len; j++) {
+ fft_in_l[delay_l + j].re = ptr[j * N + I ] * gain_lin;
+ fft_in_r[delay_r + j].re = ptr[j * N + I + 1] * gain_lin;
+ }
+
+ av_fft_permute(s->fft[0], fft_in_l);
+ av_fft_calc(s->fft[0], fft_in_l);
+ memcpy(data_hrtf_l + offset, fft_in_l, n_fft * sizeof(*fft_in_l));
+ av_fft_permute(s->fft[0], fft_in_r);
+ av_fft_calc(s->fft[0], fft_in_r);
+ memcpy(data_hrtf_r + offset, fft_in_r, n_fft * sizeof(*fft_in_r));
+ }