diff mbox series

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

Message ID GV1P250MB0737EB6EC07077A3AF15355A8F1C2@GV1P250MB0737.EURP250.PROD.OUTLOOK.COM
State Accepted
Commit f5d2dc7b4bd2430c7a3d977b22bd20ef3508505c
Headers show
Series [FFmpeg-devel,1/3] avcodec/aactab: Provide ff_ltp_coef, ff_tns_tmp2_map unconditionally | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt May 6, 2024, 12:14 p.m. UTC
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@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(-)

Comments

Lynne May 6, 2024, 5:59 p.m. UTC | #1
May 6, 2024, 14:16 by andreas.rheinhardt@outlook.com:

> 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@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(-)
>

Nice
Patch 4 to 12 LGTM
diff mbox series

Patch

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
+}