* [FFmpeg-devel] [PATCH 2/5] avcodec/aaccoder: Mark function pointer arrays as const
2022-10-22 13:57 [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const Andreas Rheinhardt
@ 2022-10-22 13:59 ` Andreas Rheinhardt
2022-10-22 13:59 ` [FFmpeg-devel] [PATCH 3/5] avutil/tx_template: Don't waste space for inexistent factors Andreas Rheinhardt
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-10-22 13:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Forgotten in 57d305207a30131172e1c07c99e2cba833c1add1.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/aaccoder.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index e3b6b2f02c..6291c16123 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -226,7 +226,7 @@ QUANTIZE_AND_ENCODE_BAND_COST_FUNC(ESC_RTZ, 0, 1, 1, 1, 0, 0, ROUND_TO_ZERO)
QUANTIZE_AND_ENCODE_BAND_COST_FUNC(NOISE, 0, 0, 0, 0, 1, 0, ROUND_STANDARD)
QUANTIZE_AND_ENCODE_BAND_COST_FUNC(STEREO,0, 0, 0, 0, 0, 1, ROUND_STANDARD)
-static quantize_and_encode_band_func quantize_and_encode_band_cost_arr[] =
+static const quantize_and_encode_band_func quantize_and_encode_band_cost_arr[] =
{
quantize_and_encode_band_cost_ZERO,
quantize_and_encode_band_cost_SQUAD,
@@ -246,7 +246,7 @@ static quantize_and_encode_band_func quantize_and_encode_band_cost_arr[] =
quantize_and_encode_band_cost_STEREO,
};
-static quantize_and_encode_band_func quantize_and_encode_band_cost_rtz_arr[] =
+static const quantize_and_encode_band_func quantize_and_encode_band_cost_rtz_arr[] =
{
quantize_and_encode_band_cost_ZERO,
quantize_and_encode_band_cost_SQUAD,
--
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 3/5] avutil/tx_template: Don't waste space for inexistent factors
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 ` Andreas Rheinhardt
2022-10-22 13:59 ` [FFmpeg-devel] [PATCH 4/5] avutil/tx_template: Avoid code duplication Andreas Rheinhardt
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-10-22 13:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
It is possible to avoid the factors array for the power-of-two
tables for which said array is unused by using a different
structure for initialization the same structure for power-of-two
tables as for non-power-of-two-tables. This saves 3*15*16B
from .data.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/tx_template.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index 6b63cc575f..b44a6189cc 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -55,9 +55,14 @@ TABLE_DEF( 9, 8);
typedef struct FFSRTabsInitOnce {
void (*func)(void);
AVOnce control;
- int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
} FFSRTabsInitOnce;
+typedef struct FFSRTabsInitOnceExt {
+ void (*func)(void);
+ AVOnce control;
+ int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
+} FFSRTabsInitOnceExt;
+
#define INIT_FF_SR_TAB(len) \
static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void) \
{ \
@@ -145,7 +150,7 @@ static av_cold void TX_TAB(ff_tx_init_tab_9)(void)
TX_TAB(ff_tx_tab_9)[7] = TX_TAB(ff_tx_tab_9)[3] - TX_TAB(ff_tx_tab_9)[4];
}
-static FFSRTabsInitOnce nptwo_tabs_init_once[] = {
+static FFSRTabsInitOnceExt nptwo_tabs_init_once[] = {
{ TX_TAB(ff_tx_init_tab_53), AV_ONCE_INIT, { 15, 5, 3 } },
{ TX_TAB(ff_tx_init_tab_9), AV_ONCE_INIT, { 9 } },
{ TX_TAB(ff_tx_init_tab_7), AV_ONCE_INIT, { 7 } },
--
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 4/5] avutil/tx_template: Avoid code duplication
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
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
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-10-22 13:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* [FFmpeg-devel] [PATCH 5/5] avutil/tx_template: Move function pointers to const memory
2022-10-22 13:57 [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const Andreas Rheinhardt
` (2 preceding siblings ...)
2022-10-22 13:59 ` [FFmpeg-devel] [PATCH 4/5] avutil/tx_template: Avoid code duplication Andreas Rheinhardt
@ 2022-10-22 13:59 ` Andreas Rheinhardt
2022-10-27 13:56 ` [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const Andreas Rheinhardt
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-10-22 13:59 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This can be achieved by moving the AVOnce out of the structure
containing the function pointers; the latter can then be made
const.
This also has the advantage of eliminating padding in the structure
(sizeof(AVOnce) is four here) and allowing the AVOnces to be put
into .bss (dependening upon the implementation).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/tx_template.c | 47 +++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 21 deletions(-)
diff --git a/libavutil/tx_template.c b/libavutil/tx_template.c
index c15dc2ea27..56e9a6aa98 100644
--- a/libavutil/tx_template.c
+++ b/libavutil/tx_template.c
@@ -55,16 +55,10 @@ TABLE_DEF(53, 12);
TABLE_DEF( 7, 6);
TABLE_DEF( 9, 8);
-typedef struct FFSRTabsInitOnce {
+typedef struct FFSRTabsInitData {
void (*func)(void);
- AVOnce control;
-} FFSRTabsInitOnce;
-
-typedef struct FFSRTabsInitOnceExt {
- void (*func)(void);
- AVOnce control;
int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
-} FFSRTabsInitOnceExt;
+} FFSRTabsInitData;
#define SR_TABLE(len) \
static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void) \
@@ -80,9 +74,14 @@ static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void) \
SR_POW2_TABLES
#undef SR_TABLE
-static FFSRTabsInitOnce sr_tabs_init_once[] = {
-#define SR_TABLE(len) \
- { TX_TAB(ff_tx_init_tab_ ## len), AV_ONCE_INIT },
+static void (*const sr_tabs_init_funcs[])(void) = {
+#define SR_TABLE(len) TX_TAB(ff_tx_init_tab_ ##len),
+ SR_POW2_TABLES
+#undef SR_TABLE
+};
+
+static AVOnce sr_tabs_init_once[] = {
+#define SR_TABLE(len) AV_ONCE_INIT,
SR_POW2_TABLES
#undef SR_TABLE
};
@@ -128,10 +127,16 @@ static av_cold void TX_TAB(ff_tx_init_tab_9)(void)
TX_TAB(ff_tx_tab_9)[7] = TX_TAB(ff_tx_tab_9)[3] - TX_TAB(ff_tx_tab_9)[4];
}
-static FFSRTabsInitOnceExt nptwo_tabs_init_once[] = {
- { TX_TAB(ff_tx_init_tab_53), AV_ONCE_INIT, { 15, 5, 3 } },
- { TX_TAB(ff_tx_init_tab_9), AV_ONCE_INIT, { 9 } },
- { TX_TAB(ff_tx_init_tab_7), AV_ONCE_INIT, { 7 } },
+static const FFSRTabsInitData nptwo_tabs_init_data[] = {
+ { TX_TAB(ff_tx_init_tab_53), { 15, 5, 3 } },
+ { TX_TAB(ff_tx_init_tab_9), { 9 } },
+ { TX_TAB(ff_tx_init_tab_7), { 7 } },
+};
+
+static AVOnce nptwo_tabs_init_once[] = {
+ AV_ONCE_INIT,
+ AV_ONCE_INIT,
+ AV_ONCE_INIT,
};
av_cold void TX_TAB(ff_tx_init_tabs)(int len)
@@ -140,23 +145,23 @@ av_cold void TX_TAB(ff_tx_init_tabs)(int len)
if (factor_2) {
int idx = factor_2 - 3;
for (int i = 0; i <= idx; i++)
- ff_thread_once(&sr_tabs_init_once[i].control,
- sr_tabs_init_once[i].func);
+ ff_thread_once(&sr_tabs_init_once[i],
+ sr_tabs_init_funcs[i]);
len >>= factor_2;
}
- for (int i = 0; i < FF_ARRAY_ELEMS(nptwo_tabs_init_once); i++) {
+ for (int i = 0; i < FF_ARRAY_ELEMS(nptwo_tabs_init_data); i++) {
int f, f_idx = 0;
if (len <= 1)
return;
- while ((f = nptwo_tabs_init_once[i].factors[f_idx++])) {
+ while ((f = nptwo_tabs_init_data[i].factors[f_idx++])) {
if (f % len)
continue;
- ff_thread_once(&nptwo_tabs_init_once[i].control,
- nptwo_tabs_init_once[i].func);
+ ff_thread_once(&nptwo_tabs_init_once[i],
+ nptwo_tabs_init_data[i].func);
len /= f;
break;
}
--
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".
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const
2022-10-22 13:57 [FFmpeg-devel] [PATCH 1/5] avformat/argo_cvg: Mark overrides as const Andreas Rheinhardt
` (3 preceding siblings ...)
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 ` Andreas Rheinhardt
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-10-27 13:56 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavformat/argo_cvg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/argo_cvg.c b/libavformat/argo_cvg.c
> index edf75c905e..aedc7c4a32 100644
> --- a/libavformat/argo_cvg.c
> +++ b/libavformat/argo_cvg.c
> @@ -70,7 +70,7 @@ typedef struct ArgoCVGMuxContext {
>
> #if CONFIG_ARGO_CVG_DEMUXER
> /* "Special" files that are played at a different rate. */
> -static ArgoCVGOverride overrides[] = {
> +static const ArgoCVGOverride overrides[] = {
> { "CRYS.CVG", { 23592, 0, 1 }, 2495499, 88200 }, /* Beta */
> { "REDCRY88.CVG", { 38280, 0, 1 }, 4134848, 88200 }, /* Beta */
> { "DANLOOP1.CVG", { 54744, 1, 0 }, 5684641, 37800 }, /* Beta */
Will apply this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
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".
^ permalink raw reply [flat|nested] 6+ messages in thread