From: Michael Niedermayer Date: Mon, 8 Jul 2013 03:10:06 +0000 (+0200) Subject: Merge commit '76efedeadb1f6bf79020c44a71dd0cee13d932ad' X-Git-Tag: n2.0~47 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/e1f98f22313bfde3c85ac566902adeb118ec6d18 Merge commit '76efedeadb1f6bf79020c44a71dd0cee13d932ad' * commit '76efedeadb1f6bf79020c44a71dd0cee13d932ad': qdm2: formatting cosmetics Conflicts: libavcodec/qdm2.c Merged-by: Michael Niedermayer --- e1f98f22313bfde3c85ac566902adeb118ec6d18 diff --cc libavcodec/qdm2.c index a30337c,fd1e7bb..b113d0a --- a/libavcodec/qdm2.c +++ b/libavcodec/qdm2.c @@@ -371,17 -375,10 +375,17 @@@ static int qdm2_get_vlc(GetBitContext * /* 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; } @@@ -789,7 -803,8 +811,8 @@@ static void fill_coding_method_array(sb * @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; @@@ -989,19 -982,20 +1012,21 @@@ } // 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; @@@ -1029,10 -1020,8 +1054,9 @@@ 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 @@@ -1104,7 -1094,7 +1129,7 @@@ static void init_tone_level_dequantizat * @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; @@@ -1119,28 -1109,22 +1144,27 @@@ 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 * @@@ -1241,8 -1225,7 +1265,7 @@@ static void process_synthesis_subpacket process_subpacket_12(q, NULL); } - -/* +/** * Decode superblock, fill packet lists. * * @param q context @@@ -1396,27 -1378,22 +1418,27 @@@ static void qdm2_fft_decode_tones(QDM2C 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); } }