提交 22140374 编写于 作者: A Andreas Rheinhardt

avcodec/mpegaudio_tablegen: Avoid write-only buffers

The mpegaudio_tablegen header contains code to initialize several
tables; it is included in both the fixed as well as the floating point
mpegaudio decoders and some of these tables are only used by the fixed
resp. floating point decoders; yet both types are always initialized,
leaving the compiler to figure out that one of them is unused.

GCC 9.3 fails at this (even with -O3):
$ readelf -s mpegaudiodec_fixed.o|grep _float
    28: 0000000000001660 32768 OBJECT  LOCAL  DEFAULT    4 expval_table_float
An actually unused table (expval_table_fixed/float) of size 32KiB is kept
and initialized (the reason for this is probably that this table is read
from, namely to initialize another table: exp_table_fixed/float; of course
the float resp. fixed tables are not used in the fixed resp. floating point
decoder).

Therefore #ifdef the unneeded tables away.
Signed-off-by: NAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
上级 73bc26ac
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <stdlib.h> #include <stdlib.h>
#define CONFIG_HARDCODED_TABLES 0 #define CONFIG_HARDCODED_TABLES 0
#define BUILD_TABLES
#include "libavutil/tablegen.h" #include "libavutil/tablegen.h"
#include "mpegaudio_tablegen.h" #include "mpegaudio_tablegen.h"
#include "tableprint.h" #include "tableprint.h"
......
...@@ -34,10 +34,18 @@ ...@@ -34,10 +34,18 @@
#else #else
static int8_t table_4_3_exp[TABLE_4_3_SIZE]; static int8_t table_4_3_exp[TABLE_4_3_SIZE];
static uint32_t table_4_3_value[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]; static uint32_t exp_table_fixed[512];
static uint32_t expval_table_fixed[512][16]; static uint32_t expval_table_fixed[512][16];
#endif
#if defined(BUILD_TABLES) || USE_FLOATS
#define FLOAT_TABLE
static float exp_table_float[512]; static float exp_table_float[512];
static float expval_table_float[512][16]; static float expval_table_float[512][16];
#endif
#define FRAC_BITS 23 #define FRAC_BITS 23
#define IMDCT_SCALAR 1.759 #define IMDCT_SCALAR 1.759
...@@ -79,13 +87,23 @@ static av_cold void mpegaudio_tableinit(void) ...@@ -79,13 +87,23 @@ static av_cold void mpegaudio_tableinit(void)
exp2_val = exp2_base * exp2_lut[exponent & 3] / IMDCT_SCALAR; exp2_val = exp2_base * exp2_lut[exponent & 3] / IMDCT_SCALAR;
for (value = 0; value < 16; value++) { for (value = 0; value < 16; value++) {
double f = pow43_lut[value] * exp2_val; double f = pow43_lut[value] * exp2_val;
#ifdef FIXED_TABLE
expval_table_fixed[exponent][value] = (f < 0xFFFFFFFF ? llrint(f) : 0xFFFFFFFF); expval_table_fixed[exponent][value] = (f < 0xFFFFFFFF ? llrint(f) : 0xFFFFFFFF);
#endif
#ifdef FLOAT_TABLE
expval_table_float[exponent][value] = f; expval_table_float[exponent][value] = f;
#endif
} }
#ifdef FIXED_TABLE
exp_table_fixed[exponent] = expval_table_fixed[exponent][1]; exp_table_fixed[exponent] = expval_table_fixed[exponent][1];
#endif
#ifdef FLOAT_TABLE
exp_table_float[exponent] = expval_table_float[exponent][1]; exp_table_float[exponent] = expval_table_float[exponent][1];
#endif
} }
} }
#undef FLOAT_TABLE
#undef FIXED_TABLE
#endif /* CONFIG_HARDCODED_TABLES */ #endif /* CONFIG_HARDCODED_TABLES */
#endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */ #endif /* AVCODEC_MPEGAUDIO_TABLEGEN_H */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册