mirror of https://git.ffmpeg.org/ffmpeg.git
avutil/tx_template: Move function pointers to const memory
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). Reviewed-by: Lynne <dev@lynne.ee> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
188216581b
commit
f8efd890bf
|
@ -55,16 +55,10 @@ TABLE_DEF(53, 12);
|
||||||
TABLE_DEF( 7, 6);
|
TABLE_DEF( 7, 6);
|
||||||
TABLE_DEF( 9, 8);
|
TABLE_DEF( 9, 8);
|
||||||
|
|
||||||
typedef struct FFSRTabsInitOnce {
|
typedef struct FFTabInitData {
|
||||||
void (*func)(void);
|
void (*func)(void);
|
||||||
AVOnce control;
|
|
||||||
} FFSRTabsInitOnce;
|
|
||||||
|
|
||||||
typedef struct FFSRTabsInitOnceExt {
|
|
||||||
void (*func)(void);
|
|
||||||
AVOnce control;
|
|
||||||
int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
|
int factors[TX_MAX_SUB]; /* Must be sorted high -> low */
|
||||||
} FFSRTabsInitOnceExt;
|
} FFTabInitData;
|
||||||
|
|
||||||
#define SR_TABLE(len) \
|
#define SR_TABLE(len) \
|
||||||
static av_cold void TX_TAB(ff_tx_init_tab_ ##len)(void) \
|
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
|
SR_POW2_TABLES
|
||||||
#undef SR_TABLE
|
#undef SR_TABLE
|
||||||
|
|
||||||
static FFSRTabsInitOnce sr_tabs_init_once[] = {
|
static void (*const sr_tabs_init_funcs[])(void) = {
|
||||||
#define SR_TABLE(len) \
|
#define SR_TABLE(len) TX_TAB(ff_tx_init_tab_ ##len),
|
||||||
{ TX_TAB(ff_tx_init_tab_ ## len), AV_ONCE_INIT },
|
SR_POW2_TABLES
|
||||||
|
#undef SR_TABLE
|
||||||
|
};
|
||||||
|
|
||||||
|
static AVOnce sr_tabs_init_once[] = {
|
||||||
|
#define SR_TABLE(len) AV_ONCE_INIT,
|
||||||
SR_POW2_TABLES
|
SR_POW2_TABLES
|
||||||
#undef SR_TABLE
|
#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];
|
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[] = {
|
static const FFTabInitData nptwo_tabs_init_data[] = {
|
||||||
{ TX_TAB(ff_tx_init_tab_53), AV_ONCE_INIT, { 15, 5, 3 } },
|
{ TX_TAB(ff_tx_init_tab_53), { 15, 5, 3 } },
|
||||||
{ TX_TAB(ff_tx_init_tab_9), AV_ONCE_INIT, { 9 } },
|
{ TX_TAB(ff_tx_init_tab_9), { 9 } },
|
||||||
{ TX_TAB(ff_tx_init_tab_7), AV_ONCE_INIT, { 7 } },
|
{ 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)
|
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) {
|
if (factor_2) {
|
||||||
int idx = factor_2 - 3;
|
int idx = factor_2 - 3;
|
||||||
for (int i = 0; i <= idx; i++)
|
for (int i = 0; i <= idx; i++)
|
||||||
ff_thread_once(&sr_tabs_init_once[i].control,
|
ff_thread_once(&sr_tabs_init_once[i],
|
||||||
sr_tabs_init_once[i].func);
|
sr_tabs_init_funcs[i]);
|
||||||
len >>= factor_2;
|
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;
|
int f, f_idx = 0;
|
||||||
|
|
||||||
if (len <= 1)
|
if (len <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while ((f = nptwo_tabs_init_once[i].factors[f_idx++])) {
|
while ((f = nptwo_tabs_init_data[i].factors[f_idx++])) {
|
||||||
if (f % len)
|
if (f % len)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ff_thread_once(&nptwo_tabs_init_once[i].control,
|
ff_thread_once(&nptwo_tabs_init_once[i],
|
||||||
nptwo_tabs_init_once[i].func);
|
nptwo_tabs_init_data[i].func);
|
||||||
len /= f;
|
len /= f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue