[FFmpeg-cvslog] avcodec/ra288: Avoid indirection when calling float dsp function

Andreas Rheinhardt git at videolan.org
Thu Sep 17 01:10:30 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Sep 13 00:09:18 2020 +0200| [d3737bde639998f5a021e6fc00547ca2a7b28798] | committer: Andreas Rheinhardt

avcodec/ra288: Avoid indirection when calling float dsp function

Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoder's close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/ra288.c | 24 +++++++++---------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/libavcodec/ra288.c b/libavcodec/ra288.c
index aa4bd5d90f..8df17891b1 100644
--- a/libavcodec/ra288.c
+++ b/libavcodec/ra288.c
@@ -39,7 +39,8 @@
 #define RA288_BLOCKS_PER_FRAME 32
 
 typedef struct RA288Context {
-    AVFloatDSPContext *fdsp;
+    void (*vector_fmul)(float *dst, const float *src0, const float *src1,
+                        int len);
     DECLARE_ALIGNED(32, float,   sp_lpc)[FFALIGN(36, 16)];   ///< LPC coefficients for speech data (spec: A)
     DECLARE_ALIGNED(32, float, gain_lpc)[FFALIGN(10, 16)];   ///< LPC coefficients for gain        (spec: GB)
 
@@ -60,18 +61,10 @@ typedef struct RA288Context {
     float gain_rec[11];
 } RA288Context;
 
-static av_cold int ra288_decode_close(AVCodecContext *avctx)
-{
-    RA288Context *ractx = avctx->priv_data;
-
-    av_freep(&ractx->fdsp);
-
-    return 0;
-}
-
 static av_cold int ra288_decode_init(AVCodecContext *avctx)
 {
     RA288Context *ractx = avctx->priv_data;
+    AVFloatDSPContext *fdsp;
 
     avctx->channels       = 1;
     avctx->channel_layout = AV_CH_LAYOUT_MONO;
@@ -82,9 +75,11 @@ static av_cold int ra288_decode_init(AVCodecContext *avctx)
         return AVERROR_PATCHWELCOME;
     }
 
-    ractx->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
-    if (!ractx->fdsp)
+    fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+    if (!fdsp)
         return AVERROR(ENOMEM);
+    ractx->vector_fmul = fdsp->vector_fmul;
+    av_free(fdsp);
 
     return 0;
 }
@@ -158,7 +153,7 @@ static void do_hybrid_window(RA288Context *ractx,
 
     av_assert2(order>=0);
 
-    ractx->fdsp->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
+    ractx->vector_fmul(work, window, hist, FFALIGN(order + n + non_rec, 16));
 
     convolve(buffer1, work + order    , n      , order);
     convolve(buffer2, work + order + n, non_rec, order);
@@ -185,7 +180,7 @@ static void backward_filter(RA288Context *ractx,
     do_hybrid_window(ractx, order, n, non_rec, temp, hist, rec, window);
 
     if (!compute_lpc_coefs(temp, order, lpc, 0, 1, 1))
-        ractx->fdsp->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
+        ractx->vector_fmul(lpc, lpc, tab, FFALIGN(order, 16));
 
     memmove(hist, hist + n, move_size*sizeof(*hist));
 }
@@ -249,6 +244,5 @@ AVCodec ff_ra_288_decoder = {
     .priv_data_size = sizeof(RA288Context),
     .init           = ra288_decode_init,
     .decode         = ra288_decode_frame,
-    .close          = ra288_decode_close,
     .capabilities   = AV_CODEC_CAP_DR1,
 };



More information about the ffmpeg-cvslog mailing list