aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2024-03-16 00:12:56 +0100
committerLynne <dev@lynne.ee>2024-04-23 08:31:34 +0200
commita309aa412755f7bb16eead43bcaff1a9dcdb5954 (patch)
tree6285f2d39ab946b1ae1ea0f792e81193e934b848
parente9fc7661daac9c0df0747e11435570899652d686 (diff)
downloadffmpeg-a309aa412755f7bb16eead43bcaff1a9dcdb5954.tar.gz
aacdec: duplicate table initialization
Preparation to move all table init and support windowing functions.
-rw-r--r--libavcodec/aac/aacdec.c2
-rw-r--r--libavcodec/aac/aacdec_dsp_template.c2
-rw-r--r--libavcodec/aac/aacdec_fixed.c26
-rw-r--r--libavcodec/aac/aacdec_float.c27
-rw-r--r--libavcodec/aacdec.h2
5 files changed, 57 insertions, 2 deletions
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 00353bddc7..26612f4a14 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -120,6 +120,8 @@ av_cold int ff_aac_decode_init_common(AVCodecContext *avctx)
ac->dsp = is_fixed ? aac_dsp_fixed : aac_dsp;
+ ac->dsp.init_tables();
+
return 0;
}
diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c
index 5e18b30d99..30151604c2 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -311,6 +311,8 @@ static void AAC_RENAME(update_ltp)(AACDecContext *ac, SingleChannelElement *sce)
}
const AACDecDSP AAC_RENAME(aac_dsp) = {
+ .init_tables = &AAC_RENAME(init_tables),
+
.dequant_scalefactors = &AAC_RENAME(dequant_scalefactors),
.apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo),
.apply_intensity_stereo = &AAC_RENAME(apply_intensity_stereo),
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 9b66f22d2f..9dd8f34f55 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -31,12 +31,34 @@
#define USE_FIXED 1
+#include "libavutil/thread.h"
+
#include "libavcodec/aac_defines.h"
#include "libavcodec/aactab.h"
#include "libavcodec/sinewin_fixed_tablegen.h"
+#include "libavcodec/kbdwin.h"
+
+DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_long_1024))[1024];
+DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME2(aac_kbd_short_128))[128];
+DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(aac_kbd_long_960))[960];
+DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(aac_kbd_short_120))[120];
+
+static void init_tables_fixed_fn(void)
+{
+ AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
+ AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
+
+ 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);
+
+ init_sine_windows_fixed();
+}
-DECLARE_ALIGNED(32, extern int, AAC_RENAME2(aac_kbd_long_1024))[1024];
-DECLARE_ALIGNED(32, extern int, AAC_RENAME2(aac_kbd_short_128))[128];
+static void init_tables_fixed(void)
+{
+ static AVOnce init_fixed_once = AV_ONCE_INIT;
+ ff_thread_once(&init_fixed_once, init_tables_fixed_fn);
+}
#include "aacdec_dsp_template.c"
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index ba1b06cc21..6a5e8483b0 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -31,9 +31,36 @@
#define USE_FIXED 0
+#include "libavutil/thread.h"
+
#include "libavcodec/aac_defines.h"
#include "libavcodec/aactab.h"
#include "libavcodec/sinewin.h"
+#include "libavcodec/kbdwin.h"
+
+DECLARE_ALIGNED(32, static float, sine_120)[120];
+DECLARE_ALIGNED(32, static float, sine_960)[960];
+DECLARE_ALIGNED(32, static float, aac_kbd_long_960)[960];
+DECLARE_ALIGNED(32, static float, aac_kbd_short_120)[120];
+
+static void init_tables_float_fn(void)
+{
+ AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_long_1024), 4.0, 1024);
+ AAC_RENAME(ff_kbd_window_init)(AAC_RENAME2(aac_kbd_short_128), 6.0, 128);
+
+ 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);
+ AAC_RENAME(ff_init_ff_sine_windows)(9);
+}
+
+static void init_tables(void)
+{
+ static AVOnce init_float_once = AV_ONCE_INIT;
+ ff_thread_once(&init_float_once, init_tables_float_fn);
+}
#include "aacdec_dsp_template.c"
diff --git a/libavcodec/aacdec.h b/libavcodec/aacdec.h
index 109c38d8e2..30da1fc198 100644
--- a/libavcodec/aacdec.h
+++ b/libavcodec/aacdec.h
@@ -204,6 +204,8 @@ typedef struct DynamicRangeControl {
* DSP-specific primitives
*/
typedef struct AACDecDSP {
+ void (*init_tables)(void);
+
void (*dequant_scalefactors)(SingleChannelElement *sce);
void (*apply_mid_side_stereo)(AACDecContext *ac, ChannelElement *cpe);