[FFmpeg-devel] [PATCH 12/12] avcodec/aac/aacdec_(fixed|float): Set AACDecDSP, AACDecProc directly

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Mon May 6 15:14:34 EEST 2024


This is more in line with how we initialize DSP functions
and avoids tables of function pointers as well as relocations
for these.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
---
 libavcodec/aac/aacdec_dsp_template.c  | 43 ++++++++++++++-------------
 libavcodec/aac/aacdec_fixed.c         |  4 +--
 libavcodec/aac/aacdec_float.c         |  4 +--
 libavcodec/aac/aacdec_proc_template.c | 11 ++++---
 4 files changed, 34 insertions(+), 28 deletions(-)

diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c
index 70f0a3cce6..621baef8ca 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -615,23 +615,26 @@ static void AAC_RENAME(apply_prediction)(AACDecContext *ac, SingleChannelElement
         reset_all_predictors(sce->AAC_RENAME(predictor_state));
 }
 
-static const AACDecDSP AAC_RENAME(aac_dsp) = {
-    .dequant_scalefactors = &AAC_RENAME(dequant_scalefactors),
-    .apply_mid_side_stereo = &AAC_RENAME(apply_mid_side_stereo),
-    .apply_intensity_stereo = &AAC_RENAME(apply_intensity_stereo),
-    .apply_tns = &AAC_RENAME(apply_tns),
-    .apply_ltp = &AAC_RENAME(apply_ltp),
-    .update_ltp = &AAC_RENAME(update_ltp),
-
-    .apply_prediction = AAC_RENAME(apply_prediction),
-
-    .imdct_and_windowing = AAC_RENAME(imdct_and_windowing),
-    .imdct_and_windowing_960 = AAC_RENAME(imdct_and_windowing_960),
-    .imdct_and_windowing_ld = AAC_RENAME(imdct_and_windowing_ld),
-    .imdct_and_windowing_eld = AAC_RENAME(imdct_and_windowing_eld),
-
-    .apply_dependent_coupling = AAC_RENAME(apply_dependent_coupling),
-    .apply_independent_coupling = AAC_RENAME(apply_independent_coupling),
-
-    .clip_output = AAC_RENAME(clip_output),
-};
+static av_cold void AAC_RENAME(aac_dsp_init)(AACDecDSP *aac_dsp)
+{
+#define SET(member) aac_dsp->member = AAC_RENAME(member)
+    SET(dequant_scalefactors);
+    SET(apply_mid_side_stereo);
+    SET(apply_intensity_stereo);
+    SET(apply_tns);
+    SET(apply_ltp);
+    SET(update_ltp);
+
+    SET(apply_prediction);
+
+    SET(imdct_and_windowing);
+    SET(imdct_and_windowing_960);
+    SET(imdct_and_windowing_ld);
+    SET(imdct_and_windowing_eld);
+
+    SET(apply_dependent_coupling);
+    SET(apply_independent_coupling);
+
+    SET(clip_output);
+#undef SET
+}
diff --git a/libavcodec/aac/aacdec_fixed.c b/libavcodec/aac/aacdec_fixed.c
index 79d35e05fb..de90880884 100644
--- a/libavcodec/aac/aacdec_fixed.c
+++ b/libavcodec/aac/aacdec_fixed.c
@@ -90,8 +90,8 @@ av_cold int ff_aac_decode_init_fixed(AVCodecContext *avctx)
     ac->is_fixed = 1;
     avctx->sample_fmt = AV_SAMPLE_FMT_S32P;
 
-    ac->dsp  = aac_dsp_fixed;
-    ac->proc = aac_proc_fixed;
+    aac_dsp_init_fixed(&ac->dsp);
+    aac_proc_init_fixed(&ac->proc);
 
     ac->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!ac->fdsp)
diff --git a/libavcodec/aac/aacdec_float.c b/libavcodec/aac/aacdec_float.c
index d48a21eef2..885d824fa7 100644
--- a/libavcodec/aac/aacdec_float.c
+++ b/libavcodec/aac/aacdec_float.c
@@ -160,8 +160,8 @@ av_cold int ff_aac_decode_init_float(AVCodecContext *avctx)
     ac->is_fixed = 0;
     avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
 
-    ac->dsp  = aac_dsp;
-    ac->proc = aac_proc;
+    aac_dsp_init(&ac->dsp);
+    aac_proc_init(&ac->proc);
 
     ac->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
     if (!ac->fdsp)
diff --git a/libavcodec/aac/aacdec_proc_template.c b/libavcodec/aac/aacdec_proc_template.c
index 1ffea2f93b..fecf228b3b 100644
--- a/libavcodec/aac/aacdec_proc_template.c
+++ b/libavcodec/aac/aacdec_proc_template.c
@@ -433,7 +433,10 @@ static int AAC_RENAME(decode_cce)(AACDecContext *ac, GetBitContext *gb, ChannelE
     return 0;
 }
 
-static const AACDecProc AAC_RENAME(aac_proc) = {
-    .decode_spectrum_and_dequant = AAC_RENAME(decode_spectrum_and_dequant),
-    .decode_cce = AAC_RENAME(decode_cce),
-};
+static av_cold void AAC_RENAME(aac_proc_init)(AACDecProc *aac_proc)
+{
+#define SET(member) aac_proc->member = AAC_RENAME(member)
+    SET(decode_spectrum_and_dequant);
+    SET(decode_cce);
+#undef SET
+}
-- 
2.40.1



More information about the ffmpeg-devel mailing list