diff mbox series

[FFmpeg-devel,21/40] avcodec/atrac1: Avoid indirection when calling float dsp function

Message ID 20200914052747.124118-5-andreas.rheinhardt@gmail.com
State Accepted
Commit 04101222f23fef3af57ac2cf1b8835f350fd4e50
Headers show
Series [FFmpeg-devel,01/16] avcodec/snowdec: Use ff_snow_common_init() directly | expand

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Andreas Rheinhardt Sept. 14, 2020, 5:27 a.m. UTC
Do this by only keeping the only function pointer from
the AVFloatDSPContext that is needed lateron.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavcodec/atrac1.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index 4cfb1061c5..b2a2d5e6a1 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -80,7 +80,8 @@  typedef struct AT1Ctx {
     DECLARE_ALIGNED(32, float, high)[512];
     float*              bands[3];
     FFTContext          mdct_ctx[3];
-    AVFloatDSPContext   *fdsp;
+    void (*vector_fmul_window)(float *dst, const float *src0,
+                               const float *src1, const float *win, int len);
 } AT1Ctx;
 
 /** size of the transform in samples in the long mode for each QMF band */
@@ -140,8 +141,8 @@  static int at1_imdct_block(AT1SUCtx* su, AT1Ctx *q)
             at1_imdct(q, &q->spec[pos], &su->spectrum[0][ref_pos + start_pos], nbits, band_num);
 
             /* overlap and window */
-            q->fdsp->vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
-                                       &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
+            q->vector_fmul_window(&q->bands[band_num][start_pos], prev_buf,
+                                  &su->spectrum[0][ref_pos + start_pos], ff_sine_32, 16);
 
             prev_buf = &su->spectrum[0][ref_pos+start_pos + 16];
             start_pos += block_size;
@@ -324,8 +325,6 @@  static av_cold int atrac1_decode_end(AVCodecContext * avctx)
     ff_mdct_end(&q->mdct_ctx[1]);
     ff_mdct_end(&q->mdct_ctx[2]);
 
-    av_freep(&q->fdsp);
-
     return 0;
 }
 
@@ -333,6 +332,7 @@  static av_cold int atrac1_decode_end(AVCodecContext * avctx)
 static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 {
     AT1Ctx *q = avctx->priv_data;
+    AVFloatDSPContext *fdsp;
     int ret;
 
     avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
@@ -360,10 +360,11 @@  static av_cold int atrac1_decode_init(AVCodecContext *avctx)
 
     ff_atrac_generate_tables();
 
-    q->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
-    if (!q->fdsp) {
+    fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+    if (!fdsp)
         return AVERROR(ENOMEM);
-    }
+    q->vector_fmul_window = fdsp->vector_fmul_window;
+    av_free(fdsp);
 
     q->bands[0] = q->low;
     q->bands[1] = q->mid;