aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLynne <dev@lynne.ee>2024-03-16 01:28:41 +0100
committerLynne <dev@lynne.ee>2024-04-23 08:31:35 +0200
commiteef9100a8e57fe9d0642aeb69c82a5abfc01e962 (patch)
tree9a0bd29b922c3281140ea115b702289429bf5854
parent091d85217d82d5ee0f96b4dbc665cb3c598a0451 (diff)
downloadffmpeg-eef9100a8e57fe9d0642aeb69c82a5abfc01e962.tar.gz
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.
-rw-r--r--libavcodec/aac/aacdec_dsp_template.c30
-rw-r--r--libavcodec/aacdec.h6
-rw-r--r--libavcodec/aacdec_template.c28
-rw-r--r--libavcodec/mips/aacdec_mips.c30
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
@@ -238,6 +238,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
*/
static void AAC_RENAME(apply_ltp)(AACDecContext *ac, SingleChannelElement *sce)
@@ -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
@@ -2368,33 +2368,6 @@ static int decode_extension_payload(AACDecContext *ac, GetBitContext *gb, int cn
}
/**
- * 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
*
* @param apply_coupling_method pointer to (in)dependent coupling function
@@ -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);