From 6dc7dd7af45aa1e341b471fd054f85ae2747775b Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Fri, 28 Oct 2011 13:07:20 -0400 Subject: atrac1: check for ff_mdct_init() failure --- libavcodec/atrac1.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'libavcodec/atrac1.c') 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, -- cgit v1.2.3