[FFmpeg-devel] [PATCH 1/2] avcodec/fft_template: improve performance of the ff_fft_init in fft_template

Moritz Barsnick barsnick at gmx.net
Sun Dec 16 15:47:06 EET 2018


On Sun, Dec 16, 2018 at 21:19:17 +0800, Steven Liu wrote:
> move the two if condition out of the loop, that can less n-1 times than condition
> in loop.
[...]
>              k = -split_radix_permutation(i, n, s->inverse) & (n-1);
> -            if (s->revtab)
>                  s->revtab[k] = j;
> -            if (s->revtab32)
> -                s->revtab32[k] = j;
>          }

Does this really improve performance? You only save one if-check per
loop (as only one of s->revtab and s->revtab32 is defined). Benchmarks?

> +            if (s->revtab32) {
> +                for(i=0; i<n; i++) {
> +                    int k;
> +                    j = i;
> +                    if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS)
> +                        j = (j&~3) | ((j>>1)&1) | ((j<<1)&2);
> +                        k = -split_radix_permutation(i, n, s->inverse) & (n-1);
> +                s->revtab32[k] = j;
> +            }
> +            }

On the other hand, all the code is duplicated. Is there a more elegant
way to do this?

Moritz


More information about the ffmpeg-devel mailing list