aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/alsdec.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-09-18 15:06:43 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-09-18 15:06:43 +0200
commit4cdc337b5da22ff30335a9de424a1510e9b3fe49 (patch)
treec898dea5b42d58d367583518ab22c91a4b388276 /libavcodec/alsdec.c
parent91af76099e0649a26a411d3f704a826840006296 (diff)
parent6a08955c104450dfc8f56aa9f552a4c08f8d8f7f (diff)
downloadffmpeg-4cdc337b5da22ff30335a9de424a1510e9b3fe49.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: flvenc: silence bogus warning configure: include flags in nm variable alsdec: fix misplaced parentheses. alsdec: check return values. alsdec: fix number of decoded samples in first sub-block in BGMC mode. alsdec: Fix out of ltp_gain_values read. alsdec: Check that quantized parcor coeffs are within range. alsdec: check opt_order. Conflicts: configure libavcodec/alsdec.c libavformat/flvenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/alsdec.c')
-rw-r--r--libavcodec/alsdec.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/libavcodec/alsdec.c b/libavcodec/alsdec.c
index 226312e897..46dd0b45ae 100644
--- a/libavcodec/alsdec.c
+++ b/libavcodec/alsdec.c
@@ -671,7 +671,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
if (*bd->opt_order > sconf->max_order) {
*bd->opt_order = sconf->max_order;
av_log(avctx, AV_LOG_ERROR, "Predictor order too large!\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
} else {
*bd->opt_order = sconf->max_order;
@@ -706,7 +706,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
int offset = parcor_rice_table[sconf->coef_table][k][0];
quant_cof[k] = decode_rice(gb, rice_param) + offset;
if (quant_cof[k] < -64 || quant_cof[k] > 63) {
- av_log(avctx, AV_LOG_ERROR, "Quantization coefficient %d is out of range!\n", quant_cof[k]);
+ av_log(avctx, AV_LOG_ERROR, "quant_cof %d is out of range\n", quant_cof[k]);
return AVERROR_INVALIDDATA;
}
}
@@ -770,7 +770,6 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
int delta[8];
unsigned int k [8];
unsigned int b = av_clip((av_ceil_log2(bd->block_length) - 3) >> 1, 0, 5);
- unsigned int i = start;
// read most significant bits
unsigned int high;
@@ -781,29 +780,30 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
current_res = bd->raw_samples + start;
- for (sb = 0; sb < sub_blocks; sb++, i = 0) {
+ for (sb = 0; sb < sub_blocks; sb++) {
+ unsigned int sb_len = sb_length - (sb ? 0 : start);
+
k [sb] = s[sb] > b ? s[sb] - b : 0;
delta[sb] = 5 - s[sb] + k[sb];
- ff_bgmc_decode(gb, sb_length - i, current_res,
+ ff_bgmc_decode(gb, sb_len, current_res,
delta[sb], sx[sb], &high, &low, &value, ctx->bgmc_lut, ctx->bgmc_lut_status);
- current_res += sb_length - i;
+ current_res += sb_len;
}
ff_bgmc_decode_end(gb);
// read least significant bits and tails
- i = start;
current_res = bd->raw_samples + start;
- for (sb = 0; sb < sub_blocks; sb++, i = 0) {
+ for (sb = 0; sb < sub_blocks; sb++, start = 0) {
unsigned int cur_tail_code = tail_code[sx[sb]][delta[sb]];
unsigned int cur_k = k[sb];
unsigned int cur_s = s[sb];
- for (; i < sb_length; i++) {
+ for (; start < sb_length; start++) {
int32_t res = *current_res;
if (res == cur_tail_code) {
@@ -1348,7 +1348,7 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
}
} else { // multi-channel coding
ALSBlockData bd = { 0 };
- int b;
+ int b, ret;
int *reverted_channels = ctx->reverted_channels;
unsigned int offset = 0;
@@ -1381,8 +1381,10 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
bd.raw_samples = ctx->raw_samples[c] + offset;
bd.raw_other = NULL;
- if (read_block(ctx, &bd) || read_channel_data(ctx, ctx->chan_data[c], c))
- return -1;
+ if ((ret = read_block(ctx, &bd)) < 0)
+ return ret;
+ if ((ret = read_channel_data(ctx, ctx->chan_data[c], c)) < 0)
+ return ret;
}
for (c = 0; c < avctx->channels; c++)
@@ -1401,8 +1403,9 @@ static int read_frame_data(ALSDecContext *ctx, unsigned int ra_frame)
bd.lpc_cof = ctx->lpc_cof[c];
bd.quant_cof = ctx->quant_cof[c];
bd.raw_samples = ctx->raw_samples[c] + offset;
- if (decode_block(ctx, &bd))
- return -1;
+
+ if ((ret = decode_block(ctx, &bd)) < 0)
+ return ret;
}
memset(reverted_channels, 0, avctx->channels * sizeof(*reverted_channels));