Browse code

avcodec/mpegaudiodec_float: Use avpriv_float_dsp_alloc()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/12/03 22:43:40
Showing 2 changed files
... ...
@@ -46,6 +46,7 @@ AVCodec ff_mp1float_decoder = {
46 46
     .id             = AV_CODEC_ID_MP1,
47 47
     .priv_data_size = sizeof(MPADecodeContext),
48 48
     .init           = decode_init,
49
+    .close          = decode_close,
49 50
     .decode         = decode_frame,
50 51
     .capabilities   = CODEC_CAP_DR1,
51 52
     .flush          = flush,
... ...
@@ -63,6 +64,7 @@ AVCodec ff_mp2float_decoder = {
63 63
     .priv_data_size = sizeof(MPADecodeContext),
64 64
     .init           = decode_init,
65 65
     .decode         = decode_frame,
66
+    .close          = decode_close,
66 67
     .capabilities   = CODEC_CAP_DR1,
67 68
     .flush          = flush,
68 69
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
... ...
@@ -78,6 +80,7 @@ AVCodec ff_mp3float_decoder = {
78 78
     .id             = AV_CODEC_ID_MP3,
79 79
     .priv_data_size = sizeof(MPADecodeContext),
80 80
     .init           = decode_init,
81
+    .close          = decode_close,
81 82
     .decode         = decode_frame,
82 83
     .capabilities   = CODEC_CAP_DR1,
83 84
     .flush          = flush,
... ...
@@ -94,6 +97,7 @@ AVCodec ff_mp3adufloat_decoder = {
94 94
     .id             = AV_CODEC_ID_MP3ADU,
95 95
     .priv_data_size = sizeof(MPADecodeContext),
96 96
     .init           = decode_init,
97
+    .close          = decode_close,
97 98
     .decode         = decode_frame_adu,
98 99
     .capabilities   = CODEC_CAP_DR1,
99 100
     .flush          = flush,
... ...
@@ -85,7 +85,7 @@ typedef struct MPADecodeContext {
85 85
     int err_recognition;
86 86
     AVCodecContext* avctx;
87 87
     MPADSPContext mpadsp;
88
-    AVFloatDSPContext fdsp;
88
+    AVFloatDSPContext *fdsp;
89 89
     AVFrame *frame;
90 90
 } MPADecodeContext;
91 91
 
... ...
@@ -406,6 +406,16 @@ static av_cold void decode_init_static(void)
406 406
     }
407 407
 }
408 408
 
409
+#if USE_FLOATS
410
+static av_cold int decode_close(AVCodecContext * avctx)
411
+{
412
+    MPADecodeContext *s = avctx->priv_data;
413
+    av_freep(&s->fdsp);
414
+
415
+    return 0;
416
+}
417
+#endif
418
+
409 419
 static av_cold int decode_init(AVCodecContext * avctx)
410 420
 {
411 421
     static int initialized_tables = 0;
... ...
@@ -418,7 +428,10 @@ static av_cold int decode_init(AVCodecContext * avctx)
418 418
 
419 419
     s->avctx = avctx;
420 420
 
421
-    avpriv_float_dsp_init(&s->fdsp, avctx->flags & CODEC_FLAG_BITEXACT);
421
+    s->fdsp = avpriv_float_dsp_alloc(avctx->flags & CODEC_FLAG_BITEXACT);
422
+    if (!s->fdsp)
423
+        return AVERROR(ENOMEM);
424
+
422 425
     ff_mpadsp_init(&s->mpadsp);
423 426
 
424 427
     if (avctx->request_sample_fmt == OUT_FMT &&
... ...
@@ -1138,7 +1151,7 @@ found2:
1138 1138
         /* NOTE: the 1/sqrt(2) normalization factor is included in the
1139 1139
            global gain */
1140 1140
 #if USE_FLOATS
1141
-       s->fdsp.butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
1141
+       s->fdsp->butterflies_float(g0->sb_hybrid, g1->sb_hybrid, 576);
1142 1142
 #else
1143 1143
         tab0 = g0->sb_hybrid;
1144 1144
         tab1 = g1->sb_hybrid;