diff options
author | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-09-15 08:16:13 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@gmail.com> | 2020-09-19 18:48:38 +0200 |
commit | e9831b1e985a61f1f0089eccc877f2e5add2d58c (patch) | |
tree | b58f6ef1e33ec051cafa653cf95aca015dd335f1 /libavcodec/mpegaudiodec_template.c | |
parent | dac9e88a99ea34c2f812b8f7b6781a84ac86360a (diff) | |
download | ffmpeg-e9831b1e985a61f1f0089eccc877f2e5add2d58c.tar.gz |
avcodec/mpegaudiodec_float: Avoid indirection with 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
decoders' close function.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpegaudiodec_template.c')
-rw-r--r-- | libavcodec/mpegaudiodec_template.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/libavcodec/mpegaudiodec_template.c b/libavcodec/mpegaudiodec_template.c index 98759b8e01..d2b72497e1 100644 --- a/libavcodec/mpegaudiodec_template.c +++ b/libavcodec/mpegaudiodec_template.c @@ -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; |