diff mbox series

[FFmpeg-devel,175/191] avcodec/aac: Share common init code of float decoder and encoder

Message ID 20201123193739.1249300-13-andreas.rheinhardt@gmail.com
State Accepted
Commit 86b8c25455d8dfa752e1f2000c775e547b9fa433
Headers show
Series VLC, esp. init_vlc patches
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Nov. 23, 2020, 7:37 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/aacdec_template.c | 10 ++++++----
 libavcodec/aacenc.c          |  6 +-----
 libavcodec/aactab.c          | 14 ++++++++++++++
 libavcodec/aactab.h          |  3 +++
 4 files changed, 24 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 3bf271af54..fbe3074071 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -1230,17 +1230,19 @@  static av_cold void aac_static_table_init(void)
                     352);
 
     // window initialization
-    AAC_RENAME(ff_kbd_window_init)(AAC_KBD_RENAME(kbd_long_1024), 4.0, 1024);
-    AAC_RENAME(ff_kbd_window_init)(AAC_KBD_RENAME(kbd_short_128), 6.0, 128);
 #if !USE_FIXED
     AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_long_960), 4.0, 960);
     AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(aac_kbd_short_120), 6.0, 120);
     AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960);
     AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120);
-#endif
+    ff_aac_float_common_init();
+#else
+    AAC_RENAME(ff_kbd_window_init)(AAC_KBD_RENAME(kbd_long_1024), 4.0, 1024);
+    AAC_RENAME(ff_kbd_window_init)(AAC_KBD_RENAME(kbd_short_128), 6.0, 128);
     AAC_RENAME(ff_init_ff_sine_windows)(10);
-    AAC_RENAME(ff_init_ff_sine_windows)( 9);
     AAC_RENAME(ff_init_ff_sine_windows)( 7);
+#endif
+    AAC_RENAME(ff_init_ff_sine_windows)( 9);
 
     AAC_RENAME(ff_cbrt_tableinit)();
 }
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 274e5ca294..070a2e706a 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -36,7 +36,6 @@ 
 #include "put_bits.h"
 #include "internal.h"
 #include "mpeg4audio.h"
-#include "kbdwin.h"
 #include "sinewin.h"
 #include "profiles.h"
 
@@ -922,10 +921,7 @@  static av_cold int dsp_init(AVCodecContext *avctx, AACEncContext *s)
         return AVERROR(ENOMEM);
 
     // window init
-    ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
-    ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
-    ff_init_ff_sine_windows(10);
-    ff_init_ff_sine_windows(7);
+    ff_aac_float_common_init();
 
     if ((ret = ff_mdct_init(&s->mdct1024, 11, 0, 32768.0)) < 0)
         return ret;
diff --git a/libavcodec/aactab.c b/libavcodec/aactab.c
index e886642e66..b9d1336d97 100644
--- a/libavcodec/aactab.c
+++ b/libavcodec/aactab.c
@@ -27,6 +27,7 @@ 
  * @author Maxim Gavrilov ( maxim.gavrilov gmail com )
  */
 
+#include "config.h"
 #include "libavutil/mem.h"
 #include "libavutil/thread.h"
 #include "aac.h"
@@ -37,9 +38,22 @@ 
 float ff_aac_pow2sf_tab[428];
 float ff_aac_pow34sf_tab[428];
 
+#if CONFIG_AAC_ENCODER || CONFIG_AAC_DECODER
+#include "kbdwin.h"
+#include "sinewin.h"
+
 DECLARE_ALIGNED(32, float,  ff_aac_kbd_long_1024)[1024];
 DECLARE_ALIGNED(32, float,  ff_aac_kbd_short_128)[128];
 
+av_cold void ff_aac_float_common_init(void)
+{
+    ff_kbd_window_init(ff_aac_kbd_long_1024, 4.0, 1024);
+    ff_kbd_window_init(ff_aac_kbd_short_128, 6.0, 128);
+    ff_init_ff_sine_windows(10);
+    ff_init_ff_sine_windows(7);
+}
+#endif
+
 const uint8_t ff_aac_num_swb_1024[] = {
     41, 41, 47, 49, 49, 51, 47, 47, 43, 43, 43, 40, 40
 };
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 04180b96fd..02f79a16c0 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -100,6 +100,9 @@  DECLARE_ALIGNED(32, extern const float, ff_aac_eld_window_480)[1800];
 DECLARE_ALIGNED(32, extern const int,   ff_aac_eld_window_480_fixed)[1800];
 // @}
 
+/* Initializes data shared between float decoder and encoder. */
+void ff_aac_float_common_init(void);
+
 /* @name number of scalefactor window bands for long and short transform windows respectively
  * @{
  */