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

Michael Niedermayer michael at niedermayer.cc
Mon Dec 24 19:16:18 EET 2018


On Fri, Dec 21, 2018 at 06:09:50PM +0800, Steven Liu wrote:
> Before patch:
> init nbits = 17, get 10000 samples, average cost: 16105 us
> After patch:
> init nbits = 17, get 10000 samples, average cost: 15221 us
> 
> Signed-off-by: Steven Liu <lq at chinaffmpeg.org>
> ---
>  libavcodec/fft_template.c | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c
> index 762c014bc8..2b528be882 100644
> --- a/libavcodec/fft_template.c
> +++ b/libavcodec/fft_template.c
> @@ -261,17 +261,21 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
>      if (s->fft_permutation == FF_FFT_PERM_AVX) {
>          fft_perm_avx(s);
>      } else {
> -        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);
> -            if (s->revtab)
> -                s->revtab[k] = j;
> -            if (s->revtab32)
> -                s->revtab32[k] = j;
> -        }
> +#define SPLIT_RADIX_PERMUTATION(num) do { \
> +    for(i=0; i<n; i++) {\
> +        int k;\
> +        j = i;\

> +        if (s->fft_permutation == FF_FFT_PERM_SWAP_LSBS)\

maybe this if() should be factored out too ?

the change looks good though, and iam not sure this is speed relevant
enough

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Never trust a computer, one day, it may think you are the virus. -- Compn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20181224/85182b81/attachment.sig>


More information about the ffmpeg-devel mailing list