diff options
author | Justin Ruggles <justin.ruggles@gmail.com> | 2011-10-28 21:27:36 -0400 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2011-11-08 12:36:14 -0500 |
commit | f50b6be57d2e68823a690c5a98639e1ac73bbd3e (patch) | |
tree | b9a31fc5f68b97dc4d6146d8637510f449b0f3c4 /libavcodec | |
parent | ce33320b30f27b221d140196f7107e3eccf80568 (diff) | |
download | ffmpeg-f50b6be57d2e68823a690c5a98639e1ac73bbd3e.tar.gz |
mace: only calculate output buffer size once
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/mace.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/libavcodec/mace.c b/libavcodec/mace.c index 5e870a2d2e..a55a041696 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -243,11 +243,14 @@ static int mace_decode_frame(AVCodecContext *avctx, int16_t *samples = data; MACEContext *ctx = avctx->priv_data; int i, j, k, l; + int out_size; int is_mace3 = (avctx->codec_id == CODEC_ID_MACE3); - if (*data_size < (3 * buf_size << (2-is_mace3))) { - av_log(avctx, AV_LOG_ERROR, "Output buffer too small!\n"); - return -1; + out_size = 3 * (buf_size << (1 - is_mace3)) * + av_get_bytes_per_sample(avctx->sample_fmt); + if (*data_size < out_size) { + av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); + return AVERROR(EINVAL); } for(i = 0; i < avctx->channels; i++) { @@ -274,7 +277,7 @@ static int mace_decode_frame(AVCodecContext *avctx, } } - *data_size = 3 * buf_size << (2-is_mace3); + *data_size = out_size; return buf_size; } |