X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fmace.c;h=980ebb90277d1ee5251afd74255ec9aae61631cf;hb=82a1d575757d5bc9b0b218fe89c77f8de06a7d39;hp=9f8749110eeeaa5a95f15c0852f59e4331f6403e;hpb=3ee83f46058449913abeca7ba82e8e2909828209;p=ffmpeg diff --git a/libavcodec/mace.c b/libavcodec/mace.c index 9f8749110ee..980ebb90277 100644 --- a/libavcodec/mace.c +++ b/libavcodec/mace.c @@ -27,7 +27,7 @@ #include "avcodec.h" /* - * Adapted to ffmpeg by Francois Revol + * Adapted to libavcodec by Francois Revol * (removed 68k REG stuff, changed types, added some statics and consts, * libavcodec api, context stuff, interlaced stereo out). */ @@ -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; }