static int init_quantization_noise(DCAEncContext *c, int noise)

{

    int ch, band, ret = 0;



    c->consumed_bits = 132 + 493 * c->fullband_channels;

    if (c->lfe_channel)

        c->consumed_bits += 72;



    /* attempt to guess the bit distribution based on the prevoius frame */

    for (ch = 0; ch < c->fullband_channels; ch++) {

        for (band = 0; band < 32; band++) {

            int snr_cb = c->peak_cb[band][ch] - c->band_masking_cb[band] - noise;



            if (snr_cb >= 1312) {

                c->abits[band][ch] = 26;

                ret |= USED_26ABITS;

            } else if (snr_cb >= 222) {

                c->abits[band][ch] = 8 + mul32(snr_cb - 222, 69000000);

                ret |= USED_NABITS;

            } else if (snr_cb >= 0) {

                c->abits[band][ch] = 2 + mul32(snr_cb, 106000000);

                ret |= USED_NABITS;

            } else {

                c->abits[band][ch] = 1;

                ret |= USED_1ABITS;

            }

        }

    }



    for (band = 0; band < 32; band++)

        for (ch = 0; ch < c->fullband_channels; ch++) {

            c->consumed_bits += bit_consumption[c->abits[band][ch]];

        }



    return ret;

}

static int init_quantization_noise(DCAEncContext *c, int noise)

{

    int ch, band, ret = 0;



    c->consumed_bits = 132 + 493 * c->fullband_channels;

    if (c->lfe_channel)

        c->consumed_bits += 72;



    

    for (ch = 0; ch < c->fullband_channels; ch++) {

        for (band = 0; band < 32; band++) {

            int snr_cb = c->peak_cb[band][ch] - c->band_masking_cb[band] - noise;



            if (snr_cb >= 1312) {

                c->abits[band][ch] = 26;

                ret |= USED_26ABITS;

            } else if (snr_cb >= 222) {

                c->abits[band][ch] = 8 + mul32(snr_cb - 222, 69000000);

                ret |= USED_NABITS;

            } else if (snr_cb >= 0) {

                c->abits[band][ch] = 2 + mul32(snr_cb, 106000000);

                ret |= USED_NABITS;

            } else {

                c->abits[band][ch] = 1;

                ret |= USED_1ABITS;

            }

        }

    }



    for (band = 0; band < 32; band++)

        for (ch = 0; ch < c->fullband_channels; ch++) {

            c->consumed_bits += bit_consumption[c->abits[band][ch]];

        }



    return ret;

}

static int FUNC_0(DCAEncContext *VAR_0, int VAR_1)

{

    int VAR_2, VAR_3, VAR_4 = 0;



    VAR_0->consumed_bits = 132 + 493 * VAR_0->fullband_channels;

    if (VAR_0->lfe_channel)

        VAR_0->consumed_bits += 72;



    

    for (VAR_2 = 0; VAR_2 < VAR_0->fullband_channels; VAR_2++) {

        for (VAR_3 = 0; VAR_3 < 32; VAR_3++) {

            int snr_cb = VAR_0->peak_cb[VAR_3][VAR_2] - VAR_0->band_masking_cb[VAR_3] - VAR_1;



            if (snr_cb >= 1312) {

                VAR_0->abits[VAR_3][VAR_2] = 26;

                VAR_4 |= USED_26ABITS;

            } else if (snr_cb >= 222) {

                VAR_0->abits[VAR_3][VAR_2] = 8 + mul32(snr_cb - 222, 69000000);

                VAR_4 |= USED_NABITS;

            } else if (snr_cb >= 0) {

                VAR_0->abits[VAR_3][VAR_2] = 2 + mul32(snr_cb, 106000000);

                VAR_4 |= USED_NABITS;

            } else {

                VAR_0->abits[VAR_3][VAR_2] = 1;

                VAR_4 |= USED_1ABITS;

            }

        }

    }



    for (VAR_3 = 0; VAR_3 < 32; VAR_3++)

        for (VAR_2 = 0; VAR_2 < VAR_0->fullband_channels; VAR_2++) {

            VAR_0->consumed_bits += bit_consumption[VAR_0->abits[VAR_3][VAR_2]];

        }



    return VAR_4;

}

static int FUNC_0(DCAEncContext *VAR_0, int VAR_1)
{ int VAR_2, VAR_3, VAR_4 = 0; VAR_0->consumed_bits = 132 + 493 * VAR_0->fullband_channels; if (VAR_0->lfe_channel)
VAR_0->consumed_bits += 72; for (VAR_2 = 0; VAR_2 < VAR_0->fullband_channels; VAR_2++) { for (VAR_3 = 0; VAR_3 < 32; VAR_3++) { int snr_cb = VAR_0->peak_cb[VAR_3][VAR_2] - VAR_0->band_masking_cb[VAR_3] - VAR_1; if (snr_cb >= 1312) { VAR_0->abits[VAR_3][VAR_2] = 26; VAR_4 |= USED_26ABITS; } else if (snr_cb >= 222) { VAR_0->abits[VAR_3][VAR_2] = 8 + mul32(snr_cb - 222, 69000000); VAR_4 |= USED_NABITS; } else if (snr_cb >= 0) { VAR_0->abits[VAR_3][VAR_2] = 2 + mul32(snr_cb, 106000000); VAR_4 |= USED_NABITS; } else { VAR_0->abits[VAR_3][VAR_2] = 1; VAR_4 |= USED_1ABITS; } } } for (VAR_3 = 0; VAR_3 < 32; VAR_3++) for (VAR_2 = 0; VAR_2 < VAR_0->fullband_channels; VAR_2++) { VAR_0->consumed_bits += bit_consumption[VAR_0->abits[VAR_3][VAR_2]]; } return VAR_4; }