From cdea393093ebe10ac2222739d480aeb2f6a0bcc8 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt Date: Sun, 22 Nov 2020 14:27:45 +0100 Subject: avcodec/aacdec, sinewin: Move 120 and 960 point sine tables to aacdec The floating point AAC decoder is the only user of these tables, so it makes sense to move them there. Furthermore, initializing the ordinary power-of-two sinetables is currently not thread-safe and if the 120- and 960-point sinetables were not moved, one would have to choose whether to guard initializing these two tables with their own AVOnces or not. Doing so would add unnecessary AVOnces as the AAC decoder already guards initializing its static data by an AVOnce; not doing so would be fragile if a second user of these tables were to be added. Signed-off-by: Andreas Rheinhardt --- libavcodec/aacdec.c | 3 +++ libavcodec/aacdec_template.c | 10 +++++----- libavcodec/sinewin.h | 5 ----- libavcodec/sinewin_tablegen.h | 4 ---- libavcodec/sinewin_tablegen_template.c | 2 -- 5 files changed, 8 insertions(+), 16 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/aacdec.c b/libavcodec/aacdec.c index d17852d8ba..fd4805f6eb 100644 --- a/libavcodec/aacdec.c +++ b/libavcodec/aacdec.c @@ -69,6 +69,9 @@ # include "mips/aacdec_mips.h" #endif +DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(sine_120))[120]; +DECLARE_ALIGNED(32, static INTFLOAT, AAC_RENAME(sine_960))[960]; + static av_always_inline void reset_predict_state(PredictorState *ps) { ps->r0 = 0.0f; diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c index 186175e6e6..e6fe913a27 100644 --- a/libavcodec/aacdec_template.c +++ b/libavcodec/aacdec_template.c @@ -1235,8 +1235,8 @@ static av_cold void aac_static_table_init(void) #if !USE_FIXED AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_long_960), 4.0, 960); AAC_RENAME(ff_kbd_window_init)(AAC_RENAME(ff_aac_kbd_short_120), 6.0, 120); - AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_960), 960); - AAC_RENAME(ff_sine_window_init)(AAC_RENAME(ff_sine_120), 120); + AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_960), 960); + AAC_RENAME(ff_sine_window_init)(AAC_RENAME(sine_120), 120); #endif AAC_RENAME(ff_init_ff_sine_windows)(10); AAC_RENAME(ff_init_ff_sine_windows)( 9); @@ -2810,9 +2810,9 @@ static void imdct_and_windowing_960(AACContext *ac, SingleChannelElement *sce) INTFLOAT *in = sce->coeffs; INTFLOAT *out = sce->ret; INTFLOAT *saved = sce->saved; - const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_120) : AAC_RENAME(ff_sine_120); - const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_long_960) : AAC_RENAME(ff_sine_960); - const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_short_120) : AAC_RENAME(ff_sine_120); + const INTFLOAT *swindow = ics->use_kb_window[0] ? AAC_RENAME(ff_aac_kbd_short_120) : AAC_RENAME(sine_120); + const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_long_960) : AAC_RENAME(sine_960); + const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME(ff_aac_kbd_short_120) : AAC_RENAME(sine_120); INTFLOAT *buf = ac->buf_mdct; INTFLOAT *temp = ac->temp; int i; diff --git a/libavcodec/sinewin.h b/libavcodec/sinewin.h index 329e9bb5be..7b64096a71 100644 --- a/libavcodec/sinewin.h +++ b/libavcodec/sinewin.h @@ -38,9 +38,6 @@ #define SINETABLE(size) \ SINETABLE_CONST DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size] -#define SINETABLE120960(size) \ - DECLARE_ALIGNED(32, INTFLOAT, AAC_RENAME(ff_sine_##size))[size] - /** * Generate a sine window. * @param window pointer to half window @@ -55,11 +52,9 @@ void AAC_RENAME(ff_init_ff_sine_windows)(int index); extern SINETABLE( 32); extern SINETABLE( 64); -extern SINETABLE120960(120); extern SINETABLE( 128); extern SINETABLE( 256); extern SINETABLE( 512); -extern SINETABLE120960(960); extern SINETABLE(1024); extern SINETABLE(2048); extern SINETABLE(4096); diff --git a/libavcodec/sinewin_tablegen.h b/libavcodec/sinewin_tablegen.h index 3c11cb6282..1959074189 100644 --- a/libavcodec/sinewin_tablegen.h +++ b/libavcodec/sinewin_tablegen.h @@ -31,10 +31,6 @@ #include "libavutil/attributes.h" #include "libavutil/common.h" -#if !USE_FIXED -SINETABLE120960(120); -SINETABLE120960(960); -#endif #if !CONFIG_HARDCODED_TABLES SINETABLE( 32); SINETABLE( 64); diff --git a/libavcodec/sinewin_tablegen_template.c b/libavcodec/sinewin_tablegen_template.c index b8eb407bd8..43ce1ba82e 100644 --- a/libavcodec/sinewin_tablegen_template.c +++ b/libavcodec/sinewin_tablegen_template.c @@ -33,8 +33,6 @@ #define SINETABLE_CONST #define SINETABLE(size) \ INTFLOAT AAC_RENAME(ff_sine_##size)[size] -#define SINETABLE120960(size) \ - INTFLOAT AAC_RENAME(ff_sine_##size)[size] #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) #include "sinewin_tablegen.h" #include "tableprint.h" -- cgit v1.2.3