avfilter: fix av_tx_fn stride usage for complex inputs

This commit is contained in:
Paul B Mahol 2022-11-19 00:04:06 +01:00
parent fced45fd95
commit 3bcec58535
20 changed files with 52 additions and 52 deletions

View File

@ -240,7 +240,7 @@ static int tx_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
AVComplexFloat *fft_in = s->fft_in[ch];
AVComplexFloat *fft_out = s->fft_out[ch];
s->tx_fn(s->fft[ch], fft_out, fft_in, sizeof(float));
s->tx_fn(s->fft[ch], fft_out, fft_in, sizeof(*fft_in));
}
return 0;
@ -292,7 +292,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
}
}
s->itx_fn(s->ifft[ch], fft_out, fft_temp, sizeof(float));
s->itx_fn(s->ifft[ch], fft_out, fft_temp, sizeof(*fft_temp));
memmove(buf, buf + s->hop_size, window_size * sizeof(float));
for (int i = 0; i < window_size; i++)

View File

@ -188,7 +188,7 @@ static int config_input(AVFilterLink *inlink)
AudioPsyClipContext *s = ctx->priv;
static const int points[][2] = { {0,14}, {125,14}, {250,16}, {500,18}, {1000,20}, {2000,20}, {4000,20}, {8000,17}, {16000,14}, {20000,-10} };
static const int num_points = 10;
float scale;
float scale = 1.f;
int ret;
s->fft_size = inlink->sample_rate > 100000 ? 1024 : inlink->sample_rate > 50000 ? 512 : 256;
@ -417,7 +417,7 @@ static void feed(AVFilterContext *ctx, int ch,
apply_window(s, in_frame, windowed_frame, 0);
r2c(windowed_frame, s->fft_size);
s->tx_fn(s->tx_ctx[ch], spectrum_buf, windowed_frame, sizeof(float));
s->tx_fn(s->tx_ctx[ch], spectrum_buf, windowed_frame, sizeof(AVComplexFloat));
c2r(windowed_frame, s->fft_size);
calculate_mask_curve(s, spectrum_buf, mask_curve);
@ -447,11 +447,11 @@ static void feed(AVFilterContext *ctx, int ch,
clip_to_window(s, windowed_frame, clipping_delta, delta_boost);
r2c(clipping_delta, s->fft_size);
s->tx_fn(s->tx_ctx[ch], spectrum_buf, clipping_delta, sizeof(float));
s->tx_fn(s->tx_ctx[ch], spectrum_buf, clipping_delta, sizeof(AVComplexFloat));
limit_clip_spectrum(s, spectrum_buf, mask_curve);
s->itx_fn(s->itx_ctx[ch], clipping_delta, spectrum_buf, sizeof(float));
s->itx_fn(s->itx_ctx[ch], clipping_delta, spectrum_buf, sizeof(AVComplexFloat));
c2r(clipping_delta, s->fft_size);
for (int i = 0; i < s->fft_size; i++)

View File

@ -111,7 +111,7 @@ AVFILTER_DEFINE_CLASS(aspectralstats);
static int config_output(AVFilterLink *outlink)
{
AudioSpectralStatsContext *s = outlink->src->priv;
float overlap, scale;
float overlap, scale = 1.f;
int ret;
s->nb_channels = outlink->ch_layout.nb_channels;
@ -460,7 +460,7 @@ static int filter_channel(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
fft_in[n].im = 0;
}
s->tx_fn(s->fft[ch], fft_out, fft_in, sizeof(float));
s->tx_fn(s->fft[ch], fft_out, fft_in, sizeof(*fft_in));
for (int n = 0; n < s->win_size / 2; n++) {
fft_out[n].re *= scale;

View File

@ -619,7 +619,7 @@ static void yae_xcorr_via_rdft(float *xcorr_in,
}
// apply inverse rDFT:
c2r_fn(complex_to_real, xcorr, xcorr_in, sizeof(float));
c2r_fn(complex_to_real, xcorr, xcorr_in, sizeof(*xc));
}
/**

View File

@ -286,7 +286,7 @@ static int de_stereo(AVFilterContext *ctx, AVFrame *out)
get_final(center, windowed_oleft, windowed_oright, vad, s->fft_size / 2 + 1,
s->original, s->enhance);
s->itx_fn(s->itx_ctx, windowed_oleft, center, sizeof(float));
s->itx_fn(s->itx_ctx, windowed_oleft, center, sizeof(AVComplexFloat));
apply_window(s, windowed_oleft, left_out, 1);

View File

@ -273,7 +273,7 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
fft_in[j].re = src[j * in_channels + i];
}
tx_fn(fft, fft_out, fft_in, sizeof(float));
tx_fn(fft, fft_out, fft_in, sizeof(*fft_in));
for (j = 0; j < n_fft; j++) {
const AVComplexFloat *hcomplex = hrtf_offset + j;
@ -285,7 +285,7 @@ static int headphone_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
}
}
itx_fn(ifft, fft_out, fft_acc, sizeof(float));
itx_fn(ifft, fft_out, fft_acc, sizeof(*fft_acc));
for (j = 0; j < in->nb_samples; j++) {
dst[2 * j] += fft_out[j].re * fft_scale;
@ -480,8 +480,8 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
fft_in_r[j].re = ptr[j * 2 + 1] * gain_lin;
}
s->tx_fn[0](s->fft[0], fft_out_l, fft_in_l, sizeof(float));
s->tx_fn[0](s->fft[0], fft_out_r, fft_in_r, sizeof(float));
s->tx_fn[0](s->fft[0], fft_out_l, fft_in_l, sizeof(*fft_in_l));
s->tx_fn[0](s->fft[0], fft_out_r, fft_in_r, sizeof(*fft_in_r));
}
} else {
int I, N = ctx->inputs[1]->ch_layout.nb_channels;
@ -513,8 +513,8 @@ static int convert_coeffs(AVFilterContext *ctx, AVFilterLink *inlink)
fft_in_r[j].re = ptr[j * N + I + 1] * gain_lin;
}
s->tx_fn[0](s->fft[0], fft_out_l, fft_in_l, sizeof(float));
s->tx_fn[0](s->fft[0], fft_out_r, fft_in_r, sizeof(float));
s->tx_fn[0](s->fft[0], fft_out_l, fft_in_l, sizeof(*fft_in_l));
s->tx_fn[0](s->fft[0], fft_out_r, fft_in_r, sizeof(*fft_in_r));
}
}
}

View File

@ -525,7 +525,7 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
}
/* transform input signal of current channel to frequency domain */
tx_fn(fft, fft_out, fft_in, sizeof(float));
tx_fn(fft, fft_out, fft_in, sizeof(*fft_in));
for (j = 0; j < n_fft; j++) {
const AVComplexFloat *hcomplex = hrtf_offset + j;
@ -541,7 +541,7 @@ static int sofalizer_fast_convolute(AVFilterContext *ctx, void *arg, int jobnr,
}
/* transform output signal of current channel back to time domain */
itx_fn(ifft, fft_out, fft_acc, sizeof(float));
itx_fn(ifft, fft_out, fft_acc, sizeof(*fft_acc));
for (j = 0; j < in->nb_samples; j++) {
/* write output signal of current channel to output buffer */
@ -832,7 +832,7 @@ static int load_data(AVFilterContext *ctx, int azim, int elev, float radius, int
s->n_fft = n_fft = 1 << (32 - ff_clz(n_max + s->framesize));
if (s->type == FREQUENCY_DOMAIN) {
float scale;
float scale = 1.f;
av_tx_uninit(&s->fft[0]);
av_tx_uninit(&s->fft[1]);
@ -927,9 +927,9 @@ static int load_data(AVFilterContext *ctx, int azim, int elev, float radius, int
}
/* actually transform to frequency domain (IRs -> HRTFs) */
s->tx_fn[0](s->fft[0], fft_out_l, fft_in_l, sizeof(float));
s->tx_fn[0](s->fft[0], fft_out_l, fft_in_l, sizeof(*fft_in_l));
memcpy(data_hrtf_l + offset, fft_out_l, n_fft * sizeof(*fft_out_l));
s->tx_fn[1](s->fft[1], fft_out_r, fft_in_r, sizeof(float));
s->tx_fn[1](s->fft[1], fft_out_r, fft_in_r, sizeof(*fft_in_r));
memcpy(data_hrtf_r + offset, fft_out_r, n_fft * sizeof(*fft_out_r));
}
}

View File

@ -225,7 +225,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
fsamples_out[i*2+1] = im;
}
s->itx_fn(s->irdft, fsamples, fsamples_out, sizeof(float));
s->itx_fn(s->irdft, fsamples, fsamples_out, sizeof(AVComplexFloat));
for (i = 0; i < s->winlen; i++)
dst[i] += fsamples[i] / s->tabsize;

View File

@ -1264,7 +1264,7 @@ static int ifft_channel(AVFilterContext *ctx, AVFrame *out, int ch)
dst = (float *)s->output_out->extended_data[ch];
ptr = (float *)s->overlap_buffer->extended_data[ch];
s->itx_fn(s->irdft[ch], dst, (float *)s->output->extended_data[ch], sizeof(float));
s->itx_fn(s->irdft[ch], dst, (float *)s->output->extended_data[ch], sizeof(AVComplexFloat));
memmove(s->overlap_buffer->extended_data[ch],
s->overlap_buffer->extended_data[ch] + s->hop_size * sizeof(float),

View File

@ -357,7 +357,7 @@ static int fn(fir_quantum)(AVFilterContext *ctx, AVFrame *out, int ch, int offse
j--;
}
seg->itx_fn(seg->itx[ch], sumout, sumin, sizeof(ftype));
seg->itx_fn(seg->itx[ch], sumout, sumin, sizeof(ctype));
buf = (ftype *)seg->buffer->extended_data[ch];
fn(fir_fadd)(s, buf, sumout, seg->part_size);

View File

@ -239,7 +239,7 @@ static av_cold int config_output(AVFilterLink *outlink)
lininterp(s->complexf, s->freq, s->magnitude, s->phase, s->nb_freq, fft_size / 2);
s->tx_fn(s->tx_ctx, s->complexf + fft_size, s->complexf, sizeof(float));
s->tx_fn(s->tx_ctx, s->complexf + fft_size, s->complexf, sizeof(*s->complexf));
compensation = 2.f / fft_size;
middle = s->nb_taps / 2;

View File

@ -261,7 +261,7 @@ static int fir_to_phase(SincContext *s, float **h, int *len, int *post_len, floa
work[i + 1] = 0;
}
s->itx_fn(s->itx, work, work, sizeof(float));
s->itx_fn(s->itx, work, work, sizeof(AVComplexFloat));
for (i = 0; i < work_len; i++)
work[i] *= 2.f / work_len;
@ -284,7 +284,7 @@ static int fir_to_phase(SincContext *s, float **h, int *len, int *post_len, floa
work[i + 1] = x * sinf(work[i + 1]);
}
s->itx_fn(s->itx, work, work, sizeof(float));
s->itx_fn(s->itx, work, work, sizeof(AVComplexFloat));
for (i = 0; i < work_len; i++)
work[i] *= 2.f / work_len;

View File

@ -1148,7 +1148,7 @@ static int plot_cqt(AVFilterContext *ctx, AVFrame **frameout)
}
}
s->tx_fn(s->fft_ctx, s->fft_result, s->fft_input, sizeof(float));
s->tx_fn(s->fft_ctx, s->fft_result, s->fft_input, sizeof(AVComplexFloat));
s->fft_result[s->fft_len] = s->fft_result[0];
UPDATE_TIME(s->fft_time);
@ -1356,7 +1356,7 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = ctx->inputs[0];
ShowCQTContext *s = ctx->priv;
float scale;
float scale = 1.f;
int ret;
common_uninit(s);

View File

@ -151,7 +151,7 @@ static int config_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
AVFilterLink *inlink = ctx->inputs[0];
ShowFreqsContext *s = ctx->priv;
float overlap, scale;
float overlap, scale = 1.f;
int i, ret;
s->old_pts = AV_NOPTS_VALUE;
@ -403,7 +403,7 @@ static int plot_freqs(AVFilterLink *inlink, int64_t pts)
if (s->bypass[ch])
continue;
s->tx_fn(s->fft, s->fft_data[ch], s->fft_input[ch], sizeof(float));
s->tx_fn(s->fft, s->fft_data[ch], s->fft_input[ch], sizeof(AVComplexFloat));
}
s->pts = av_rescale_q(pts, inlink->time_base, outlink->time_base);

View File

@ -121,7 +121,7 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
s->fft_tdata[ch][n].im = 0.f;
}
s->tx_fn[ch](s->fft[ch], s->fft_data[ch], s->fft_tdata[ch], sizeof(float));
s->tx_fn[ch](s->fft[ch], s->fft_data[ch], s->fft_tdata[ch], sizeof(AVComplexFloat));
return 0;
}

View File

@ -454,10 +454,10 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
}
memcpy(f, h, s->buf_size * sizeof(*f));
s->tx_fn(s->fft[ch], h, f, sizeof(float));
s->tx_fn(s->fft[ch], h, f, sizeof(AVComplexFloat));
memcpy(f, g, s->buf_size * sizeof(*f));
s->tx_fn(s->fft[ch], g, f, sizeof(float));
s->tx_fn(s->fft[ch], g, f, sizeof(AVComplexFloat));
for (int n = 0; n < L; n++) {
c = g[n].re;
@ -488,7 +488,7 @@ static int run_channel_fft(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
}
/* run FFT on each samples set */
s->tx_fn(s->fft[ch], s->fft_data[ch], s->fft_in[ch], sizeof(float));
s->tx_fn(s->fft[ch], s->fft_data[ch], s->fft_in[ch], sizeof(AVComplexFloat));
}
return 0;

View File

@ -342,7 +342,7 @@ static void synth_window(AVFilterContext *ctx, int x)
s->fft_in[ch][y].im = -s->fft_in[ch][f].im;
}
s->tx_fn(s->fft, s->fft_out[ch], s->fft_in[ch], sizeof(float));
s->tx_fn(s->fft, s->fft_out[ch], s->fft_in[ch], sizeof(AVComplexFloat));
}
}

View File

@ -196,7 +196,7 @@ static int fft_horizontal(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
int y;
for (y = start; y < end; y++) {
s->tx_fn[plane](s->fft[plane][jobnr], hdata_out + y * n, hdata_in + y * n, sizeof(float));
s->tx_fn[plane](s->fft[plane][jobnr], hdata_out + y * n, hdata_in + y * n, sizeof(AVComplexFloat));
}
return 0;
@ -388,7 +388,7 @@ static int fft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
vdata_in[y * n + x].im = hdata[x * n + y].im;
}
s->tx_fn[plane](s->fft[plane][jobnr], vdata_out + y * n, vdata_in + y * n, sizeof(float));
s->tx_fn[plane](s->fft[plane][jobnr], vdata_out + y * n, vdata_in + y * n, sizeof(AVComplexFloat));
}
return 0;
@ -408,7 +408,7 @@ static int ifft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs
int y, x;
for (y = start; y < end; y++) {
s->itx_fn[plane](s->ifft[plane][jobnr], vdata_out + y * n, vdata_in + y * n, sizeof(float));
s->itx_fn[plane](s->ifft[plane][jobnr], vdata_out + y * n, vdata_in + y * n, sizeof(AVComplexFloat));
for (x = 0; x < n; x++) {
hdata[x * n + y].re = vdata_out[y * n + x].re;
@ -432,7 +432,7 @@ static int ifft_horizontal(AVFilterContext *ctx, void *arg, int jobnr, int nb_jo
int y;
for (y = start; y < end; y++) {
s->itx_fn[plane](s->ifft[plane][jobnr], hdata_out + y * n, hdata_in + y * n, sizeof(float));
s->itx_fn[plane](s->ifft[plane][jobnr], hdata_out + y * n, hdata_in + y * n, sizeof(AVComplexFloat));
}
return 0;
@ -778,7 +778,7 @@ static int config_output(AVFilterLink *outlink)
for (i = 0; i < s->nb_planes; i++) {
for (j = 0; j < MAX_THREADS; j++) {
float scale;
float scale = 1.f;
ret = av_tx_init(&s->fft[i][j], &s->tx_fn[i], AV_TX_FLOAT_FFT, 0, s->fft_len[i], &scale, 0);
if (ret < 0)

View File

@ -305,7 +305,7 @@ static void import_block(FFTdnoizContext *s,
dst[j].re = dst[rw - 1].re;
dst[j].im = 0.f;
}
s->tx_fn(s->fft[jobnr], dst_out, dst, sizeof(float));
s->tx_fn(s->fft[jobnr], dst_out, dst, sizeof(AVComplexFloat));
ddst = dst_out;
dst += data_linesize;
@ -327,7 +327,7 @@ static void import_block(FFTdnoizContext *s,
for (int i = 0; i < block; i++) {
for (int j = 0; j < block; j++)
dst[j] = ssrc[j * data_linesize + i];
s->tx_fn(s->fft[jobnr], bdst, dst, sizeof(float));
s->tx_fn(s->fft[jobnr], bdst, dst, sizeof(AVComplexFloat));
dst += data_linesize;
bdst += buffer_linesize;
@ -361,7 +361,7 @@ static void export_block(FFTdnoizContext *s,
buffer_linesize /= sizeof(float);
for (int i = 0; i < block; i++) {
s->itx_fn(s->ifft[jobnr], vdst, bsrc, sizeof(float));
s->itx_fn(s->ifft[jobnr], vdst, bsrc, sizeof(AVComplexFloat));
for (int j = 0; j < block; j++)
hdst[j * data_linesize + i] = vdst[j];
@ -373,7 +373,7 @@ static void export_block(FFTdnoizContext *s,
for (int i = 0; i < rh && (y * size + i) < height; i++) {
uint8_t *dst = dstp + dst_linesize * (y * size + i) + x * size * bpp;
s->itx_fn(s->ifft[jobnr], hdst_out, hdst, sizeof(float));
s->itx_fn(s->ifft[jobnr], hdst_out, hdst, sizeof(AVComplexFloat));
s->export_row(hdst_out + hoverlap, dst, rw, depth, s->win[i + hoverlap] + hoverlap);
hdst += data_linesize;
@ -410,7 +410,7 @@ static void filter_block3d2(FFTdnoizContext *s, int plane, float *pbuffer, float
buffer[2].re = nbuff[2 * j ];
buffer[2].im = nbuff[2 * j + 1];
s->tx_r_fn(s->fft_r[jobnr], outbuffer, buffer, sizeof(float));
s->tx_r_fn(s->fft_r[jobnr], outbuffer, buffer, sizeof(AVComplexFloat));
for (int z = 0; z < 3; z++) {
const float re = outbuffer[z].re;
@ -431,7 +431,7 @@ static void filter_block3d2(FFTdnoizContext *s, int plane, float *pbuffer, float
outbuffer[z].im *= factor;
}
s->itx_r_fn(s->ifft_r[jobnr], buffer, outbuffer, sizeof(float));
s->itx_r_fn(s->ifft_r[jobnr], buffer, outbuffer, sizeof(AVComplexFloat));
cbuff[2 * j + 0] = buffer[1].re;
cbuff[2 * j + 1] = buffer[1].im;
@ -468,7 +468,7 @@ static void filter_block3d1(FFTdnoizContext *s, int plane, float *pbuffer,
buffer[1].re = cbuff[2 * j ];
buffer[1].im = cbuff[2 * j + 1];
s->tx_r_fn(s->fft_r[jobnr], outbuffer, buffer, sizeof(float));
s->tx_r_fn(s->fft_r[jobnr], outbuffer, buffer, sizeof(AVComplexFloat));
for (int z = 0; z < 2; z++) {
const float re = outbuffer[z].re;
@ -489,7 +489,7 @@ static void filter_block3d1(FFTdnoizContext *s, int plane, float *pbuffer,
outbuffer[z].im *= factor;
}
s->itx_r_fn(s->ifft_r[jobnr], buffer, outbuffer, sizeof(float));
s->itx_r_fn(s->ifft_r[jobnr], buffer, outbuffer, sizeof(AVComplexFloat));
cbuff[2 * j + 0] = buffer[1].re;
cbuff[2 * j + 1] = buffer[1].im;

View File

@ -201,7 +201,7 @@ static int irdft_horizontal8(AVFilterContext *ctx, void *arg, int jobnr, int nb_
s->ihtx_fn(s->ihrdft[jobnr][plane],
s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane],
s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane],
sizeof(float));
sizeof(AVComplexFloat));
for (int i = slice_start; i < slice_end; i++) {
const float scale = 1.f / (s->rdft_hlen[plane] * s->rdft_vlen[plane]);
@ -232,7 +232,7 @@ static int irdft_horizontal16(AVFilterContext *ctx, void *arg, int jobnr, int nb
s->ihtx_fn(s->ihrdft[jobnr][plane],
s->rdft_hdata_out[plane] + i * s->rdft_hstride[plane],
s->rdft_hdata_in[plane] + i * s->rdft_hstride[plane],
sizeof(float));
sizeof(AVComplexFloat));
for (int i = slice_start; i < slice_end; i++) {
const float scale = 1.f / (s->rdft_hlen[plane] * s->rdft_vlen[plane]);
@ -468,7 +468,7 @@ static int irdft_vertical(AVFilterContext *ctx, void *arg, int jobnr, int nb_job
s->ivtx_fn(s->ivrdft[jobnr][plane],
s->rdft_vdata_in[plane] + i * s->rdft_vstride[plane],
s->rdft_vdata_out[plane] + i * s->rdft_vstride[plane],
sizeof(float));
sizeof(AVComplexFloat));
}
return 0;