/* parse spectral coefficients : just RLE encoding */
for (ch = 0; ch < pwd->ahi.channels; ch++) {
- if (pwd->channel_coded[ch]) {
- struct vlc *coef_vlc;
- int level, run, sign, tindex;
- int16_t *ptr, *eptr;
- const uint16_t *level_table, *run_table;
-
- /* special VLC tables are used for ms stereo because
- there is potentially less energy there */
- tindex = (ch == 1 && pwd->ms_stereo);
- coef_vlc = &pwd->coef_vlc[tindex];
- run_table = pwd->run_table[tindex];
- level_table = pwd->level_table[tindex];
- /* XXX: optimize */
- ptr = &pwd->coefs1[ch][0];
- eptr = ptr + nb_coefs[ch];
- memset(ptr, 0, pwd->block_len * sizeof(int16_t));
- for (;;) {
- code = get_vlc(&pwd->gb, coef_vlc->table,
- VLCBITS, VLCMAX);
- if (code < 0)
- return -1;
- if (code == 1) /* EOB */
- break;
- if (code == 0) { /* escape */
- level = get_bits(&pwd->gb, coef_nb_bits);
- /* reading block_len_bits would be better */
- run = get_bits(&pwd->gb, pwd->frame_len_bits);
- } else { /* normal code */
- run = run_table[code];
- level = level_table[code];
- }
- sign = get_bit(&pwd->gb);
- if (!sign)
- level = -level;
- ptr += run;
- if (ptr >= eptr) {
- PARA_ERROR_LOG("overflow in spectral RLE, ignoring\n");
- break;
- }
- *ptr++ = level;
- if (ptr >= eptr) /* EOB can be omitted */
- break;
+ struct vlc *coef_vlc;
+ int level, run, sign, tindex;
+ int16_t *ptr, *eptr;
+ const uint16_t *level_table, *run_table;
+
+ if (!pwd->channel_coded[ch])
+ continue;
+ /*
+ * special VLC tables are used for ms stereo because there is
+ * potentially less energy there
+ */
+ tindex = (ch == 1 && pwd->ms_stereo);
+ coef_vlc = &pwd->coef_vlc[tindex];
+ run_table = pwd->run_table[tindex];
+ level_table = pwd->level_table[tindex];
+ /* XXX: optimize */
+ ptr = &pwd->coefs1[ch][0];
+ eptr = ptr + nb_coefs[ch];
+ memset(ptr, 0, pwd->block_len * sizeof(int16_t));
+ for (;;) {
+ code = get_vlc(&pwd->gb, coef_vlc->table,
+ VLCBITS, VLCMAX);
+ if (code < 0)
+ return -1;
+ if (code == 1) /* EOB */
+ break;
+ if (code == 0) { /* escape */
+ level = get_bits(&pwd->gb, coef_nb_bits);
+ /* reading block_len_bits would be better */
+ run = get_bits(&pwd->gb, pwd->frame_len_bits);
+ } else { /* normal code */
+ run = run_table[code];
+ level = level_table[code];
+ }
+ sign = get_bit(&pwd->gb);
+ if (!sign)
+ level = -level;
+ ptr += run;
+ if (ptr >= eptr) {
+ PARA_ERROR_LOG("overflow in spectral RLE, ignoring\n");
+ break;
}
+ *ptr++ = level;
+ if (ptr >= eptr) /* EOB can be omitted */
+ break;
}
}