[FFmpeg-cvslog] aacdec: template LTP windowing separately

Lynne git at videolan.org
Tue Apr 23 09:58:41 EEST 2024


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Sat Mar 16 01:28:41 2024 +0100| [eef9100a8e57fe9d0642aeb69c82a5abfc01e962] | committer: Lynne

aacdec: template LTP windowing separately

The function is called only internally in DSP, so we do not
need to expose it.

apply_ltp on MIPS uses this function, but due to the function
being just a glue function with no real optimizations,
duplicate it there.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eef9100a8e57fe9d0642aeb69c82a5abfc01e962
---

 libavcodec/aac/aacdec_dsp_template.c | 30 +++++++++++++++++++++++++++++-
 libavcodec/aacdec.h                  |  6 ------
 libavcodec/aacdec_template.c         | 28 ----------------------------
 libavcodec/mips/aacdec_mips.c        | 30 +++++++++++++++++++++++++++++-
 4 files changed, 58 insertions(+), 36 deletions(-)

diff --git a/libavcodec/aac/aacdec_dsp_template.c b/libavcodec/aac/aacdec_dsp_template.c
index c607383d67..56c51c3e07 100644
--- a/libavcodec/aac/aacdec_dsp_template.c
+++ b/libavcodec/aac/aacdec_dsp_template.c
@@ -237,6 +237,34 @@ static void AAC_RENAME(apply_tns)(void *_coef_param, TemporalNoiseShaping *tns,
     }
 }
 
+/**
+ *  Apply windowing and MDCT to obtain the spectral
+ *  coefficient from the predicted sample by LTP.
+ */
+static inline void AAC_RENAME(windowing_and_mdct_ltp)(AACDecContext *ac,
+                                                      INTFLOAT *out, INTFLOAT *in,
+                                                      IndividualChannelStream *ics)
+{
+    const INTFLOAT *lwindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
+    const INTFLOAT *swindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
+    const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
+    const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
+
+    if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {
+        ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024);
+    } else {
+        memset(in, 0, 448 * sizeof(*in));
+        ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128);
+    }
+    if (ics->window_sequence[0] != LONG_START_SEQUENCE) {
+        ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
+    } else {
+        ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
+        memset(in + 1024 + 576, 0, 448 * sizeof(*in));
+    }
+    ac->mdct_ltp_fn(ac->mdct_ltp, out, in, sizeof(INTFLOAT));
+}
+
 /**
  * Apply the long term prediction
  */
@@ -257,7 +285,7 @@ static void AAC_RENAME(apply_ltp)(AACDecContext *ac, SingleChannelElement *sce)
             predTime[i] = AAC_MUL30(sce->AAC_RENAME(ltp_state)[i + 2048 - ltp->lag], ltp->AAC_RENAME(coef));
         memset(&predTime[i], 0, (2048 - i) * sizeof(*predTime));
 
-        ac->AAC_RENAME(windowing_and_mdct_ltp)(ac, predFreq, predTime, &sce->ics);
+        AAC_RENAME(windowing_and_mdct_ltp)(ac, predFreq, predTime, &sce->ics);
 
         if (sce->tns.present)
             AAC_RENAME(apply_tns)(predFreq, &sce->tns, &sce->ics, 0);
diff --git a/libavcodec/aacdec.h b/libavcodec/aacdec.h
index a0f8790e17..87462adb02 100644
--- a/libavcodec/aacdec.h
+++ b/libavcodec/aacdec.h
@@ -311,12 +311,6 @@ struct AACDecContext {
     int is_fixed;
 
     /* aacdec functions pointers */
-    union {
-        void (*windowing_and_mdct_ltp)(struct AACDecContext *ac, float *out,
-                                       float *in, IndividualChannelStream *ics);
-        void (*windowing_and_mdct_ltp_fixed)(struct AACDecContext *ac, int *out,
-                                             int *in, IndividualChannelStream *ics);
-    };
     void (*vector_pow43)(int *coefs, int len);
     void (*subband_scale)(int *dst, int *src, int scale, int offset, int len, void *log_context);
 };
diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index 7985a213eb..a8fb8606e1 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -2367,33 +2367,6 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn
     return res;
 }
 
-/**
- *  Apply windowing and MDCT to obtain the spectral
- *  coefficient from the predicted sample by LTP.
- */
-static void windowing_and_mdct_ltp(AACDecContext *ac, INTFLOAT *out,
-                                   INTFLOAT *in, IndividualChannelStream *ics)
-{
-    const INTFLOAT *lwindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
-    const INTFLOAT *swindow      = ics->use_kb_window[0] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
-    const INTFLOAT *lwindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_long_1024) : AAC_RENAME2(sine_1024);
-    const INTFLOAT *swindow_prev = ics->use_kb_window[1] ? AAC_RENAME2(aac_kbd_short_128) : AAC_RENAME2(sine_128);
-
-    if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {
-        ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024);
-    } else {
-        memset(in, 0, 448 * sizeof(*in));
-        ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128);
-    }
-    if (ics->window_sequence[0] != LONG_START_SEQUENCE) {
-        ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
-    } else {
-        ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
-        memset(in + 1024 + 576, 0, 448 * sizeof(*in));
-    }
-    ac->mdct_ltp_fn(ac->mdct_ltp, out, in, sizeof(INTFLOAT));
-}
-
 /**
  * channel coupling transformation interface
  *
@@ -2919,7 +2892,6 @@ static int aac_decode_frame(AVCodecContext *avctx, AVFrame *frame,
 
 static void aacdec_init(AACDecContext *c)
 {
-    c->AAC_RENAME(windowing_and_mdct_ltp)       = windowing_and_mdct_ltp;
 #if USE_FIXED
     c->vector_pow43                             = vector_pow43;
     c->subband_scale                            = subband_scale;
diff --git a/libavcodec/mips/aacdec_mips.c b/libavcodec/mips/aacdec_mips.c
index b9848baaaa..dee135b032 100644
--- a/libavcodec/mips/aacdec_mips.c
+++ b/libavcodec/mips/aacdec_mips.c
@@ -224,6 +224,34 @@ static void imdct_and_windowing_mips(AACDecContext *ac, SingleChannelElement *sc
     }
 }
 
+/**
+ *  Apply windowing and MDCT to obtain the spectral
+ *  coefficient from the predicted sample by LTP.
+ */
+static inline void windowing_and_mdct_ltp(AACDecContext *ac,
+                                          float *out, float *in,
+                                          IndividualChannelStream *ics)
+{
+    const float *lwindow      = ics->use_kb_window[0] ? ff_aac_kbd_long_1024) : ff_sine_1024;
+    const float *swindow      = ics->use_kb_window[0] ? ff_aac_kbd_short_128) : ff_sine_128;
+    const float *lwindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_long_1024) : ff_sine_1024;
+    const float *swindow_prev = ics->use_kb_window[1] ? ff_aac_kbd_short_128) : ff_sine_128;
+
+    if (ics->window_sequence[0] != LONG_STOP_SEQUENCE) {
+        ac->fdsp->vector_fmul(in, in, lwindow_prev, 1024);
+    } else {
+        memset(in, 0, 448 * sizeof(*in));
+        ac->fdsp->vector_fmul(in + 448, in + 448, swindow_prev, 128);
+    }
+    if (ics->window_sequence[0] != LONG_START_SEQUENCE) {
+        ac->fdsp->vector_fmul_reverse(in + 1024, in + 1024, lwindow, 1024);
+    } else {
+        ac->fdsp->vector_fmul_reverse(in + 1024 + 448, in + 1024 + 448, swindow, 128);
+        memset(in + 1024 + 576, 0, 448 * sizeof(*in));
+    }
+    ac->mdct_ltp_fn(ac->mdct_ltp, out, in, sizeof(INTFLOAT));
+}
+
 static void apply_ltp_mips(AACDecContext *ac, SingleChannelElement *sce)
 {
     const LongTermPrediction *ltp = &sce->ics.ltp;
@@ -272,7 +300,7 @@ static void apply_ltp_mips(AACDecContext *ac, SingleChannelElement *sce)
             );
         }
 
-        ac->windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics);
+        windowing_and_mdct_ltp(ac, predFreq, predTime, &sce->ics);
 
         if (sce->tns.present)
             ac->dsp.apply_tns(predFreq, &sce->tns, &sce->ics, 0);



More information about the ffmpeg-cvslog mailing list