diff mbox series

[FFmpeg-devel,12/13] avcodec/dca_lbr: Hardcode lpc table to save space

Message ID GV1P250MB0737FE432B494D184BD6F7DD8F479@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit 62d9b1195a039f88f8f82d2a519bf88c75f3cdbd
Headers show
Series [FFmpeg-devel,01/13] avcodec/dolby_e_parser: Remove unnecessary headers | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 13, 2022, 11:33 a.m. UTC
The code to initialize it takes more space (in .text) than
the table to be initialized (namely 86B vs 64B for GCC 11.2
with -O3 in an av_cold function), so hardcode the table.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/dca_lbr.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/dca_lbr.c b/libavcodec/dca_lbr.c
index 579bd9c469..9a0eb62f06 100644
--- a/libavcodec/dca_lbr.c
+++ b/libavcodec/dca_lbr.c
@@ -119,7 +119,17 @@  static const uint16_t channel_layouts[7] = {
 };
 
 static float    cos_tab[256];
-static float    lpc_tab[16];
+static const float lpc_tab[16] = {
+    /* lpc_tab[i] = sin((i - 8) * (M_PI / ((i < 8) ? 17 : 15))) */
+    -0.995734176295034521871191178905, -0.961825643172819070408796290732,
+    -0.895163291355062322067016499754, -0.798017227280239503332805112796,
+    -0.673695643646557211712691912426, -0.526432162877355800244607799141,
+    -0.361241666187152948744714596184, -0.183749517816570331574408839621,
+     0.0,                               0.207911690817759337101742284405,
+     0.406736643075800207753985990341,  0.587785252292473129168705954639,
+     0.743144825477394235014697048974,  0.866025403784438646763723170753,
+     0.951056516295153572116439333379,  0.994521895368273336922691944981
+};
 
 av_cold void ff_dca_lbr_init_tables(void)
 {
@@ -127,9 +137,6 @@  av_cold void ff_dca_lbr_init_tables(void)
 
     for (i = 0; i < 256; i++)
         cos_tab[i] = cos(M_PI * i / 128);
-
-    for (i = 0; i < 16; i++)
-        lpc_tab[i] = sin((i - 8) * (M_PI / ((i < 8) ? 17 : 15)));
 }
 
 static int parse_lfe_24(DCALbrDecoder *s)