diff mbox series

[FFmpeg-devel,4/5] avutil/tx_template: Avoid code duplication

Message ID AS8P250MB0744B3A7C36BC043E7E56B388F2C9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 188216581bc73572bebacab571d7c0468680b8d1
Headers show
Series [FFmpeg-devel,1/5] avformat/argo_cvg: Mark overrides as const | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Oct. 22, 2022, 1:59 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavutil/tx_template.c | 76 +++++++++++++++--------------------------
 1 file changed, 27 insertions(+), 49 deletions(-)
diff mbox series

Patch

diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index b44a6189cc..c15dc2ea27 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -27,25 +27,28 @@ 
 #define TABLE_DEF(name, size) \
     DECLARE_ALIGNED(32, TXSample, TX_TAB(ff_tx_tab_ ##name))[size]
 
-#define SR_TABLE(len) \
-    TABLE_DEF(len, len/4 + 1)
+#define SR_POW2_TABLES \
+    SR_TABLE(8)        \
+    SR_TABLE(16)       \
+    SR_TABLE(32)       \
+    SR_TABLE(64)       \
+    SR_TABLE(128)      \
+    SR_TABLE(256)      \
+    SR_TABLE(512)      \
+    SR_TABLE(1024)     \
+    SR_TABLE(2048)     \
+    SR_TABLE(4096)     \
+    SR_TABLE(8192)     \
+    SR_TABLE(16384)    \
+    SR_TABLE(32768)    \
+    SR_TABLE(65536)    \
+    SR_TABLE(131072)   \
 
+#define SR_TABLE(len) \
+    TABLE_DEF(len, len/4 + 1);
 /* Power of two tables */
-SR_TABLE(8);
-SR_TABLE(16);
-SR_TABLE(32);
-SR_TABLE(64);
-SR_TABLE(128);
-SR_TABLE(256);
-SR_TABLE(512);
-SR_TABLE(1024);
-SR_TABLE(2048);
-SR_TABLE(4096);
-SR_TABLE(8192);
-SR_TABLE(16384);
-SR_TABLE(32768);
-SR_TABLE(65536);
-SR_TABLE(131072);
+SR_POW2_TABLES
+#undef SR_TABLE
 
 /* Other factors' tables */
 TABLE_DEF(53, 12);
@@ -63,7 +66,7 @@  typedef struct FFSRTabsInitOnceExt {
     int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
 } FFSRTabsInitOnceExt;
 
-#define INIT_FF_SR_TAB(len)                                        \
+#define SR_TABLE(len)                                              \
 static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void)            \
 {                                                                  \
     double freq = 2*M_PI/len;                                      \
@@ -74,39 +77,14 @@  static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void)            \
                                                                    \
     *tab = 0;                                                      \
 }
-
-INIT_FF_SR_TAB(8)
-INIT_FF_SR_TAB(16)
-INIT_FF_SR_TAB(32)
-INIT_FF_SR_TAB(64)
-INIT_FF_SR_TAB(128)
-INIT_FF_SR_TAB(256)
-INIT_FF_SR_TAB(512)
-INIT_FF_SR_TAB(1024)
-INIT_FF_SR_TAB(2048)
-INIT_FF_SR_TAB(4096)
-INIT_FF_SR_TAB(8192)
-INIT_FF_SR_TAB(16384)
-INIT_FF_SR_TAB(32768)
-INIT_FF_SR_TAB(65536)
-INIT_FF_SR_TAB(131072)
+SR_POW2_TABLES
+#undef SR_TABLE
 
 static FFSRTabsInitOnce sr_tabs_init_once[] = {
-    { TX_TAB(ff_tx_init_tab_8),      AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_16),     AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_32),     AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_64),     AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_128),    AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_256),    AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_512),    AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_1024),   AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_2048),   AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_4096),   AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_8192),   AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_16384),  AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_32768),  AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_65536),  AV_ONCE_INIT },
-    { TX_TAB(ff_tx_init_tab_131072), AV_ONCE_INIT },
+#define SR_TABLE(len) \
+    { TX_TAB(ff_tx_init_tab_ ## len), AV_ONCE_INIT },
+    SR_POW2_TABLES
+#undef SR_TABLE
 };
 
 static av_cold void TX_TAB(ff_tx_init_tab_53)(void)