From patchwork Wed Jan 6 23:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24812 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 20DEC44A498 for ; Thu, 7 Jan 2021 01:13:34 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D6596689F89; Thu, 7 Jan 2021 01:13:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7B1E6687FD3 for ; Thu, 7 Jan 2021 01:13:26 +0200 (EET) Received: by mail-ed1-f49.google.com with SMTP id i24so5917562edj.8 for ; Wed, 06 Jan 2021 15:13:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:reply-to:mime-version :content-transfer-encoding; bh=DWcTKYgERCDWpLgw2a2SISiyybGAh9RxmSglPGaZeG4=; b=pcmRB+cXE8NU2uaThqL9TW8Z+XssOtWBiRiSP0L4toqVbdJgiuT9NNxaN38/GWf4MO +wKuYDCjMHRZu+6LHjVhjTcinRjDf5Zy/ADQWFFYhy9L5LgkGjfhBY1EtmtFz8koPXqe tjvPEMKjd/JXp2fJdMoL9QCTZsJ78Qg+L5RnuqRTvLmmz7y98ehYDuLcYgbJjSPQog5t h51OdCOLpVSnKtABoxS6kecoEtzkcsZ5luHRqZUaCm/K3KmDQOmk2rDZL9cm56E6WDjS rhQvg5eR+lzkyc2u7zTQFHFgOxV7904V8ku3SNdpJ6P/pFeKUlNOH3hfn+gkKlAklTZd EUqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :mime-version:content-transfer-encoding; bh=DWcTKYgERCDWpLgw2a2SISiyybGAh9RxmSglPGaZeG4=; b=YLU1qEgVwDxf9oSoWpDDqHDyQHlCkv1U796hei9l1H/5OvOEet1aoHlTknevvPkP6j h+1FvBeT/kvhpVuwn0TS6RZQe2uVokIbGKzq6uT0iX2UtcxNaqtlFjgQ6D8IAsW3HZNO ph4rSZvjgMQXPo5N2FGU4kaxGuGdoaNU/ZVPBY8bRPLAlYZNvAsv739mGqRc1BgUOxgF xPV9WrmDDGzWYYGO/sSzSBOGkJqZwnfIg0wb3JYnn77I1wvL3z9/f6xebfIMA9vkwKwE cG7l0ZqEtTDL+xMrHpRgPIk1wn1Qx2/cRYQNf1sTZCRTb0NdeTimoADwKWrnSvmEgwSE NQZA== X-Gm-Message-State: AOAM532kPKVx04we6ZmW6mqU0FHolhljqPy4v2i8tOKYR5k8qcfB9/xd PbJozIz7LZwd4TuOYo1lDerQZkiahng= X-Google-Smtp-Source: ABdhPJyQkspsxOuQfwnUkknqxQuVkLlnWuyULmoUmeb8L/lM7iVchuXOPL/RYA7fa7Zu8LxOZSJ9Dw== X-Received: by 2002:a50:b742:: with SMTP id g60mr5398350ede.113.1609974805642; Wed, 06 Jan 2021 15:13:25 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id b7sm1794295ejz.4.2021.01.06.15.13.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 15:13:24 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jan 2021 00:13:04 +0100 Message-Id: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/tableprint: Don't include mem_internal.h 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" tableprint.h does not declare anything as aligned; it just prints DECLARE_ALIGNED. So it can be removed; in fact, it needs to be removed, because mem_internal.h includes config.h which leads to warnings when building with hardcoded tables enabled because of redefinitions of CONFIG_HARDCODED_TABLES. (Furthermore, config.h is only valid for the target, not the host, so HAVE_LOCAL_ALIGNED might even be wrong here.) Signed-off-by: Andreas Rheinhardt --- libavcodec/tableprint.h | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/tableprint.h b/libavcodec/tableprint.h index e57eeb6ca6..6f61c7124b 100644 --- a/libavcodec/tableprint.h +++ b/libavcodec/tableprint.h @@ -27,7 +27,6 @@ #include #include "libavutil/common.h" -#include "libavutil/mem_internal.h" #define WRITE_1D_FUNC_ARGV(type, linebrk, fmtstr, ...)\ void write_##type##_array(const type *data, int len)\ From patchwork Wed Jan 6 23:13:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24814 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 91F7C44A498 for ; Thu, 7 Jan 2021 01:13:55 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 76B3268A2CA; Thu, 7 Jan 2021 01:13:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3E3C268A18D for ; Thu, 7 Jan 2021 01:13:47 +0200 (EET) Received: by mail-ed1-f41.google.com with SMTP id g24so5916700edw.9 for ; Wed, 06 Jan 2021 15:13:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=4zzgHJdDT3mkc3mX+H1gAOZw28DQkKcVOShtm2nDqYo=; b=BQrN/9EiSUfmqvHebyakApssATAvsAVZnus+73WPo3upGVeiynhMq5eR2r++FD/mpm DL82I9IIIDvyyVpuj457wREGXUbyBwN7+YuJfIoj5Zke++9S0lrSwDQmNW6/CDhSxG/T cNkAFww4T4AfpK5qgRhqprvCB0YMDZ+zmz2Czg/wp7Os+8c9VHCAEWGEOfnWCjLEKLom KmdcuML6YN7MsLtzu/uKs5GTFrrvYxb6JENIcE8Wqs326HnmRlfx0+bl29zDwxfT/hKA YBy+mWLjwAqVri/t1Q1LUi7JbGTJp+fhd5VDg72tTpzK0v8gdyZPhrnbeE3uhaMp23BY F1Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=4zzgHJdDT3mkc3mX+H1gAOZw28DQkKcVOShtm2nDqYo=; b=MKLDcyhzY4dGBal52S50eOXmLxF9JiQeP2iPDD6S3NhLeyPgHf6xZSmDnApGscJTUH yljVXn6NduAqyp4qun0Y4AkUaFcmDeaB/iabdQ2Mrtu7lruVkbGKEGh4UrsMdXH5jw4K IF5H7hPhuvfNpkL4rFU2GxJavYttGUswTIVxYnQWaANVNicuHGthoDDjUaJf7b+zIAyy 7C1HXmde+0WKzooElTaX/LL+CsLQ/vbQtIc9UwCUzY6EQwWETKtG7wq6/QFh+Twg/lui jMaOzd4UthDTuT/GrC0r2VK/TlztDSWMUOlJtEOaC2gwBrCcOeZP3ckfWGpEmQhz3vCS mRqQ== X-Gm-Message-State: AOAM5339na1DV8No/tHNbUlBT7kiCw2dGekUSDGt8SVM5enwQHuOzyzE JXlc7/4smKa1t5gcQJigzfQCaJD0e7U= X-Google-Smtp-Source: ABdhPJzXlU6Gb2SxHhy/2ArjTbGL2c+er1oto9WzQsG6yUXkHTqrD80YAY7C+/KthGoRJScDGcoifw== X-Received: by 2002:a05:6402:171a:: with SMTP id y26mr5636430edu.371.1609974826352; Wed, 06 Jan 2021 15:13:46 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id b7sm1794295ejz.4.2021.01.06.15.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 15:13:45 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jan 2021 00:13:05 +0100 Message-Id: <20210106231308.2952217-2-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> References: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/fft_template: Remove unused fixed-point cosine tables 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" There are three types of FFTs: floating-point, 32-bit fixed-point and 16-bit fixed-point. The latter has exactly one user: The fixed-point AC-3-encoder; the cosine tables used by it use up to seven bits. The tables corresponding to eight to seventeen bits are unused, as are the FFT functions for these bits. Therefore this commit removes these tables and functions. This is especially beneficial when using hardcoded tables as they take up more than 255 KiB. But even without it one saves said unused functions as well as entries in corresponding tables (this also saves relocations). Signed-off-by: Andreas Rheinhardt --- Thee changes to ARM assembly are honstely untested. I hope someone can test them. Btw: It seems that the ARM assembly code wouldn't be able to deal with an FFT with more than 16 bits (no function for this has been defined), which only worked because no one ever used that many bits with the fixed-point FFT. libavcodec/arm/fft_fixed_neon.S | 18 ------------------ libavcodec/cos_tablegen.c | 4 ++-- libavcodec/fft.h | 4 +++- libavcodec/fft_fixed.c | 1 + libavcodec/fft_template.c | 31 +++++++++++++++++++++++-------- tests/fate/fft.mak | 8 ++++++-- 6 files changed, 35 insertions(+), 31 deletions(-) diff --git a/libavcodec/arm/fft_fixed_neon.S b/libavcodec/arm/fft_fixed_neon.S index 2651607544..c94da56f80 100644 --- a/libavcodec/arm/fft_fixed_neon.S +++ b/libavcodec/arm/fft_fixed_neon.S @@ -223,15 +223,6 @@ endfunc def_fft 32, 16, 8 def_fft 64, 32, 16 def_fft 128, 64, 32 - def_fft 256, 128, 64 - def_fft 512, 256, 128 - def_fft 1024, 512, 256 - def_fft 2048, 1024, 512 - def_fft 4096, 2048, 1024 - def_fft 8192, 4096, 2048 - def_fft 16384, 8192, 4096 - def_fft 32768, 16384, 8192 - def_fft 65536, 32768, 16384 function ff_fft_fixed_calc_neon, export=1 ldr r2, [r0] @@ -249,13 +240,4 @@ const fft_fixed_tab_neon, relocate=1 .word fft32_neon .word fft64_neon .word fft128_neon - .word fft256_neon - .word fft512_neon - .word fft1024_neon - .word fft2048_neon - .word fft4096_neon - .word fft8192_neon - .word fft16384_neon - .word fft32768_neon - .word fft65536_neon endconst diff --git a/libavcodec/cos_tablegen.c b/libavcodec/cos_tablegen.c index 7206aad5dd..5929c29e1a 100644 --- a/libavcodec/cos_tablegen.c +++ b/libavcodec/cos_tablegen.c @@ -26,7 +26,6 @@ #include "libavutil/mathematics.h" -#define BITS 17 #define FLOATFMT "%.18e" #define FIXEDFMT "%6d" @@ -56,12 +55,13 @@ int main(int argc, char *argv[]) int i, j; int do_sin = argc > 1 && !strcmp(argv[1], "sin"); int fixed = argc > 1 && strstr(argv[1], "fixed"); + int bits = fixed ? 7 : 17; double (*func)(double) = do_sin ? sin : cos; printf("/* This file was automatically generated. */\n"); printf("#define FFT_FLOAT %d\n", !fixed); printf("#include \"libavcodec/%s\"\n", do_sin ? "rdft.h" : "fft.h"); - for (i = 4; i <= BITS; i++) { + for (i = 4; i <= bits; i++) { int m = 1 << i; double freq = 2*M_PI/m; printf("%s(%i) = {\n ", do_sin ? "SINTABLE" : "COSTABLE", m); diff --git a/libavcodec/fft.h b/libavcodec/fft.h index 5f67b61f06..fedc0c5ef0 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -127,6 +127,7 @@ extern COSTABLE(16); extern COSTABLE(32); extern COSTABLE(64); extern COSTABLE(128); +#if FFT_FLOAT extern COSTABLE(256); extern COSTABLE(512); extern COSTABLE(1024); @@ -137,7 +138,8 @@ extern COSTABLE(16384); extern COSTABLE(32768); extern COSTABLE(65536); extern COSTABLE(131072); -extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[18]; +#endif /* FFT_FLOAT */ +extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[]; #define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs) diff --git a/libavcodec/fft_fixed.c b/libavcodec/fft_fixed.c index 3d3bd2fca6..52d225ee09 100644 --- a/libavcodec/fft_fixed.c +++ b/libavcodec/fft_fixed.c @@ -18,4 +18,5 @@ #define FFT_FLOAT 0 #define FFT_FIXED_32 0 +#define MAX_BITS 7 #include "fft_template.c" diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c index 8825e39f79..7a7d51a6b4 100644 --- a/libavcodec/fft_template.c +++ b/libavcodec/fft_template.c @@ -33,6 +33,10 @@ #include "fft.h" #include "fft-internal.h" +#ifndef MAX_BITS +#define MAX_BITS 17 +#endif + #if FFT_FIXED_32 #include "fft_table.h" #else /* FFT_FIXED_32 */ @@ -43,6 +47,7 @@ COSTABLE(16); COSTABLE(32); COSTABLE(64); COSTABLE(128); +#if FFT_FLOAT COSTABLE(256); COSTABLE(512); COSTABLE(1024); @@ -53,6 +58,7 @@ COSTABLE(16384); COSTABLE(32768); COSTABLE(65536); COSTABLE(131072); +#endif /* FFT_FLOAT */ static av_cold void init_ff_cos_tabs(int index) { @@ -81,6 +87,7 @@ INIT_FF_COS_TABS_FUNC(4, 16) INIT_FF_COS_TABS_FUNC(5, 32) INIT_FF_COS_TABS_FUNC(6, 64) INIT_FF_COS_TABS_FUNC(7, 128) +#if FFT_FLOAT INIT_FF_COS_TABS_FUNC(8, 256) INIT_FF_COS_TABS_FUNC(9, 512) INIT_FF_COS_TABS_FUNC(10, 1024) @@ -91,6 +98,7 @@ INIT_FF_COS_TABS_FUNC(14, 16384) INIT_FF_COS_TABS_FUNC(15, 32768) INIT_FF_COS_TABS_FUNC(16, 65536) INIT_FF_COS_TABS_FUNC(17, 131072) +#endif /* FFT_FLOAT */ static CosTabsInitOnce cos_tabs_init_once[] = { { NULL }, @@ -101,6 +109,7 @@ static CosTabsInitOnce cos_tabs_init_once[] = { { init_ff_cos_tabs_32, AV_ONCE_INIT }, { init_ff_cos_tabs_64, AV_ONCE_INIT }, { init_ff_cos_tabs_128, AV_ONCE_INIT }, +#if FFT_FLOAT { init_ff_cos_tabs_256, AV_ONCE_INIT }, { init_ff_cos_tabs_512, AV_ONCE_INIT }, { init_ff_cos_tabs_1024, AV_ONCE_INIT }, @@ -111,6 +120,7 @@ static CosTabsInitOnce cos_tabs_init_once[] = { { init_ff_cos_tabs_32768, AV_ONCE_INIT }, { init_ff_cos_tabs_65536, AV_ONCE_INIT }, { init_ff_cos_tabs_131072, AV_ONCE_INIT }, +#endif /* FFT_FLOAT */ }; #endif @@ -120,6 +130,7 @@ COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = { FFT_NAME(ff_cos_32), FFT_NAME(ff_cos_64), FFT_NAME(ff_cos_128), +#if FFT_FLOAT FFT_NAME(ff_cos_256), FFT_NAME(ff_cos_512), FFT_NAME(ff_cos_1024), @@ -130,6 +141,7 @@ COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = { FFT_NAME(ff_cos_32768), FFT_NAME(ff_cos_65536), FFT_NAME(ff_cos_131072), +#endif /* FFT_FLOAT */ }; #endif /* FFT_FIXED_32 */ @@ -200,7 +212,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) s->revtab = NULL; s->revtab32 = NULL; - if (nbits < 2 || nbits > 17) + if (nbits < 2 || nbits > MAX_BITS) goto fail; s->nbits = nbits; n = 1 << nbits; @@ -537,11 +549,6 @@ static void name(FFTComplex *z, const FFTSample *wre, unsigned int n)\ } PASS(pass) -#if !CONFIG_SMALL -#undef BUTTERFLIES -#define BUTTERFLIES BUTTERFLIES_BIG -PASS(pass_big) -#endif #define DECL_FFT(n,n2,n4)\ static void fft##n(FFTComplex *z)\ @@ -603,9 +610,13 @@ DECL_FFT(16,8,4) DECL_FFT(32,16,8) DECL_FFT(64,32,16) DECL_FFT(128,64,32) +#if FFT_FLOAT DECL_FFT(256,128,64) DECL_FFT(512,256,128) #if !CONFIG_SMALL +#undef BUTTERFLIES +#define BUTTERFLIES BUTTERFLIES_BIG +PASS(pass_big) #define pass pass_big #endif DECL_FFT(1024,512,256) @@ -616,10 +627,14 @@ DECL_FFT(16384,8192,4096) DECL_FFT(32768,16384,8192) DECL_FFT(65536,32768,16384) DECL_FFT(131072,65536,32768) +#endif /* FFT_FLOAT */ static void (* const fft_dispatch[])(FFTComplex*) = { - fft4, fft8, fft16, fft32, fft64, fft128, fft256, fft512, fft1024, - fft2048, fft4096, fft8192, fft16384, fft32768, fft65536, fft131072 + fft4, fft8, fft16, fft32, fft64, fft128, +#if FFT_FLOAT + fft256, fft512, fft1024, fft2048, fft4096, + fft8192, fft16384, fft32768, fft65536, fft131072 +#endif /* FFT_FLOAT */ }; static void fft_calc_c(FFTContext *s, FFTComplex *z) diff --git a/tests/fate/fft.mak b/tests/fate/fft.mak index 5da6e687ec..3eb8450d94 100644 --- a/tests/fate/fft.mak +++ b/tests/fate/fft.mak @@ -28,15 +28,19 @@ $(FATE_FFT_ALL): CMD = run libavcodec/tests/fft$(EXESUF) $(CPUFLAGS:%=-c%) $(ARG define DEF_FFT_FIXED FATE_FFT_FIXED-$(CONFIG_FFT) += fate-fft-fixed-$(1) fate-ifft-fixed-$(1) -FATE_MDCT_FIXED-$(CONFIG_MDCT) += fate-mdct-fixed-$(1) fate-imdct-fixed-$(1) fate-fft-fixed-$(1): ARGS = -n$(1) fate-ifft-fixed-$(1): ARGS = -n$(1) -i +endef +define DEF_MDCT_FIXED +FATE_MDCT_FIXED-$(CONFIG_MDCT) += fate-mdct-fixed-$(1) fate-imdct-fixed-$(1) + fate-mdct-fixed-$(1): ARGS = -n$(1) -m fate-imdct-fixed-$(1): ARGS = -n$(1) -m -i endef -$(foreach N, 4 5 6 7 8 9 10 11 12, $(eval $(call DEF_FFT_FIXED,$(N)))) +$(foreach N, 4 5 6 7, $(eval $(call DEF_FFT_FIXED,$(N)))) +$(foreach N, 4 5 6 7 8 9, $(eval $(call DEF_MDCT_FIXED,$(N)))) fate-fft-fixed: $(FATE_FFT_FIXED-yes) fate-mdct-fixed: $(FATE_MDCT_FIXED-yes) From patchwork Wed Jan 6 23:13:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24815 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 751DD44A498 for ; Thu, 7 Jan 2021 01:13:56 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6022968A606; Thu, 7 Jan 2021 01:13:56 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1AAFE68A295 for ; Thu, 7 Jan 2021 01:13:48 +0200 (EET) Received: by mail-ej1-f44.google.com with SMTP id x16so7273205ejj.7 for ; Wed, 06 Jan 2021 15:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=T0jDfEhquxZV1ezYY0QJ2Mj679zJS96Pi7TlYA6qXWQ=; b=W2rC8hfsp9X4cuCE6EJ1zoyMmFWg612RK9BvMyZbGI1q/HCqKefJdKgPQ75c6JH4W7 gi6IGpm88AWqRbi0hp+jn7vztoYjtrWfqf76wkoLfE0cyri+n5YsfvX1nEWn46BXEU5g HKRKCN7hEC4aS6y79GSdQfQk1WME23FZSzbBU3+2cnUjSr/qL1K7H+bmzb1p8+2tVnvx Bqk9Gd3luze72leDiNUSZnIVnFKiyhSt/cLxNxn3byJexQdHoFab/yP8h9BmtRQPX06h 2mwHG9YaHqqWJtFJorYYdgrbkGk1kq2m8UGq+zePEDHlx5igNuAZYzC3TV5AcDTtVNs4 8BkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=T0jDfEhquxZV1ezYY0QJ2Mj679zJS96Pi7TlYA6qXWQ=; b=o+t7oVUtQmTKtnft/CGJbU2rHlq9HDtPTXM0GzORTXsShry2AqMLiijkq4iC+U2uK4 qxxjRDgx5/xflOwK/rXCKYvEwAktOZM2hpABtKZB9B9fa8SpCER0jbUbnvp0Cxb81WGR zcmj+MCAIvnRFlsAD8v8QBWfbgpQzRuq4Ru5fiPdMbiHd798q9DYPwweFCdQyO0B/6Nt bucMtW/rjkfngQ4o9/i45vZT5JddwG5Rpb81leUysPmPUAtk2uO/KvAkmkZ0j+l4gqDF QcKZM/w9J+X9k3RRyLD4vmFrhfSuxBWWv5gfxfSXYChmclzi8aWHEkUz53bsoSRrsF/r xSyg== X-Gm-Message-State: AOAM531l22ouKkxkhhY6P6ZedjokuCmHe0AzPArlaK3FyLI9+Cyd7I3P DdQw64yx49k1rTgZC7NOIMtLBtgX7Gk= X-Google-Smtp-Source: ABdhPJxCA/l7vADDp6LfH8/Rvhk3NoF8q0jgedni3uJZhWAyxK5ycRRDygE8y3jnfiIBziJT9QEggw== X-Received: by 2002:a17:906:3b55:: with SMTP id h21mr4484936ejf.184.1609974827276; Wed, 06 Jan 2021 15:13:47 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id b7sm1794295ejz.4.2021.01.06.15.13.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 15:13:46 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jan 2021 00:13:06 +0100 Message-Id: <20210106231308.2952217-3-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> References: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/fft_fixed: Hardcode cosine tables to save space 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The tables that are used take 256B; the code to initialize them uses 281B here (GCC 9.3, x64, -O3, but in av_cold functions). On top of that, removing this code also allows to remove the array of AVOnce used to guard the cosine tables against multiple initializations; this also removes relocations. Signed-off-by: Andreas Rheinhardt --- libavcodec/Makefile | 2 +- libavcodec/fft.h | 19 +++++++++--------- libavcodec/fft_fixed.c | 42 +++++++++++++++++++++++++++++++++++++++ libavcodec/fft_template.c | 27 +++++++++---------------- 4 files changed, 62 insertions(+), 28 deletions(-) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index fea37ef3c9..8e03feb7d1 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -83,7 +83,7 @@ OBJS-$(CONFIG_EXIF) += exif.o tiff_common.o OBJS-$(CONFIG_FAANDCT) += faandct.o OBJS-$(CONFIG_FAANIDCT) += faanidct.o OBJS-$(CONFIG_FDCTDSP) += fdctdsp.o jfdctfst.o jfdctint.o -FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o cos_fixed_tables.o +FFT-OBJS-$(CONFIG_HARDCODED_TABLES) += cos_tables.o OBJS-$(CONFIG_FFT) += avfft.o fft_fixed.o fft_float.o \ fft_fixed_32.o fft_init_table.o \ $(FFT-OBJS-yes) diff --git a/libavcodec/fft.h b/libavcodec/fft.h index fedc0c5ef0..4b54265b7f 100644 --- a/libavcodec/fft.h +++ b/libavcodec/fft.h @@ -114,10 +114,18 @@ struct FFTContext { uint32_t *revtab32; }; -#if CONFIG_HARDCODED_TABLES +#if CONFIG_HARDCODED_TABLES || !FFT_FLOAT #define COSTABLE_CONST const +#define ff_init_ff_cos_tabs(...) #else #define COSTABLE_CONST +#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs) + +/** + * Initialize the cosine table in ff_cos_tabs[index] + * @param index index in ff_cos_tabs array of the table to initialize + */ +void ff_init_ff_cos_tabs(int index); #endif #define COSTABLE(size) \ @@ -138,16 +146,9 @@ extern COSTABLE(16384); extern COSTABLE(32768); extern COSTABLE(65536); extern COSTABLE(131072); -#endif /* FFT_FLOAT */ extern COSTABLE_CONST FFTSample* const FFT_NAME(ff_cos_tabs)[]; -#define ff_init_ff_cos_tabs FFT_NAME(ff_init_ff_cos_tabs) - -/** - * Initialize the cosine table in ff_cos_tabs[index] - * @param index index in ff_cos_tabs array of the table to initialize - */ -void ff_init_ff_cos_tabs(int index); +#endif /* FFT_FLOAT */ #define ff_fft_init FFT_NAME(ff_fft_init) #define ff_fft_end FFT_NAME(ff_fft_end) diff --git a/libavcodec/fft_fixed.c b/libavcodec/fft_fixed.c index 52d225ee09..ce52dec7fd 100644 --- a/libavcodec/fft_fixed.c +++ b/libavcodec/fft_fixed.c @@ -19,4 +19,46 @@ #define FFT_FLOAT 0 #define FFT_FIXED_32 0 #define MAX_BITS 7 + +#include "fft.h" + +COSTABLE(16) = { + 32767, 30274, 23170, 12540, + 0, 12540, 23170, 30274, +}; +COSTABLE(32) = { + 32767, 32138, 30274, 27246, + 23170, 18205, 12540, 6393, + 0, 6393, 12540, 18205, + 23170, 27246, 30274, 32138, +}; +COSTABLE(64) = { + 32767, 32610, 32138, 31357, + 30274, 28899, 27246, 25330, + 23170, 20788, 18205, 15447, + 12540, 9512, 6393, 3212, + 0, 3212, 6393, 9512, + 12540, 15447, 18205, 20788, + 23170, 25330, 27246, 28899, + 30274, 31357, 32138, 32610, +}; +COSTABLE(128) = { + 32767, 32729, 32610, 32413, + 32138, 31786, 31357, 30853, + 30274, 29622, 28899, 28106, + 27246, 26320, 25330, 24279, + 23170, 22006, 20788, 19520, + 18205, 16846, 15447, 14010, + 12540, 11039, 9512, 7962, + 6393, 4808, 3212, 1608, + 0, 1608, 3212, 4808, + 6393, 7962, 9512, 11039, + 12540, 14010, 15447, 16846, + 18205, 19520, 20788, 22006, + 23170, 24279, 25330, 26320, + 27246, 28106, 28899, 29622, + 30274, 30853, 31357, 31786, + 32138, 32413, 32610, 32729, +}; + #include "fft_template.c" diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c index 7a7d51a6b4..9d125de073 100644 --- a/libavcodec/fft_template.c +++ b/libavcodec/fft_template.c @@ -42,12 +42,12 @@ #else /* FFT_FIXED_32 */ /* cos(2*pi*x/n) for 0<=x<=n/4, followed by its reverse */ +#if FFT_FLOAT #if !CONFIG_HARDCODED_TABLES COSTABLE(16); COSTABLE(32); COSTABLE(64); COSTABLE(128); -#if FFT_FLOAT COSTABLE(256); COSTABLE(512); COSTABLE(1024); @@ -58,7 +58,6 @@ COSTABLE(16384); COSTABLE(32768); COSTABLE(65536); COSTABLE(131072); -#endif /* FFT_FLOAT */ static av_cold void init_ff_cos_tabs(int index) { @@ -87,7 +86,6 @@ INIT_FF_COS_TABS_FUNC(4, 16) INIT_FF_COS_TABS_FUNC(5, 32) INIT_FF_COS_TABS_FUNC(6, 64) INIT_FF_COS_TABS_FUNC(7, 128) -#if FFT_FLOAT INIT_FF_COS_TABS_FUNC(8, 256) INIT_FF_COS_TABS_FUNC(9, 512) INIT_FF_COS_TABS_FUNC(10, 1024) @@ -98,7 +96,6 @@ INIT_FF_COS_TABS_FUNC(14, 16384) INIT_FF_COS_TABS_FUNC(15, 32768) INIT_FF_COS_TABS_FUNC(16, 65536) INIT_FF_COS_TABS_FUNC(17, 131072) -#endif /* FFT_FLOAT */ static CosTabsInitOnce cos_tabs_init_once[] = { { NULL }, @@ -109,7 +106,6 @@ static CosTabsInitOnce cos_tabs_init_once[] = { { init_ff_cos_tabs_32, AV_ONCE_INIT }, { init_ff_cos_tabs_64, AV_ONCE_INIT }, { init_ff_cos_tabs_128, AV_ONCE_INIT }, -#if FFT_FLOAT { init_ff_cos_tabs_256, AV_ONCE_INIT }, { init_ff_cos_tabs_512, AV_ONCE_INIT }, { init_ff_cos_tabs_1024, AV_ONCE_INIT }, @@ -120,17 +116,20 @@ static CosTabsInitOnce cos_tabs_init_once[] = { { init_ff_cos_tabs_32768, AV_ONCE_INIT }, { init_ff_cos_tabs_65536, AV_ONCE_INIT }, { init_ff_cos_tabs_131072, AV_ONCE_INIT }, -#endif /* FFT_FLOAT */ }; +av_cold void ff_init_ff_cos_tabs(int index) +{ + ff_thread_once(&cos_tabs_init_once[index].control, cos_tabs_init_once[index].func); +} #endif + COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = { NULL, NULL, NULL, NULL, FFT_NAME(ff_cos_16), FFT_NAME(ff_cos_32), FFT_NAME(ff_cos_64), FFT_NAME(ff_cos_128), -#if FFT_FLOAT FFT_NAME(ff_cos_256), FFT_NAME(ff_cos_512), FFT_NAME(ff_cos_1024), @@ -141,8 +140,8 @@ COSTABLE_CONST FFTSample * const FFT_NAME(ff_cos_tabs)[] = { FFT_NAME(ff_cos_32768), FFT_NAME(ff_cos_65536), FFT_NAME(ff_cos_131072), -#endif /* FFT_FLOAT */ }; +#endif /* FFT_FLOAT */ #endif /* FFT_FIXED_32 */ @@ -160,13 +159,6 @@ static int split_radix_permutation(int i, int n, int inverse) else return split_radix_permutation(i, m, inverse)*4 - 1; } -av_cold void ff_init_ff_cos_tabs(int index) -{ -#if (!CONFIG_HARDCODED_TABLES) && (!FFT_FIXED_32) - ff_thread_once(&cos_tabs_init_once[index].control, cos_tabs_init_once[index].func); -#endif -} - static const int avx_tab[] = { 0, 4, 1, 5, 8, 12, 9, 13, 2, 6, 3, 7, 10, 14, 11, 15 }; @@ -250,13 +242,12 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) if (ARCH_X86) ff_fft_init_x86(s); if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc; if (HAVE_MIPSFPU) ff_fft_init_mips(s); + for (j = 4; !CONFIG_HARDCODED_TABLES && j <= nbits; j++) + ff_init_ff_cos_tabs(j); #else if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c; if (ARCH_ARM) ff_fft_fixed_init_arm(s); #endif - for(j=4; j<=nbits; j++) { - ff_init_ff_cos_tabs(j); - } #endif /* FFT_FIXED_32 */ From patchwork Wed Jan 6 23:13:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24816 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 3F40144A498 for ; Thu, 7 Jan 2021 01:13:57 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2986668A2C6; Thu, 7 Jan 2021 01:13:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CABFB689EA2 for ; Thu, 7 Jan 2021 01:13:48 +0200 (EET) Received: by mail-ej1-f52.google.com with SMTP id x16so7273241ejj.7 for ; Wed, 06 Jan 2021 15:13:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=qbCBsqg86n1F3NSU0akkaNaWfGc3BrQ7fVR3Y46BQqY=; b=UXVTQaPlQjQMtKi9bw/JMlaWmdf518jfLH5F+c10mVy+GtawAbJC8U3DwmanWWOKiy cJWLkPrSBh3EoB9Dr6t/PPnwHJrrRr+JItiZK9Fjb8B69YsivpM8QeSJBJ0O0E928+p3 GdPHZjwAx1ACyrIGtnsbqo++e1wPlULjVTmqPgDqcSqWepNi/Bh+58OpKXm00nG3yTsU fD0xLfipKCmn1B91QR1ohOVEovoKyZLJH9ywigYd6x7nElZwIlKocsON/1fr3/va7Pnj 9yPnVoEws+1bHKHhQ+D+ITtI6BUws0WVCdhElTcKrUjp6xXh1mTABbGEQN+oXWuOIrex AHzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=qbCBsqg86n1F3NSU0akkaNaWfGc3BrQ7fVR3Y46BQqY=; b=DLsDNFCyRGjNbjRPdPoYaux+MhrQ/iqUAeSYrTRivm3sEckNBrhwy793sB2nA1yuSZ NE2WUpdVs2kNpHjZu+PzE9vAoZpcZBv9VKH5zOLoubJZnM93AelwAnKBaZnhBFBtJELS S43Jlt3imUEORNzS6OTOcQYb87iv4+xrYBx3mk4WylJeoipC5GNfnFpEgHDkPvMEDWTg S+KoKMC4Lx4u8Y8RZpZwJ/gMYSGEq1vEzBPRDOj0Q3XgGNONsWdRWqXZ5AHxfa7khf+q WKILPX/I8dut7QeuoCsj77uA+8pXoE6WJxlwu9tsSRFzNc8ca56UVICksRaz6n8wKjiW do1Q== X-Gm-Message-State: AOAM532V5B9wbpMGX0dUSvMTiEhOyt751mlsDbS3r8ihGY4q01H5Q+Hj fkeETPEToeCmCQC/XsD6KuQYHCUwyV0= X-Google-Smtp-Source: ABdhPJxZ5LwE8EoIa+8tl6Cao8qy4EfZMlbvwunCnNUYy8xuhdhch2ofPmkgbM9ZsTQFaSTwYKaTfQ== X-Received: by 2002:a17:906:386:: with SMTP id b6mr4232772eja.554.1609974828150; Wed, 06 Jan 2021 15:13:48 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id b7sm1794295ejz.4.2021.01.06.15.13.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 15:13:47 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jan 2021 00:13:07 +0100 Message-Id: <20210106231308.2952217-4-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> References: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avcodec/fft_template: Only check for FF_FFT_PERM_AVX on ARCH_X86 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Also do it for FFT_FLOAT only, as this is the only combination for which it can be set. Signed-off-by: Andreas Rheinhardt --- libavcodec/fft_template.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c index 9d125de073..ddde63714e 100644 --- a/libavcodec/fft_template.c +++ b/libavcodec/fft_template.c @@ -251,7 +251,7 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) #endif /* FFT_FIXED_32 */ - if (s->fft_permutation == FF_FFT_PERM_AVX) { + if (ARCH_X86 && FFT_FLOAT && s->fft_permutation == FF_FFT_PERM_AVX) { fft_perm_avx(s); } else { #define PROCESS_FFT_PERM_SWAP_LSBS(num) do {\ From patchwork Wed Jan 6 23:13:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 24813 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 304B044A498 for ; Thu, 7 Jan 2021 01:13:52 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 15510689FED; Thu, 7 Jan 2021 01:13:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 22083689EA2 for ; Thu, 7 Jan 2021 01:13:49 +0200 (EET) Received: by mail-ej1-f51.google.com with SMTP id n26so7293572eju.6 for ; Wed, 06 Jan 2021 15:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=WkPuEgy9gbxarQncbcz2Xwaelgpk6Enae3axe9sD6B8=; b=Hp48A1AYwt3/myGaSP8Z/cdVenmzs7VGgJFAtoIrgK8xoN+zchNsjELShDtq8FAP9Q i91pG+vvUuTvMAu7QADVjVlOQT/S6CR+dJcraRGK9hk5V02PGpGyJ8TMh2X8wqKnXul8 G/LsbQDSQWcXqo6BRYd0/Z6JHxCb97WNR3McZq7Up9FT3MT9ghUjWg2Rhd08mutomH9/ 8RnynwL32X5hAC+YdAbj9pVq6HbcoRSM59NNKhImtAmBs9xN0YaCp3RU5qfJTP6aLOGY nhaLNqvOVCkJSi5BeyQXAfqwl58KNiiayIfd1PwO/RFEwZQ4ivpawzPojh0HDUhEfg7v MY7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=WkPuEgy9gbxarQncbcz2Xwaelgpk6Enae3axe9sD6B8=; b=EzvYyEBkmzDHIiE/PhlkCQP86x9Y5p/YS/W4N7TLjxnf3YqL1nja5Pr8q9xzCSNf4r t7s+azZqtb0INvadtK0nfPKV/Wdlxi0O9dmmWyDKMAC0Nsx9FUlI6xuK5tomboA8YwmH sZxtYv3OJtXdzYju5SWDYRoXEOw7QavCZsNIjPTx6xuW0XCh8HXMcz4U40sDJ9AL5QpB /hWIDKeyzVKPuR3ULr6FwAN14QcUAPiM2jH8+xgdwK1VCpnFgMH+v1Ly6uUPyWGr4zCT HnBgRJbN5AUF15bhWKIRk05c4nexOBTA04J3k4hnppxlOy5EjHhKTlOpk/mA6RZbDK40 jRVQ== X-Gm-Message-State: AOAM531570WStfWeh7ZoquTs5RBuwHaV5+A0hiWf8rJz+25c47Wk8oEa +WlxK6YvD50ieN0rNf7bf454U94QCYc= X-Google-Smtp-Source: ABdhPJyhT1zpWauGg24+GYFd5WHRJJ3tdMZzmHPDnVaSQPn+4dQ7DLRfIIhfnhuG7pVNIiecwvHiSg== X-Received: by 2002:a17:906:3fc4:: with SMTP id k4mr4269104ejj.137.1609974829221; Wed, 06 Jan 2021 15:13:49 -0800 (PST) Received: from sblaptop.fritz.box (ipbcc1aa4b.dynamic.kabel-deutschland.de. [188.193.170.75]) by smtp.gmail.com with ESMTPSA id b7sm1794295ejz.4.2021.01.06.15.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 15:13:48 -0800 (PST) From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 7 Jan 2021 00:13:08 +0100 Message-Id: <20210106231308.2952217-5-andreas.rheinhardt@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> References: <20210106231308.2952217-1-andreas.rheinhardt@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] avcodec/fft_template: Perform some checks at compile-time 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" The fixed point FFT never uses the 32bit revtab; this commit adds some compile-time checks to make sure that dead code doesn't get compiled in. Also, while just at it, fix the indentation in ff_fft_init() and make sure that a do {} while (0) macro does not already swallow the semicolon on its own. Signed-off-by: Andreas Rheinhardt --- libavcodec/fft_template.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/fft_template.c b/libavcodec/fft_template.c index ddde63714e..76bda09a07 100644 --- a/libavcodec/fft_template.c +++ b/libavcodec/fft_template.c @@ -279,12 +279,12 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse) } else {\ PROCESS_FFT_PERM_DEFAULT(num) \ }\ -} while(0); +} while (0) - if (s->revtab) - SPLIT_RADIX_PERMUTATION() - if (s->revtab32) - SPLIT_RADIX_PERMUTATION(32) + if (MAX_BITS <= 16 || s->revtab) + SPLIT_RADIX_PERMUTATION(); + else + SPLIT_RADIX_PERMUTATION(32); #undef PROCESS_FFT_PERM_DEFAULT #undef PROCESS_FFT_PERM_SWAP_LSBS @@ -306,7 +306,7 @@ static void fft_permute_c(FFTContext *s, FFTComplex *z) const uint32_t *revtab32 = s->revtab32; np = 1 << s->nbits; /* TODO: handle split-radix permute in a more optimal way, probably in-place */ - if (revtab) { + if (MAX_BITS <= 16 || revtab) { for(j=0;jtmp_buf[revtab[j]] = z[j]; } else for(j=0;jtmp_buf[revtab32[j]] = z[j];