From patchwork Fri Dec 21 10:09:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liu Steven X-Patchwork-Id: 11511 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 0646944102C for ; Fri, 21 Dec 2018 12:10:04 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2AC7268A923; Fri, 21 Dec 2018 12:10:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from smtpbg202.qq.com (smtpbg202.qq.com [184.105.206.29]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3F13268A90C for ; Fri, 21 Dec 2018 12:09:56 +0200 (EET) X-QQ-mid: bizesmtp9t1545386993tseqnal1u Received: from localhost (unknown [106.2.229.242]) by esmtp4.qq.com (ESMTP) with id ; Fri, 21 Dec 2018 18:09:53 +0800 (CST) X-QQ-SSF: 01100000002000F0FNF0B00A0000000 X-QQ-FEAT: buVMrsJXDDjQYmFvHLY4yIKU4zeGhtkmRV0W+jyd06xjhvCMw7vLTNn0ZX4Vh +BByWiP+HCn4HAN9X3bnRu0AGHlzmN3Jn9XUvZii7J2U2q29WOFINWFEQcEX4fmt/ELEGn/ +uOwT/hyzhuvQtrTuBygd5r1Qgl6xA/spWAnHpNma+44emItYWXaf6wmVUHL5kwmELvLlhN o7bBA68/BYHleoU8Gnixf3th/8e3t2mb0X6DZf500pQUV11hXrlHGHvcZc6QpiqVsQq9B4K 3T4L4UpByk2mZkL1K2b61ozQrgS4KvU4mMLBGtshRw8A3U X-QQ-GoodBg: 0 From: Steven Liu To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 Dec 2018 18:09:50 +0800 Message-Id: <20181221100950.62785-1-lq@chinaffmpeg.org> X-Mailer: git-send-email 2.15.2 (Apple Git-101.1) In-Reply-To: <20181217232452.GH3501@michaelspb> References: <20181217232452.GH3501@michaelspb> X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:chinaffmpeg.org:qybgforeign:qybgforeign4 X-QQ-Bgrelay: 1 Subject: [FFmpeg-devel] [PATCH v2] avcodec/fft_template: libavcodec/fft_template: improve performance of the ff_fft_init in fft_template X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Steven Liu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --- 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; ifft_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; ifft_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->revtab##num[k] = j;\ + }\ +} while(0); + if (s->revtab) + SPLIT_RADIX_PERMUTATION() + if (s->revtab32) + SPLIT_RADIX_PERMUTATION(32) +#undef SPLIT_RADIX_PERMUTATION } return 0;