[FFmpeg-devel] [PATCH] avfilter: add arnndn filter
Lynne
dev at lynne.ee
Sat Jul 27 16:54:48 EEST 2019
Jul 26, 2019, 4:37 PM by onemda at gmail.com <mailto:onemda at gmail.com>:
> +static void biquad(float *y, float mem[2], const float *x,
> + const float *b, const float *a, int N)
> +{
> + for (int i = 0; i < N; i++) {
> + float xi, yi;
> + xi = x[i];
> + yi = x[i] + mem[0];
> + mem[0] = mem[1] + (b[0]*(double)xi - a[0]*(double)yi);
> + mem[1] = (b[1]*(double)xi - a[1]*(double)yi);
> + y[i] = yi;
> + }
> +}
Do you really need double precision here?
> +static void apply_window(float *x, float *half_window)
> +{
> + for (int i = 0; i < FRAME_SIZE; i++) {
> + x[i] *= half_window[i];
> + x[WINDOW_SIZE - 1 - i] *= half_window[i];
> + }
> +}
Use vector_fmul_window.
> +#define FRAME_SIZE_SHIFT 2
> +#define FRAME_SIZE (120<<FRAME_SIZE_SHIFT)
> +#define WINDOW_SIZE (2*FRAME_SIZE)
> +#define FREQ_SIZE (FRAME_SIZE + 1)
>
> + AVComplexFloat y[WINDOW_SIZE];
>
> + st->tx_fn(st->tx, y, x, 0);
> +
> + for (int i = 0; i < FREQ_SIZE; i++) {
> + out[i] = y[i];
> + }
Make y and x aligned and set the tx stride to sizeof(float) for when SIMD is implemented.
I can't see how this could even work with stride = 0.
Why is FREQ_SIZE = FRAME_SIZE + 1?
> + st->tx_fn(st->tx, y, x, 0);
> +
> + /* output in reverse order for IFFT. */
> + out[0] = y[0].re / WINDOW_SIZE;
> + for (i=1; i < WINDOW_SIZE; i++) {
> + out[i] = y[WINDOW_SIZE - i].re / WINDOW_SIZE;
> + }
Make another tx context for an inverse transform, also same as above, and use float_dsp to divide all by WINDOW_SIZE.
> + for (int i=0;i<FRAME_SIZE;i++)
> + out[i] = x[i] + st->synthesis_mem[i]
float_dsp? If you can afford to overwrite and overread the arrays odd sizes will work.
> + for (int i = 0; i < FRAME_SIZE; i++)
> + s->half_window[i] = sin(.5*M_PI*sin(.5*M_PI*(i+.5)/FRAME_SIZE) * sin(.5*M_PI*(i+.5)/FRAME_SIZE));
Just copy ff_celt_window and use it.
Also fix coding style and upload a weights file somewhere.
More information about the ffmpeg-devel
mailing list