[FFmpeg-cvslog] nellymoserdec: allocate float_buf only when decoding to int16

Justin Ruggles git at videolan.org
Mon Oct 3 01:17:04 CEST 2011


ffmpeg | branch: master | Justin Ruggles <justin.ruggles at gmail.com> | Wed Sep 14 12:37:01 2011 -0400| [fac6b7f9f22d4fc3a275af7af9d9754356d48d89] | committer: Justin Ruggles

nellymoserdec: allocate float_buf only when decoding to int16

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

 libavcodec/nellymoserdec.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index d7d1aba..2d59abf 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -47,7 +47,7 @@
 
 typedef struct NellyMoserDecodeContext {
     AVCodecContext* avctx;
-    DECLARE_ALIGNED(32, float, float_buf)[NELLY_SAMPLES];
+    float          *float_buf;
     float           state[NELLY_BUF_LEN];
     AVLFG           random_state;
     GetBitContext   gb;
@@ -145,6 +145,11 @@ static av_cold int decode_init(AVCodecContext * avctx) {
         s->scale_bias = 1.0/(1*8);
         avctx->sample_fmt = AV_SAMPLE_FMT_S16;
         ff_fmt_convert_init(&s->fmt_conv, avctx);
+        s->float_buf = av_mallocz(NELLY_SAMPLES * sizeof(*s->float_buf));
+        if (!s->float_buf) {
+            av_log(avctx, AV_LOG_ERROR, "error allocating float buffer\n");
+            return AVERROR(ENOMEM);
+        }
     }
 
     /* Generate overlap window */
@@ -208,6 +213,7 @@ static int decode_tag(AVCodecContext * avctx,
 static av_cold int decode_end(AVCodecContext * avctx) {
     NellyMoserDecodeContext *s = avctx->priv_data;
 
+    av_freep(&s->float_buf);
     ff_mdct_end(&s->imdct_ctx);
     return 0;
 }



More information about the ffmpeg-cvslog mailing list