]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/mpegaudiodec_float: Avoid indirection with float dsp function
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 15 Sep 2020 06:16:13 +0000 (08:16 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 19 Sep 2020 16:48:38 +0000 (18:48 +0200)
Do this by only keeping the only function pointer from the
AVFloatDSPContext that is needed lateron. This also allows to remove the
decoders' close function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/mpegaudiodec_float.c
libavcodec/mpegaudiodec_template.c

index ddfa5e0daaa28db98afb5b4c5d3e57ea8225bb45..0defdf3af16ffbe01262fd4fb53c50e93617be11 100644 (file)
@@ -46,7 +46,6 @@ AVCodec ff_mp1float_decoder = {
     .id             = AV_CODEC_ID_MP1,
     .priv_data_size = sizeof(MPADecodeContext),
     .init           = decode_init,
-    .close          = decode_close,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
     .flush          = flush,
@@ -64,7 +63,6 @@ AVCodec ff_mp2float_decoder = {
     .priv_data_size = sizeof(MPADecodeContext),
     .init           = decode_init,
     .decode         = decode_frame,
-    .close          = decode_close,
     .capabilities   = AV_CODEC_CAP_DR1,
     .flush          = flush,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
@@ -80,7 +78,6 @@ AVCodec ff_mp3float_decoder = {
     .id             = AV_CODEC_ID_MP3,
     .priv_data_size = sizeof(MPADecodeContext),
     .init           = decode_init,
-    .close          = decode_close,
     .decode         = decode_frame,
     .capabilities   = AV_CODEC_CAP_DR1,
     .flush          = flush,
@@ -97,7 +94,6 @@ AVCodec ff_mp3adufloat_decoder = {
     .id             = AV_CODEC_ID_MP3ADU,
     .priv_data_size = sizeof(MPADecodeContext),
     .init           = decode_init,
-    .close          = decode_close,
     .decode         = decode_frame_adu,
     .capabilities   = AV_CODEC_CAP_DR1,
     .flush          = flush,
index 98759b8e01e6a5e048a71adc4d2eed24dc41f7e0..d2b72497e10a25e47f0feccd6901736e68f06e6f 100644 (file)
@@ -87,7 +87,7 @@ typedef struct MPADecodeContext {
     int err_recognition;
     AVCodecContext* avctx;
     MPADSPContext mpadsp;
-    AVFloatDSPContext *fdsp;
+    void (*butterflies_float)(float *av_restrict v1, float *av_restrict v2, int len);
     AVFrame *frame;
     uint32_t crc;
 } MPADecodeContext;
@@ -410,16 +410,6 @@ static av_cold void decode_init_static(void)
     }
 }
 
-#if USE_FLOATS
-static av_cold int decode_close(AVCodecContext * avctx)
-{
-    MPADecodeContext *s = avctx->priv_data;
-    av_freep(&s->fdsp);
-
-    return 0;
-}
-#endif
-
 static av_cold int decode_init(AVCodecContext * avctx)
 {
     static int initialized_tables = 0;
@@ -433,9 +423,14 @@ static av_cold int decode_init(AVCodecContext * avctx)
     s->avctx = avctx;
 
 #if USE_FLOATS
-    s->fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
-    if (!s->fdsp)
-        return AVERROR(ENOMEM);
+    {
+        AVFloatDSPContext *fdsp;
+        fdsp = avpriv_float_dsp_alloc(avctx->flags & AV_CODEC_FLAG_BITEXACT);
+        if (!fdsp)
+            return AVERROR(ENOMEM);
+        s->butterflies_float = fdsp->butterflies_float;
+        av_free(fdsp);
+    }
 #endif
 
     ff_mpadsp_init(&s->mpadsp);
@@ -1188,7 +1183,7 @@ found2:
         /* NOTE: the 1/sqrt(2) normalization factor is included in the
            global gain */
 #if USE_FLOATS
-       s->fdsp->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
+       s->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
 #else
         tab0 = g0->sb_hybrid;
         tab1 = g1->sb_hybrid;
@@ -1871,9 +1866,6 @@ static av_cold int decode_close_mp3on4(AVCodecContext * avctx)
     MP3On4DecodeContext *s = avctx->priv_data;
     int i;
 
-    if (s->mp3decctx[0])
-        av_freep(&s->mp3decctx[0]->fdsp);
-
     for (i = 0; i < s->frames; i++)
         av_freep(&s->mp3decctx[i]);
 
@@ -1938,7 +1930,7 @@ static av_cold int decode_init_mp3on4(AVCodecContext * avctx)
         s->mp3decctx[i]->adu_mode = 1;
         s->mp3decctx[i]->avctx = avctx;
         s->mp3decctx[i]->mpadsp = s->mp3decctx[0]->mpadsp;
-        s->mp3decctx[i]->fdsp = s->mp3decctx[0]->fdsp;
+        s->mp3decctx[i]->butterflies_float = s->mp3decctx[0]->butterflies_float;
     }
 
     return 0;