summaryrefslogtreecommitdiff
path: root/libavcodec/mpegaudiodec_float.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-11-18 02:19:53 +0100
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2020-12-08 17:51:47 +0100
commited33bbe678730ef1ffde77f20eb4c6afb7a6902c (patch)
treea46f589b105fca7f4290023d17474e12e98ad01e /libavcodec/mpegaudiodec_float.c
parent12e941df89aa0e2aa8c6b90bfef9d4127ae7063c (diff)
avcodec/mpegaudiodec: Hardcode tables to save space
The csa_tables (which always consist of 32 entries of four byte each, but the type depends upon whether the decoder is fixed or floating-point) are currently initialized once during decoder initialization; yet it turns out that this is actually no benefit: The code used to initialize these tables takes up 153 (fixed point) and 122 (floating point) bytes when compiled with GCC 9.3 with -O3 on x64, so it is better to just hardcode these tables. Essentially the same applies to the is_tables: They have a size of 128B each and the code to initialize them occupies 149 (fixed point) resp. 140 (floating point) bytes. So hardcode them, too. To make the origin of the tables clear, references to the code used to create them have been added. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpegaudiodec_float.c')
-rw-r--r--libavcodec/mpegaudiodec_float.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libavcodec/mpegaudiodec_float.c b/libavcodec/mpegaudiodec_float.c
index cdee337499..3ab7651d5b 100644
--- a/libavcodec/mpegaudiodec_float.c
+++ b/libavcodec/mpegaudiodec_float.c
@@ -36,6 +36,39 @@
#define OUT_FMT AV_SAMPLE_FMT_FLT
#define OUT_FMT_P AV_SAMPLE_FMT_FLTP
+/* Intensity stereo table. See commit b91d46614df189e7905538e7f5c4ed9c7ed0d274
+ * (float based mp1/mp2/mp3 decoders.) for how they were created. */
+static const float is_table[2][16] = {
+ { 0.000000000000000000e+00, 2.113248705863952637e-01, 3.660253882408142090e-01,
+ 5.000000000000000000e-01, 6.339746117591857910e-01, 7.886751294136047363e-01,
+ 1.000000000000000000e+00 },
+ { 1.000000000000000000e+00, 7.886751294136047363e-01, 6.339746117591857910e-01,
+ 5.000000000000000000e-01, 3.660253882408142090e-01, 2.113248705863952637e-01,
+ 0.000000000000000000e+00 }
+};
+
+/* Antialiasing table. See commit 6f1ec38ce2193d3d4cacd87edb452c6d7ba751ec
+ * (mpegaudio: clean up compute_antialias() definition) for how they were
+ * created. */
+static const float csa_table[8][4] = {
+ { 8.574929237365722656e-01, -5.144957900047302246e-01,
+ 3.429971337318420410e-01, -1.371988654136657715e+00 },
+ { 8.817420005798339844e-01, -4.717319905757904053e-01,
+ 4.100100100040435791e-01, -1.353474020957946777e+00 },
+ { 9.496286511421203613e-01, -3.133774697780609131e-01,
+ 6.362511515617370605e-01, -1.263006091117858887e+00 },
+ { 9.833145737648010254e-01, -1.819131970405578613e-01,
+ 8.014013767242431641e-01, -1.165227770805358887e+00 },
+ { 9.955177903175354004e-01, -9.457419067621231079e-02,
+ 9.009436368942260742e-01, -1.090092062950134277e+00 },
+ { 9.991605877876281738e-01, -4.096558317542076111e-02,
+ 9.581949710845947266e-01, -1.040126085281372070e+00 },
+ { 9.998992085456848145e-01, -1.419856864959001541e-02,
+ 9.857006072998046875e-01, -1.014097809791564941e+00 },
+ { 9.999931454658508301e-01, -3.699974622577428818e-03,
+ 9.962931871414184570e-01, -1.003693103790283203e+00 }
+};
+
#include "mpegaudiodec_template.c"
#if CONFIG_MP1FLOAT_DECODER