diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-11-18 13:13:45 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-12-08 17:51:47 +0100 |
commit | d5d1c697bd0844a676eeb7761b130b6dd951edee (patch) | |
tree | b48866794f78373e136d839713a06dd0f8c39c82 /libavcodec/mpegaudio_tablegen.h | |
parent | ed33bbe678730ef1ffde77f20eb4c6afb7a6902c (diff) |
avcodec/mpegaudio_tablegen: Make exponential LUT shared
Both the fixed as well as the floating point mpegaudio decoders use
LUTs of type int8_t and uint32_t with 32K entries each; these tables
are completely the same, yet they are not shared. This commit makes
them shared. When both fixed as well as floating point decoders are
enabled, this saves 160KiB from the bss segment for a normal build
(translating into 160KiB less memory usage if both a shared as well as
a floating point decoder have actually been used) and 160KiB from the
binary for a build with hardcoded tables.
It also means that the code to create said LUTs is no longer duplicated
(for a normal build).
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpegaudio_tablegen.h')
-rw-r--r-- | libavcodec/mpegaudio_tablegen.h | 22 |
1 files changed, 1 insertions, 21 deletions
diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h index d9e32b54da..bae6962ac0 100644 --- a/libavcodec/mpegaudio_tablegen.h +++ b/libavcodec/mpegaudio_tablegen.h @@ -27,14 +27,10 @@ #include <math.h> #include "libavutil/attributes.h" -#define TABLE_4_3_SIZE (8191 + 16)*4 #if CONFIG_HARDCODED_TABLES #define mpegaudio_tableinit() #include "libavcodec/mpegaudio_tables.h" #else -static int8_t table_4_3_exp[TABLE_4_3_SIZE]; -static uint32_t table_4_3_value[TABLE_4_3_SIZE]; - #if defined(BUILD_TABLES) || !USE_FLOATS #define FIXED_TABLE static uint32_t exp_table_fixed[512]; @@ -47,7 +43,6 @@ static float exp_table_float[512]; static float expval_table_float[512][16]; #endif -#define FRAC_BITS 23 #define IMDCT_SCALAR 1.759 static av_cold void mpegaudio_tableinit(void) @@ -62,25 +57,10 @@ static av_cold void mpegaudio_tableinit(void) double pow43_lut[16]; double exp2_base = 2.11758236813575084767080625169910490512847900390625e-22; // 2^(-72) double exp2_val; - double pow43_val = 0; + for (i = 0; i < 16; ++i) pow43_lut[i] = i * cbrt(i); - for (i = 1; i < TABLE_4_3_SIZE; i++) { - double f, fm; - int e, m; - double value = i / 4; - if ((i & 3) == 0) - pow43_val = value / IMDCT_SCALAR * cbrt(value); - f = pow43_val * exp2_lut[i & 3]; - fm = frexp(f, &e); - m = llrint(fm * (1LL << 31)); - e += FRAC_BITS - 31 + 5 - 100; - - /* normalized to FRAC_BITS */ - table_4_3_value[i] = m; - table_4_3_exp[i] = -e; - } for (exponent = 0; exponent < 512; exponent++) { if (exponent && (exponent & 3) == 0) exp2_base *= 2; |