alac: support a read sample size of up to 32

Use get_bits_long() in decode_scalar().
Use unsigned int for decoded value.
This commit is contained in:
Justin Ruggles 2012-07-09 15:38:58 -04:00
parent 73dc0db486
commit cd632619d9
1 changed files with 11 additions and 10 deletions

View File

@ -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];