-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use dynamic allocation for ffmpeg fft tables on Windows. #21539
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c | ||
index 8dc3d2519c13abec090b374fa5ed0f11f7153849..a5d156d2789ec521c034edd929e04b2ad09a833b 100644 | ||
--- a/libavutil/tx_template.c | ||
+++ b/libavutil/tx_template.c | ||
@@ -27,6 +27,29 @@ | ||
#define TABLE_DEF(name, size) \ | ||
DECLARE_ALIGNED(32, TXSample, TX_TAB(ff_tx_tab_ ##name))[size] | ||
|
||
+#ifdef _WIN32 | ||
+ | ||
+#include <malloc.h> | ||
+ | ||
+// Declares aligned ff_tx_tab_* pointer. | ||
+#define TABLE_DEF_PTR(name, size) \ | ||
+ DECLARE_ALIGNED(32, TXSample*, TX_TAB(ff_tx_tab_##name)) | ||
+ | ||
+// Allocates aligned memory for ff_tx_tab_* variable. | ||
+#define ALLOCATE_FF_TX_TABLE(len) \ | ||
+ if (!TX_TAB(ff_tx_tab_##len)) { \ | ||
+ TX_TAB(ff_tx_tab_##len) = \ | ||
+ _aligned_malloc((len / 4 + 1) * sizeof(TXSample), 32); \ | ||
+ } | ||
+ | ||
+#else | ||
+ | ||
+// Use static arrays on non-Windows targets as usual. | ||
+#define TABLE_DEF_PTR(name, size) TABLE_DEF(name, size) | ||
+#define ALLOCATE_FF_TX_TABLE(len) | ||
+ | ||
+#endif | ||
+ | ||
#define SR_POW2_TABLES \ | ||
SR_TABLE(8) \ | ||
SR_TABLE(16) \ | ||
@@ -43,13 +66,9 @@ | ||
SR_TABLE(32768) \ | ||
SR_TABLE(65536) \ | ||
SR_TABLE(131072) \ | ||
- SR_TABLE(262144) \ | ||
- SR_TABLE(524288) \ | ||
- SR_TABLE(1048576) \ | ||
- SR_TABLE(2097152) \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add the link to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
#define SR_TABLE(len) \ | ||
- TABLE_DEF(len, len/4 + 1); | ||
+ TABLE_DEF_PTR(len, len/4 + 1); | ||
/* Power of two tables */ | ||
SR_POW2_TABLES | ||
#undef SR_TABLE | ||
@@ -68,6 +87,7 @@ typedef struct FFTabInitData { | ||
static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void) \ | ||
{ \ | ||
double freq = 2*M_PI/len; \ | ||
+ ALLOCATE_FF_TX_TABLE(len); \ | ||
TXSample *tab = TX_TAB(ff_tx_tab_ ##len); \ | ||
\ | ||
for (int i = 0; i < len/4; i++) \ | ||
@@ -721,10 +741,6 @@ DECL_SR_CODELET(16384,8192,4096) | ||
DECL_SR_CODELET(32768,16384,8192) | ||
DECL_SR_CODELET(65536,32768,16384) | ||
DECL_SR_CODELET(131072,65536,32768) | ||
-DECL_SR_CODELET(262144,131072,65536) | ||
-DECL_SR_CODELET(524288,262144,131072) | ||
-DECL_SR_CODELET(1048576,524288,262144) | ||
-DECL_SR_CODELET(2097152,1048576,524288) | ||
|
||
static av_cold int TX_NAME(ff_tx_fft_init)(AVTXContext *s, | ||
const FFTXCodelet *cd, | ||
@@ -2157,10 +2173,6 @@ const FFTXCodelet * const TX_NAME(ff_tx_codelet_list)[] = { | ||
&TX_NAME(ff_tx_fft32768_ns_def), | ||
&TX_NAME(ff_tx_fft65536_ns_def), | ||
&TX_NAME(ff_tx_fft131072_ns_def), | ||
- &TX_NAME(ff_tx_fft262144_ns_def), | ||
- &TX_NAME(ff_tx_fft524288_ns_def), | ||
- &TX_NAME(ff_tx_fft1048576_ns_def), | ||
- &TX_NAME(ff_tx_fft2097152_ns_def), | ||
|
||
/* Prime factor codelets */ | ||
&TX_NAME(ff_tx_fft3_ns_def), |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we cannot use chromium_src for this override, because
tx_template.c
is included intotx_float.c
.