diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-02-12 01:02:55 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-02-12 01:06:13 +0100 |
commit | cd1c12b5c5b79195140a93d59cbf990d034f61d8 (patch) | |
tree | 1a1ab570f0dddd706a1b995e255272c1c6f9f453 /libavcodec/tta.c | |
parent | 289520fd97395ffd5bf933ac80487e858bc4039d (diff) | |
parent | b498867d6691b5f1f107afd81aff403f66b434aa (diff) | |
download | ffmpeg-cd1c12b5c5b79195140a93d59cbf990d034f61d8.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
FATE: update reference for seek-alac_mp4
sunrast: Return AVERROR values instead of -1.
sunrast: Add support for gray8 decoding.
swscale: enforce a minimum filtersize.
alacenc: use AVCodec.encode2()
alacenc: cosmetics: indentation
alacenc: consolidate bitstream writing into a single function.
alacenc: only encode frame size in header for a final smaller frame
alacenc: store current frame size in AlacEncodeContext.
alacenc: return AVERROR codes in alac_encode_frame()
alacenc: calculate a new max frame size for the final small frame
alacenc: pretty-printing and other cosmetics
alacenc: fix error handling and potential memleaks in alac_encode_init()
alacenc: do not set coded_frame->key_frame
alacenc: do not set bits_per_coded_sample
alacenc: remove unneeded frame_size check in alac_encode_frame()
tta: error out if samplerate is zero.
ttadec: fix invalid free when an error occurs while decoding 24-bit tta
wavpack: add needed braces for 2 statements inside an if block
Conflicts:
tests/ref/acodec/alac
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/tta.c')
-rw-r--r-- | libavcodec/tta.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/libavcodec/tta.c b/libavcodec/tta.c index 8a628a53a3..3f5ab23b1e 100644 --- a/libavcodec/tta.c +++ b/libavcodec/tta.c @@ -235,6 +235,9 @@ static av_cold int tta_decode_init(AVCodecContext * avctx) if (s->channels == 0) { av_log(s->avctx, AV_LOG_ERROR, "Invalid number of channels\n"); return AVERROR_INVALIDDATA; + } else if (avctx->sample_rate == 0) { + av_log(s->avctx, AV_LOG_ERROR, "Invalid samplerate\n"); + return AVERROR_INVALIDDATA; } switch(s->bps) { @@ -354,12 +357,16 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, unary--; } - if (get_bits_left(&s->gb) < k) - return -1; + if (get_bits_left(&s->gb) < k) { + ret = AVERROR_INVALIDDATA; + goto error; + } if (k) { - if (k > MIN_CACHE_BITS) - return -1; + if (k > MIN_CACHE_BITS) { + ret = AVERROR_INVALIDDATA; + goto error; + } value = (unary << k) + get_bits(&s->gb, k); } else value = unary; @@ -412,8 +419,10 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, } } - if (get_bits_left(&s->gb) < 32) - return -1; + if (get_bits_left(&s->gb) < 32) { + ret = AVERROR_INVALIDDATA; + goto error; + } skip_bits_long(&s->gb, 32); // frame crc // convert to output buffer @@ -445,6 +454,11 @@ static int tta_decode_frame(AVCodecContext *avctx, void *data, *(AVFrame *)data = s->frame; return buf_size; +error: + // reset decode buffer + if (s->bps == 3) + s->decode_buffer = NULL; + return ret; } static av_cold int tta_decode_close(AVCodecContext *avctx) { |