aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-10-28 13:07:20 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2011-10-29 15:06:31 -0400
commit6dc7dd7af45aa1e341b471fd054f85ae2747775b (patch)
treed61cde5ca48e1a1640f2d279bd8dd80890175ecd
parent21dcecc310e701d035b6a877139b9dd8e2a82a1a (diff)
downloadffmpeg-6dc7dd7af45aa1e341b471fd054f85ae2747775b.tar.gz
atrac1: check for ff_mdct_init() failure
-rw-r--r--libavcodec/atrac1.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/libavcodec/atrac1.c b/libavcodec/atrac1.c
index c646ba9fc1..3f42deaa7e 100644
--- a/libavcodec/atrac1.c
+++ b/libavcodec/atrac1.c
@@ -326,9 +326,24 @@ static int atrac1_decode_frame(AVCodecContext *avctx, void *data,
}
+static av_cold int atrac1_decode_end(AVCodecContext * avctx)
+{
+ AT1Ctx *q = avctx->priv_data;
+
+ av_freep(&q->out_samples[0]);
+
+ ff_mdct_end(&q->mdct_ctx[0]);
+ ff_mdct_end(&q->mdct_ctx[1]);
+ ff_mdct_end(&q->mdct_ctx[2]);
+
+ return 0;
+}
+
+
static av_cold int atrac1_decode_init(AVCodecContext *avctx)
{
AT1Ctx *q = avctx->priv_data;
+ int ret;
avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
@@ -349,9 +364,13 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
}
/* Init the mdct transforms */
- ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15));
- ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15));
- ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15));
+ if ((ret = ff_mdct_init(&q->mdct_ctx[0], 6, 1, -1.0/ (1 << 15))) ||
+ (ret = ff_mdct_init(&q->mdct_ctx[1], 8, 1, -1.0/ (1 << 15))) ||
+ (ret = ff_mdct_init(&q->mdct_ctx[2], 9, 1, -1.0/ (1 << 15)))) {
+ av_log(avctx, AV_LOG_ERROR, "Error initializing MDCT\n");
+ atrac1_decode_end(avctx);
+ return ret;
+ }
ff_init_ff_sine_windows(5);
@@ -374,18 +393,6 @@ static av_cold int atrac1_decode_init(AVCodecContext *avctx)
}
-static av_cold int atrac1_decode_end(AVCodecContext * avctx) {
- AT1Ctx *q = avctx->priv_data;
-
- av_freep(&q->out_samples[0]);
-
- ff_mdct_end(&q->mdct_ctx[0]);
- ff_mdct_end(&q->mdct_ctx[1]);
- ff_mdct_end(&q->mdct_ctx[2]);
- return 0;
-}
-
-
AVCodec ff_atrac1_decoder = {
.name = "atrac1",
.type = AVMEDIA_TYPE_AUDIO,