static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int band,

                           float *bits, float lambda)

{

    int i, b = 0;

    uint32_t cm[2] = { (1 << f->blocks) - 1, (1 << f->blocks) - 1 };

    const int band_size = ff_celt_freq_range[band] << f->size;

    float buf[176 * 2], lowband_scratch[176], norm1[176], norm2[176];

    float dist, cost, err_x = 0.0f, err_y = 0.0f;

    float *X = buf;

    float *X_orig = f->block[0].coeffs + (ff_celt_freq_bands[band] << f->size);

    float *Y = (f->channels == 2) ? &buf[176] : NULL;

    float *Y_orig = f->block[1].coeffs + (ff_celt_freq_bands[band] << f->size);

    OPUS_RC_CHECKPOINT_SPAWN(rc);



    memcpy(X, X_orig, band_size*sizeof(float));

    if (Y)

        memcpy(Y, Y_orig, band_size*sizeof(float));



    f->remaining2 = ((f->framebits << 3) - f->anticollapse_needed) - opus_rc_tell_frac(rc) - 1;

    if (band <= f->coded_bands - 1) {

        int curr_balance = f->remaining / FFMIN(3, f->coded_bands - band);

        b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[band] + curr_balance), 14);

    }



    if (f->dual_stereo) {

        pvq->quant_band(pvq, f, rc, band, X, NULL, band_size, b / 2, f->blocks, NULL,

                        f->size, norm1, 0, 1.0f, lowband_scratch, cm[0]);



        pvq->quant_band(pvq, f, rc, band, Y, NULL, band_size, b / 2, f->blocks, NULL,

                        f->size, norm2, 0, 1.0f, lowband_scratch, cm[1]);

    } else {

        pvq->quant_band(pvq, f, rc, band, X, Y, band_size, b, f->blocks, NULL, f->size,

                        norm1, 0, 1.0f, lowband_scratch, cm[0] | cm[1]);

    }



    for (i = 0; i < band_size; i++) {

        err_x += (X[i] - X_orig[i])*(X[i] - X_orig[i]);

        if (Y)

            err_y += (Y[i] - Y_orig[i])*(Y[i] - Y_orig[i]);

    }



    dist = sqrtf(err_x) + sqrtf(err_y);

    cost = OPUS_RC_CHECKPOINT_BITS(rc)/8.0f;

    *bits += cost;



    OPUS_RC_CHECKPOINT_ROLLBACK(rc);



    return lambda*dist*cost;

}

static float pvq_band_cost(CeltPVQ *pvq, CeltFrame *f, OpusRangeCoder *rc, int band,

                           float *bits, float lambda)

{

    int i, b = 0;

    uint32_t cm[2] = { (1 << f->blocks) - 1, (1 << f->blocks) - 1 };

    const int band_size = ff_celt_freq_range[band] << f->size;

    float buf[176 * 2], lowband_scratch[176], norm1[176], norm2[176];

    float dist, cost, err_x = 0.0f, err_y = 0.0f;

    float *X = buf;

    float *X_orig = f->block[0].coeffs + (ff_celt_freq_bands[band] << f->size);

    float *Y = (f->channels == 2) ? &buf[176] : NULL;

    float *Y_orig = f->block[1].coeffs + (ff_celt_freq_bands[band] << f->size);

    OPUS_RC_CHECKPOINT_SPAWN(rc);



    memcpy(X, X_orig, band_size*sizeof(float));

    if (Y)

        memcpy(Y, Y_orig, band_size*sizeof(float));



    f->remaining2 = ((f->framebits << 3) - f->anticollapse_needed) - opus_rc_tell_frac(rc) - 1;

    if (band <= f->coded_bands - 1) {

        int curr_balance = f->remaining / FFMIN(3, f->coded_bands - band);

        b = av_clip_uintp2(FFMIN(f->remaining2 + 1, f->pulses[band] + curr_balance), 14);

    }



    if (f->dual_stereo) {

        pvq->quant_band(pvq, f, rc, band, X, NULL, band_size, b / 2, f->blocks, NULL,

                        f->size, norm1, 0, 1.0f, lowband_scratch, cm[0]);



        pvq->quant_band(pvq, f, rc, band, Y, NULL, band_size, b / 2, f->blocks, NULL,

                        f->size, norm2, 0, 1.0f, lowband_scratch, cm[1]);

    } else {

        pvq->quant_band(pvq, f, rc, band, X, Y, band_size, b, f->blocks, NULL, f->size,

                        norm1, 0, 1.0f, lowband_scratch, cm[0] | cm[1]);

    }



    for (i = 0; i < band_size; i++) {

        err_x += (X[i] - X_orig[i])*(X[i] - X_orig[i]);

        if (Y)

            err_y += (Y[i] - Y_orig[i])*(Y[i] - Y_orig[i]);

    }



    dist = sqrtf(err_x) + sqrtf(err_y);

    cost = OPUS_RC_CHECKPOINT_BITS(rc)/8.0f;

    *bits += cost;



    OPUS_RC_CHECKPOINT_ROLLBACK(rc);



    return lambda*dist*cost;

}

static float FUNC_0(CeltPVQ *VAR_0, CeltFrame *VAR_1, OpusRangeCoder *VAR_2, int VAR_3,

                           float *VAR_4, float VAR_5)

{

    int VAR_6, VAR_7 = 0;

    uint32_t cm[2] = { (1 << VAR_1->blocks) - 1, (1 << VAR_1->blocks) - 1 };

    const int VAR_8 = ff_celt_freq_range[VAR_3] << VAR_1->size;

    float VAR_9[176 * 2], VAR_10[176], VAR_11[176], VAR_12[176];

    float VAR_13, VAR_14, VAR_15 = 0.0f, VAR_16 = 0.0f;

    float *VAR_17 = VAR_9;

    float *VAR_18 = VAR_1->block[0].coeffs + (ff_celt_freq_bands[VAR_3] << VAR_1->size);

    float *VAR_19 = (VAR_1->channels == 2) ? &VAR_9[176] : NULL;

    float *VAR_20 = VAR_1->block[1].coeffs + (ff_celt_freq_bands[VAR_3] << VAR_1->size);

    OPUS_RC_CHECKPOINT_SPAWN(VAR_2);



    memcpy(VAR_17, VAR_18, VAR_8*sizeof(float));

    if (VAR_19)

        memcpy(VAR_19, VAR_20, VAR_8*sizeof(float));



    VAR_1->remaining2 = ((VAR_1->framebits << 3) - VAR_1->anticollapse_needed) - opus_rc_tell_frac(VAR_2) - 1;

    if (VAR_3 <= VAR_1->coded_bands - 1) {

        int VAR_21 = VAR_1->remaining / FFMIN(3, VAR_1->coded_bands - VAR_3);

        VAR_7 = av_clip_uintp2(FFMIN(VAR_1->remaining2 + 1, VAR_1->pulses[VAR_3] + VAR_21), 14);

    }



    if (VAR_1->dual_stereo) {

        VAR_0->quant_band(VAR_0, VAR_1, VAR_2, VAR_3, VAR_17, NULL, VAR_8, VAR_7 / 2, VAR_1->blocks, NULL,

                        VAR_1->size, VAR_11, 0, 1.0f, VAR_10, cm[0]);



        VAR_0->quant_band(VAR_0, VAR_1, VAR_2, VAR_3, VAR_19, NULL, VAR_8, VAR_7 / 2, VAR_1->blocks, NULL,

                        VAR_1->size, VAR_12, 0, 1.0f, VAR_10, cm[1]);

    } else {

        VAR_0->quant_band(VAR_0, VAR_1, VAR_2, VAR_3, VAR_17, VAR_19, VAR_8, VAR_7, VAR_1->blocks, NULL, VAR_1->size,

                        VAR_11, 0, 1.0f, VAR_10, cm[0] | cm[1]);

    }



    for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++) {

        VAR_15 += (VAR_17[VAR_6] - VAR_18[VAR_6])*(VAR_17[VAR_6] - VAR_18[VAR_6]);

        if (VAR_19)

            VAR_16 += (VAR_19[VAR_6] - VAR_20[VAR_6])*(VAR_19[VAR_6] - VAR_20[VAR_6]);

    }



    VAR_13 = sqrtf(VAR_15) + sqrtf(VAR_16);

    VAR_14 = OPUS_RC_CHECKPOINT_BITS(VAR_2)/8.0f;

    *VAR_4 += VAR_14;



    OPUS_RC_CHECKPOINT_ROLLBACK(VAR_2);



    return VAR_5*VAR_13*VAR_14;

}

static float FUNC_0(CeltPVQ *VAR_0, CeltFrame *VAR_1, OpusRangeCoder *VAR_2, int VAR_3,
float *VAR_4, float VAR_5)
{ int VAR_6, VAR_7 = 0; uint32_t cm[2] = { (1 << VAR_1->blocks) - 1, (1 << VAR_1->blocks) - 1 }; const int VAR_8 = ff_celt_freq_range[VAR_3] << VAR_1->size; float VAR_9[176 * 2], VAR_10[176], VAR_11[176], VAR_12[176]; float VAR_13, VAR_14, VAR_15 = 0.0f, VAR_16 = 0.0f; float *VAR_17 = VAR_9; float *VAR_18 = VAR_1->block[0].coeffs + (ff_celt_freq_bands[VAR_3] << VAR_1->size); float *VAR_19 = (VAR_1->channels == 2) ? &VAR_9[176] : NULL; float *VAR_20 = VAR_1->block[1].coeffs + (ff_celt_freq_bands[VAR_3] << VAR_1->size); OPUS_RC_CHECKPOINT_SPAWN(VAR_2); memcpy(VAR_17, VAR_18, VAR_8*sizeof(float)); if (VAR_19)
memcpy(VAR_19, VAR_20, VAR_8*sizeof(float)); VAR_1->remaining2 = ((VAR_1->framebits << 3) - VAR_1->anticollapse_needed) - opus_rc_tell_frac(VAR_2) - 1; if (VAR_3 <= VAR_1->coded_bands - 1) { int VAR_21 = VAR_1->remaining / FFMIN(3, VAR_1->coded_bands - VAR_3); VAR_7 = av_clip_uintp2(FFMIN(VAR_1->remaining2 + 1, VAR_1->pulses[VAR_3] + VAR_21), 14); } if (VAR_1->dual_stereo) { VAR_0->quant_band(VAR_0, VAR_1, VAR_2, VAR_3, VAR_17, NULL, VAR_8, VAR_7 / 2, VAR_1->blocks, NULL,
VAR_1->size, VAR_11, 0, 1.0f, VAR_10, cm[0]); VAR_0->quant_band(VAR_0, VAR_1, VAR_2, VAR_3, VAR_19, NULL, VAR_8, VAR_7 / 2, VAR_1->blocks, NULL,
VAR_1->size, VAR_12, 0, 1.0f, VAR_10, cm[1]); } else { VAR_0->quant_band(VAR_0, VAR_1, VAR_2, VAR_3, VAR_17, VAR_19, VAR_8, VAR_7, VAR_1->blocks, NULL, VAR_1->size,
VAR_11, 0, 1.0f, VAR_10, cm[0] | cm[1]); } for (VAR_6 = 0; VAR_6 < VAR_8; VAR_6++) { VAR_15 += (VAR_17[VAR_6] - VAR_18[VAR_6])*(VAR_17[VAR_6] - VAR_18[VAR_6]); if (VAR_19)
VAR_16 += (VAR_19[VAR_6] - VAR_20[VAR_6])*(VAR_19[VAR_6] - VAR_20[VAR_6]); } VAR_13 = sqrtf(VAR_15) + sqrtf(VAR_16); VAR_14 = OPUS_RC_CHECKPOINT_BITS(VAR_2)/8.0f; *VAR_4 += VAR_14; OPUS_RC_CHECKPOINT_ROLLBACK(VAR_2); return VAR_5*VAR_13*VAR_14; }