+ for (i = 0; i < BANDS; i++) {
+ chctx->sumLenArr[i] = 0;
+ chctx->skipFlagRaw[i] = 0;
+ for (j = band_tab[i]; j < band_tab[i + 1]; j++)
+ chctx->sumLenArr[i] += chctx->CWlengthT[j];
+ if (chctx->bandFlagsBuf[i])
+ if ((((band_tab[i + 1] - band_tab[i]) * 1.5) > chctx->sumLenArr[i]) && (chctx->sumLenArr[i] > 0))
+ chctx->skipFlagRaw[i] = 1;
+ }
+
+ imc_get_skip_coeff(q, chctx);
+
+ for (i = 0; i < BANDS; i++) {
+ chctx->flcoeffs6[i] = chctx->flcoeffs1[i];
+ /* band has flag set and at least one coded coefficient */
+ if (chctx->bandFlagsBuf[i] && (band_tab[i + 1] - band_tab[i]) != chctx->skipFlagCount[i]) {
+ chctx->flcoeffs6[i] *= q->sqrt_tab[ band_tab[i + 1] - band_tab[i]] /
+ q->sqrt_tab[(band_tab[i + 1] - band_tab[i] - chctx->skipFlagCount[i])];
+ }
+ }
+
+ /* calculate bits left, bits needed and adjust bit allocation */
+ bits = summer = 0;
+
+ for (i = 0; i < BANDS; i++) {
+ if (chctx->bandFlagsBuf[i]) {
+ for (j = band_tab[i]; j < band_tab[i + 1]; j++) {
+ if (chctx->skipFlags[j]) {
+ summer += chctx->CWlengthT[j];
+ chctx->CWlengthT[j] = 0;
+ }
+ }
+ bits += chctx->skipFlagBits[i];
+ summer -= chctx->skipFlagBits[i];
+ }
+ }
+ imc_adjust_bit_allocation(q, chctx, summer);
+}