aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2012-07-09 15:38:58 -0400
committerJustin Ruggles <justin.ruggles@gmail.com>2012-07-19 13:26:48 -0400
commitcd632619d954c653add4b4f1820e7d3488a5c9a7 (patch)
treef103f808c9e9faa3e2d6e8f1a6111279bd996891
parent73dc0db486b826e1442ae4e4177b4e3724b06a4e (diff)
downloadffmpeg-cd632619d954c653add4b4f1820e7d3488a5c9a7.tar.gz
alac: support a read sample size of up to 32
Use get_bits_long() in decode_scalar(). Use unsigned int for decoded value.
-rw-r--r--libavcodec/alac.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libavcodec/alac.c b/libavcodec/alac.c
index 5f2c8a0492..b44b5c44ba 100644
--- a/libavcodec/alac.c
+++ b/libavcodec/alac.c
@@ -78,13 +78,14 @@ typedef struct {
int nb_samples; /**< number of samples in the current frame */
} ALACContext;
-static inline int decode_scalar(GetBitContext *gb, int k, int readsamplesize)
+static inline unsigned int decode_scalar(GetBitContext *gb, int k,
+ int readsamplesize)
{
- int x = get_unary_0_9(gb);
+ unsigned int x = get_unary_0_9(gb);
if (x > 8) { /* RICE THRESHOLD */
/* use alternative encoding */
- x = get_bits(gb, readsamplesize);
+ x = get_bits_long(gb, readsamplesize);
} else if (k != 1) {
int extrabits = show_bits(gb, k);
@@ -111,7 +112,8 @@ static void bastardized_rice_decompress(ALACContext *alac,
int sign_modifier = 0;
for (output_count = 0; output_count < output_size; output_count++) {
- int x, k;
+ int k;
+ unsigned int x;
/* read k, that is bits as is */
k = av_log2((history >> 9) + 3);
@@ -294,6 +296,11 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
hassize = get_bits1(&alac->gb);
alac->extra_bits = get_bits(&alac->gb, 2) << 3;
+ readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
+ if (readsamplesize > 32) {
+ av_log(avctx, AV_LOG_ERROR, "bps is unsupported: %d\n", readsamplesize);
+ return AVERROR_PATCHWELCOME;
+ }
/* whether the frame is compressed */
is_compressed = !get_bits1(&alac->gb);
@@ -321,12 +328,6 @@ static int alac_decode_frame(AVCodecContext *avctx, void *data,
alac->output_samples_buffer[ch] = (int32_t *)alac->frame.data[ch];
}
- readsamplesize = alac->sample_size - alac->extra_bits + channels - 1;
- if (readsamplesize > MIN_CACHE_BITS) {
- av_log(avctx, AV_LOG_ERROR, "readsamplesize too big (%d)\n", readsamplesize);
- return -1;
- }
-
if (is_compressed) {
int16_t predictor_coef_table[MAX_CHANNELS][32];
int predictor_coef_num[MAX_CHANNELS];