/* stage-3, optional */
if (flag) {
- int tmp = vlc_stage3_values[value];
+ int tmp;
+
+ if (value >= 60) {
+ av_log(NULL, AV_LOG_ERROR, "value %d in qdm2_get_vlc too large\n", value);
+ return 0;
+ }
+
+ tmp= vlc_stage3_values[value];
if ((value & ~3) > 0)
- tmp += get_bits (gb, (value >> 2));
+ tmp += get_bits(gb, (value >> 2));
value = tmp;
}
* @param sb_min lower subband processed (sb_min included)
* @param sb_max higher subband processed (sb_max excluded)
*/
- static int synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max)
-static void synthfilt_build_sb_samples(QDM2Context *q, GetBitContext *gb,
++static int synthfilt_build_sb_samples(QDM2Context *q, GetBitContext *gb,
+ int length, int sb_min, int sb_max)
{
int sb, j, k, n, ch, run, channels;
int joined_stereo, zero_encoding, chs;
} // j loop
} // channel loop
} // subband loop
+ return 0;
}
-
/**
- * Init the first element of a channel in quantized_coeffs with data from packet 10 (quantized_coeffs[ch][0]).
- * This is similar to process_subpacket_9, but for a single channel and for element [0]
+ * Init the first element of a channel in quantized_coeffs with data
+ * from packet 10 (quantized_coeffs[ch][0]).
+ * This is similar to process_subpacket_9, but for a single channel
+ * and for element [0]
* same VLC tables as process_subpacket_9 are used.
*
* @param quantized_coeffs pointer to quantized_coeffs[ch][0]
* @param gb bitreader context
*/
- static int init_quantized_coeffs_elem0 (int8_t *quantized_coeffs, GetBitContext *gb)
-static void init_quantized_coeffs_elem0(int8_t *quantized_coeffs,
++static int init_quantized_coeffs_elem0(int8_t *quantized_coeffs,
+ GetBitContext *gb)
{
int i, k, run, level, diff;
level += diff;
i += run;
}
+ return 0;
}
-
/**
* Related to synthesis filter, process data from packet 10
* Init part of quantized_coeffs via function init_quantized_coeffs_elem0
* @param q context
* @param node pointer to node with packet
*/
- static int process_subpacket_9 (QDM2Context *q, QDM2SubPNode *node)
-static void process_subpacket_9(QDM2Context *q, QDM2SubPNode *node)
++static int process_subpacket_9(QDM2Context *q, QDM2SubPNode *node)
{
GetBitContext gb;
int i, j, k, n, ch, run, level, diff;
q->quantized_coeffs[ch][i][0] = level;
for (j = 0; j < (8 - 1); ) {
- run = qdm2_get_vlc(&gb, &vlc_tab_run, 0, 1) + 1;
+ run = qdm2_get_vlc(&gb, &vlc_tab_run, 0, 1) + 1;
diff = qdm2_get_se_vlc(&vlc_tab_diff, &gb, 2);
+ if (j + run >= 8)
+ return -1;
+
for (k = 1; k <= run; k++)
- q->quantized_coeffs[ch][i][j + k] = (level + ((k*diff) / run));
+ q->quantized_coeffs[ch][i][j + k] = (level + ((k * diff) / run));
level += diff;
- j += run;
+ j += run;
}
}
for (ch = 0; ch < q->nb_channels; ch++)
for (i = 0; i < 8; i++)
q->quantized_coeffs[ch][0][i] = 0;
+
+ return 0;
}
-
/**
* Process subpacket 10 if not null, else
*
process_subpacket_12(q, NULL);
}
-
-/*
+/**
* Decode superblock, fill packet lists.
*
* @param q context
int local_int_14, stereo_exp, local_int_20, local_int_28;
int n, offset;
- local_int_4 = 0;
+ local_int_4 = 0;
local_int_28 = 0;
local_int_20 = 2;
- local_int_8 = (4 - duration);
+ local_int_8 = (4 - duration);
local_int_10 = 1 << (q->group_order - duration - 1);
- offset = 1;
+ offset = 1;
- while (1) {
+ while (get_bits_left(gb)>0) {
if (q->superblocktype_2_3) {
while ((n = qdm2_get_vlc(gb, &vlc_tab_fft_tone_offset[local_int_8], 1, 2)) < 2) {
+ if (get_bits_left(gb)<0) {
+ if(local_int_4 < q->group_size)
+ av_log(NULL, AV_LOG_ERROR, "overread in qdm2_fft_decode_tones()\n");
+ return;
+ }
offset = 1;
if (n == 0) {
- local_int_4 += local_int_10;
+ local_int_4 += local_int_10;
local_int_28 += (1 << local_int_8);
} else {
- local_int_4 += 8*local_int_10;
+ local_int_4 += 8 * local_int_10;
local_int_28 += (8 << local_int_8);
}
}