static void init_tone_level_dequantization (QDM2Context *q, GetBitContext *gb, int length)
{
    int sb, j, k, n, ch;
    for (ch = 0; ch < q->nb_channels; ch++) {
        init_quantized_coeffs_elem0(q->quantized_coeffs[ch][0], gb, length);
        if (BITS_LEFT(length,gb) < 16) {
            memset(q->quantized_coeffs[ch][0], 0, 8);
            break;
        }
    }
    n = q->sub_sampling + 1;
    for (sb = 0; sb < n; sb++)
        for (ch = 0; ch < q->nb_channels; ch++)
            for (j = 0; j < 8; j++) {
                if (BITS_LEFT(length,gb) < 1)
                    break;
                if (get_bits1(gb)) {
                    for (k=0; k < 8; k++) {
                        if (BITS_LEFT(length,gb) < 16)
                            break;
                        q->tone_level_idx_hi1[ch][sb][j][k] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_hi1, 0, 2);
                    }
                } else {
                    for (k=0; k < 8; k++)
                        q->tone_level_idx_hi1[ch][sb][j][k] = 0;
                }
            }
    n = QDM2_SB_USED(q->sub_sampling) - 4;
    for (sb = 0; sb < n; sb++)
        for (ch = 0; ch < q->nb_channels; ch++) {
            if (BITS_LEFT(length,gb) < 16)
                break;
            q->tone_level_idx_hi2[ch][sb] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_hi2, 0, 2);
            if (sb > 19)
                q->tone_level_idx_hi2[ch][sb] -= 16;
            else
                for (j = 0; j < 8; j++)
                    q->tone_level_idx_mid[ch][sb][j] = -16;
        }
    n = QDM2_SB_USED(q->sub_sampling) - 5;
    for (sb = 0; sb < n; sb++)
        for (ch = 0; ch < q->nb_channels; ch++)
            for (j = 0; j < 8; j++) {
                if (BITS_LEFT(length,gb) < 16)
                    break;
                q->tone_level_idx_mid[ch][sb][j] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_mid, 0, 2) - 32;
            }
}
['static void init_tone_level_dequantization (QDM2Context *q, GetBitContext *gb, int length)\n{\n    int sb, j, k, n, ch;\n    for (ch = 0; ch < q->nb_channels; ch++) {\n        init_quantized_coeffs_elem0(q->quantized_coeffs[ch][0], gb, length);\n        if (BITS_LEFT(length,gb) < 16) {\n            memset(q->quantized_coeffs[ch][0], 0, 8);\n            break;\n        }\n    }\n    n = q->sub_sampling + 1;\n    for (sb = 0; sb < n; sb++)\n        for (ch = 0; ch < q->nb_channels; ch++)\n            for (j = 0; j < 8; j++) {\n                if (BITS_LEFT(length,gb) < 1)\n                    break;\n                if (get_bits1(gb)) {\n                    for (k=0; k < 8; k++) {\n                        if (BITS_LEFT(length,gb) < 16)\n                            break;\n                        q->tone_level_idx_hi1[ch][sb][j][k] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_hi1, 0, 2);\n                    }\n                } else {\n                    for (k=0; k < 8; k++)\n                        q->tone_level_idx_hi1[ch][sb][j][k] = 0;\n                }\n            }\n    n = QDM2_SB_USED(q->sub_sampling) - 4;\n    for (sb = 0; sb < n; sb++)\n        for (ch = 0; ch < q->nb_channels; ch++) {\n            if (BITS_LEFT(length,gb) < 16)\n                break;\n            q->tone_level_idx_hi2[ch][sb] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_hi2, 0, 2);\n            if (sb > 19)\n                q->tone_level_idx_hi2[ch][sb] -= 16;\n            else\n                for (j = 0; j < 8; j++)\n                    q->tone_level_idx_mid[ch][sb][j] = -16;\n        }\n    n = QDM2_SB_USED(q->sub_sampling) - 5;\n    for (sb = 0; sb < n; sb++)\n        for (ch = 0; ch < q->nb_channels; ch++)\n            for (j = 0; j < 8; j++) {\n                if (BITS_LEFT(length,gb) < 16)\n                    break;\n                q->tone_level_idx_mid[ch][sb][j] = qdm2_get_vlc(gb, &vlc_tab_tone_level_idx_mid, 0, 2) - 32;\n            }\n}']