aboutsummaryrefslogtreecommitdiff
path: root/gst-libs/ext/libav/libavcodec/alsdec.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst-libs/ext/libav/libavcodec/alsdec.c')
-rw-r--r--gst-libs/ext/libav/libavcodec/alsdec.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/gst-libs/ext/libav/libavcodec/alsdec.c b/gst-libs/ext/libav/libavcodec/alsdec.c
index 26496bf..459e2af 100644
--- a/gst-libs/ext/libav/libavcodec/alsdec.c
+++ b/gst-libs/ext/libav/libavcodec/alsdec.c
@@ -651,6 +651,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
for (k = 1; k < sub_blocks; k++)
s[k] = s[k - 1] + decode_rice(gb, 0);
}
+ for (k = 1; k < sub_blocks; k++)
+ if (s[k] > 32) {
+ av_log(avctx, AV_LOG_ERROR, "k invalid for rice code.\n");
+ return AVERROR_INVALIDDATA;
+ }
if (get_bits1(gb))
*bd->shift_lsbs = get_bits(gb, 4) + 1;
@@ -663,6 +668,11 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
int opt_order_length = av_ceil_log2(av_clip((bd->block_length >> 3) - 1,
2, sconf->max_order + 1));
*bd->opt_order = get_bits(gb, opt_order_length);
+ 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 AVERROR_INVALIDDATA;
+ }
} else {
*bd->opt_order = sconf->max_order;
}
@@ -695,6 +705,10 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
int rice_param = parcor_rice_table[sconf->coef_table][k][1];
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, "quant_cof %d is out of range\n", quant_cof[k]);
+ return AVERROR_INVALIDDATA;
+ }
}
// read coefficients 20 to 126
@@ -727,7 +741,7 @@ static int read_var_block_data(ALSDecContext *ctx, ALSBlockData *bd)
bd->ltp_gain[0] = decode_rice(gb, 1) << 3;
bd->ltp_gain[1] = decode_rice(gb, 2) << 3;
- r = get_unary(gb, 0, 4);
+ r = get_unary(gb, 0, 3);
c = get_bits(gb, 2);
bd->ltp_gain[2] = ltp_gain_values[r][c];
@@ -756,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;
@@ -767,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, 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;
+ 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) {