From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 4/5] avutil/tx_template: Avoid code duplication
Date: Sat, 22 Oct 2022 15:59:02 +0200
Message-ID: <AS8P250MB0744B3A7C36BC043E7E56B388F2C9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
In-Reply-To: <AS8P250MB0744EEDDFAC2FE05398004DF8F2C9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/tx_template.c | 76 +++++++++++++++--------------------------
1 file changed, 27 insertions(+), 49 deletions(-)
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)
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-10-22 13:59 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-22 13:57 [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const Andreas Rheinhardt
2022-10-22 13:59 ` [FFmpeg-devel] [PATCH 2/5] avcodec/aaccoder: Mark function pointer arrays " Andreas Rheinhardt
2022-10-22 13:59 ` [FFmpeg-devel] [PATCH 3/5] avutil/tx_template: Don't waste space for inexistent factors Andreas Rheinhardt
2022-10-22 13:59 ` Andreas Rheinhardt [this message]
2022-10-22 13:59 ` [FFmpeg-devel] [PATCH 5/5] avutil/tx_template: Move function pointers to const memory Andreas Rheinhardt
2022-10-27 13:56 ` [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AS8P250MB0744B3A7C36BC043E7E56B388F2C9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git