int ff_lpc_calc_coefs(LPCContext *s,
                      const int32_t *samples, int blocksize, int min_order,
                      int max_order, int precision,
                      int32_t coefs[][MAX_LPC_ORDER], int *shift,
                      enum FFLPCType lpc_type, int lpc_passes,
                      int omethod, int max_shift, int zero_shift)
{
    double autoc[MAX_LPC_ORDER+1];
    double ref[MAX_LPC_ORDER];
    double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
    int i, j, pass;
    int opt_order;
    av_assert2(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
           lpc_type > FF_LPC_TYPE_FIXED);
    /* reinit LPC context if parameters have changed */
    if (blocksize != s->blocksize || max_order != s->max_order ||
        lpc_type  != s->lpc_type) {
        ff_lpc_end(s);
        ff_lpc_init(s, blocksize, max_order, lpc_type);
    }
    if (lpc_type == FF_LPC_TYPE_LEVINSON) {
        double *windowed_samples = s->windowed_samples + max_order;
        s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
        s->lpc_compute_autocorr(windowed_samples, blocksize, max_order, autoc);
        compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
        for(i=0; i<max_order; i++)
            ref[i] = fabs(lpc[i][i]);
    } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
        LLSModel m[2];
        double var[MAX_LPC_ORDER+1], av_uninit(weight);
        for(pass=0; pass<lpc_passes; pass++){
            av_init_lls(&m[pass&1], max_order);
            weight=0;
            for(i=max_order; i<blocksize; i++){
                for(j=0; j<=max_order; j++)
                    var[j]= samples[i-j];
                if(pass){
                    double eval, inv, rinv;
                    eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
                    eval= (512>>pass) + fabs(eval - var[0]);
                    inv = 1/eval;
                    rinv = sqrt(inv);
                    for(j=0; j<=max_order; j++)
                        var[j] *= rinv;
                    weight += inv;
                }else
                    weight++;
                av_update_lls(&m[pass&1], var, 1.0);
            }
            av_solve_lls(&m[pass&1], 0.001, 0);
        }
        for(i=0; i<max_order; i++){
            for(j=0; j<max_order; j++)
                lpc[i][j]=-m[(pass-1)&1].coeff[i][j];
            ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
        }
        for(i=max_order-1; i>0; i--)
            ref[i] = ref[i-1] - ref[i];
    }
    opt_order = max_order;
    if(omethod == ORDER_METHOD_EST) {
        opt_order = estimate_best_order(ref, min_order, max_order);
        i = opt_order-1;
        quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
    } else {
        for(i=min_order-1; i<max_order; i++) {
            quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
        }
    }
    return opt_order;
}
int ff_lpc_calc_coefs(LPCContext *s,
                      const int32_t *samples, int blocksize, int min_order,
                      int max_order, int precision,
                      int32_t coefs[][MAX_LPC_ORDER], int *shift,
                      enum FFLPCType lpc_type, int lpc_passes,
                      int omethod, int max_shift, int zero_shift)
{
    double autoc[MAX_LPC_ORDER+1];
    double ref[MAX_LPC_ORDER];
    double lpc[MAX_LPC_ORDER][MAX_LPC_ORDER];
    int i, j, pass;
    int opt_order;
    av_assert2(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER &&
           lpc_type > FF_LPC_TYPE_FIXED);
    
    if (blocksize != s->blocksize || max_order != s->max_order ||
        lpc_type  != s->lpc_type) {
        ff_lpc_end(s);
        ff_lpc_init(s, blocksize, max_order, lpc_type);
    }
    if (lpc_type == FF_LPC_TYPE_LEVINSON) {
        double *windowed_samples = s->windowed_samples + max_order;
        s->lpc_apply_welch_window(samples, blocksize, windowed_samples);
        s->lpc_compute_autocorr(windowed_samples, blocksize, max_order, autoc);
        compute_lpc_coefs(autoc, max_order, &lpc[0][0], MAX_LPC_ORDER, 0, 1);
        for(i=0; i<max_order; i++)
            ref[i] = fabs(lpc[i][i]);
    } else if (lpc_type == FF_LPC_TYPE_CHOLESKY) {
        LLSModel m[2];
        double var[MAX_LPC_ORDER+1], av_uninit(weight);
        for(pass=0; pass<lpc_passes; pass++){
            av_init_lls(&m[pass&1], max_order);
            weight=0;
            for(i=max_order; i<blocksize; i++){
                for(j=0; j<=max_order; j++)
                    var[j]= samples[i-j];
                if(pass){
                    double eval, inv, rinv;
                    eval= av_evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
                    eval= (512>>pass) + fabs(eval - var[0]);
                    inv = 1/eval;
                    rinv = sqrt(inv);
                    for(j=0; j<=max_order; j++)
                        var[j] *= rinv;
                    weight += inv;
                }else
                    weight++;
                av_update_lls(&m[pass&1], var, 1.0);
            }
            av_solve_lls(&m[pass&1], 0.001, 0);
        }
        for(i=0; i<max_order; i++){
            for(j=0; j<max_order; j++)
                lpc[i][j]=-m[(pass-1)&1].coeff[i][j];
            ref[i]= sqrt(m[(pass-1)&1].variance[i] / weight) * (blocksize - max_order) / 4000;
        }
        for(i=max_order-1; i>0; i--)
            ref[i] = ref[i-1] - ref[i];
    }
    opt_order = max_order;
    if(omethod == ORDER_METHOD_EST) {
        opt_order = estimate_best_order(ref, min_order, max_order);
        i = opt_order-1;
        quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
    } else {
        for(i=min_order-1; i<max_order; i++) {
            quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
        }
    }
    return opt_order;
}
int FUNC_0(LPCContext *VAR_0,
                      const int32_t *VAR_1, int VAR_2, int VAR_3,
                      int VAR_4, int VAR_5,
                      int32_t VAR_6[][MAX_LPC_ORDER], int *VAR_7,
                      enum FFLPCType VAR_8, int VAR_9,
                      int VAR_10, int VAR_11, int VAR_12)
{
    double VAR_13[MAX_LPC_ORDER+1];
    double VAR_14[MAX_LPC_ORDER];
    double VAR_15[MAX_LPC_ORDER][MAX_LPC_ORDER];
    int VAR_16, VAR_17, VAR_18;
    int VAR_19;
    av_assert2(VAR_4 >= MIN_LPC_ORDER && VAR_4 <= MAX_LPC_ORDER &&
           VAR_8 > FF_LPC_TYPE_FIXED);
    
    if (VAR_2 != VAR_0->VAR_2 || VAR_4 != VAR_0->VAR_4 ||
        VAR_8  != VAR_0->VAR_8) {
        ff_lpc_end(VAR_0);
        ff_lpc_init(VAR_0, VAR_2, VAR_4, VAR_8);
    }
    if (VAR_8 == FF_LPC_TYPE_LEVINSON) {
        double *VAR_20 = VAR_0->VAR_20 + VAR_4;
        VAR_0->lpc_apply_welch_window(VAR_1, VAR_2, VAR_20);
        VAR_0->lpc_compute_autocorr(VAR_20, VAR_2, VAR_4, VAR_13);
        compute_lpc_coefs(VAR_13, VAR_4, &VAR_15[0][0], MAX_LPC_ORDER, 0, 1);
        for(VAR_16=0; VAR_16<VAR_4; VAR_16++)
            VAR_14[VAR_16] = fabs(VAR_15[VAR_16][VAR_16]);
    } else if (VAR_8 == FF_LPC_TYPE_CHOLESKY) {
        LLSModel m[2];
        double VAR_21[MAX_LPC_ORDER+1], av_uninit(weight);
        for(VAR_18=0; VAR_18<VAR_9; VAR_18++){
            av_init_lls(&m[VAR_18&1], VAR_4);
            weight=0;
            for(VAR_16=VAR_4; VAR_16<VAR_2; VAR_16++){
                for(VAR_17=0; VAR_17<=VAR_4; VAR_17++)
                    VAR_21[VAR_17]= VAR_1[VAR_16-VAR_17];
                if(VAR_18){
                    double VAR_22, VAR_23, VAR_24;
                    VAR_22= av_evaluate_lls(&m[(VAR_18-1)&1], VAR_21+1, VAR_4-1);
                    VAR_22= (512>>VAR_18) + fabs(VAR_22 - VAR_21[0]);
                    VAR_23 = 1/VAR_22;
                    VAR_24 = sqrt(VAR_23);
                    for(VAR_17=0; VAR_17<=VAR_4; VAR_17++)
                        VAR_21[VAR_17] *= VAR_24;
                    weight += VAR_23;
                }else
                    weight++;
                av_update_lls(&m[VAR_18&1], VAR_21, 1.0);
            }
            av_solve_lls(&m[VAR_18&1], 0.001, 0);
        }
        for(VAR_16=0; VAR_16<VAR_4; VAR_16++){
            for(VAR_17=0; VAR_17<VAR_4; VAR_17++)
                VAR_15[VAR_16][VAR_17]=-m[(VAR_18-1)&1].coeff[VAR_16][VAR_17];
            VAR_14[VAR_16]= sqrt(m[(VAR_18-1)&1].variance[VAR_16] / weight) * (VAR_2 - VAR_4) / 4000;
        }
        for(VAR_16=VAR_4-1; VAR_16>0; VAR_16--)
            VAR_14[VAR_16] = VAR_14[VAR_16-1] - VAR_14[VAR_16];
    }
    VAR_19 = VAR_4;
    if(VAR_10 == ORDER_METHOD_EST) {
        VAR_19 = estimate_best_order(VAR_14, VAR_3, VAR_4);
        VAR_16 = VAR_19-1;
        quantize_lpc_coefs(VAR_15[VAR_16], VAR_16+1, VAR_5, VAR_6[VAR_16], &VAR_7[VAR_16], VAR_11, VAR_12);
    } else {
        for(VAR_16=VAR_3-1; VAR_16<VAR_4; VAR_16++) {
            quantize_lpc_coefs(VAR_15[VAR_16], VAR_16+1, VAR_5, VAR_6[VAR_16], &VAR_7[VAR_16], VAR_11, VAR_12);
        }
    }
    return VAR_19;
}
int FUNC_0(LPCContext *VAR_0,
const int32_t *VAR_1, int VAR_2, int VAR_3,
int VAR_4, int VAR_5,
int32_t VAR_6[][MAX_LPC_ORDER], int *VAR_7,
enum FFLPCType VAR_8, int VAR_9,
int VAR_10, int VAR_11, int VAR_12)
{ double VAR_13[MAX_LPC_ORDER+1]; double VAR_14[MAX_LPC_ORDER]; double VAR_15[MAX_LPC_ORDER][MAX_LPC_ORDER]; int VAR_16, VAR_17, VAR_18; int VAR_19; av_assert2(VAR_4 >= MIN_LPC_ORDER && VAR_4 <= MAX_LPC_ORDER &&
VAR_8 > FF_LPC_TYPE_FIXED); if (VAR_2 != VAR_0->VAR_2 || VAR_4 != VAR_0->VAR_4 ||
VAR_8  != VAR_0->VAR_8) { ff_lpc_end(VAR_0); ff_lpc_init(VAR_0, VAR_2, VAR_4, VAR_8); } if (VAR_8 == FF_LPC_TYPE_LEVINSON) { double *VAR_20 = VAR_0->VAR_20 + VAR_4; VAR_0->lpc_apply_welch_window(VAR_1, VAR_2, VAR_20); VAR_0->lpc_compute_autocorr(VAR_20, VAR_2, VAR_4, VAR_13); compute_lpc_coefs(VAR_13, VAR_4, &VAR_15[0][0], MAX_LPC_ORDER, 0, 1); for(VAR_16=0; VAR_16<VAR_4; VAR_16++) VAR_14[VAR_16] = fabs(VAR_15[VAR_16][VAR_16]); } else if (VAR_8 == FF_LPC_TYPE_CHOLESKY) { LLSModel m[2]; double VAR_21[MAX_LPC_ORDER+1], av_uninit(weight); for(VAR_18=0; VAR_18<VAR_9; VAR_18++){ av_init_lls(&m[VAR_18&1], VAR_4); weight=0; for(VAR_16=VAR_4; VAR_16<VAR_2; VAR_16++){ for(VAR_17=0; VAR_17<=VAR_4; VAR_17++) VAR_21[VAR_17]= VAR_1[VAR_16-VAR_17]; if(VAR_18){ double VAR_22, VAR_23, VAR_24; VAR_22= av_evaluate_lls(&m[(VAR_18-1)&1], VAR_21+1, VAR_4-1); VAR_22= (512>>VAR_18) + fabs(VAR_22 - VAR_21[0]); VAR_23 = 1/VAR_22; VAR_24 = sqrt(VAR_23); for(VAR_17=0; VAR_17<=VAR_4; VAR_17++) VAR_21[VAR_17] *= VAR_24; weight += VAR_23; }else weight++; av_update_lls(&m[VAR_18&1], VAR_21, 1.0); } av_solve_lls(&m[VAR_18&1], 0.001, 0); } for(VAR_16=0; VAR_16<VAR_4; VAR_16++){ for(VAR_17=0; VAR_17<VAR_4; VAR_17++) VAR_15[VAR_16][VAR_17]=-m[(VAR_18-1)&1].coeff[VAR_16][VAR_17]; VAR_14[VAR_16]= sqrt(m[(VAR_18-1)&1].variance[VAR_16] / weight) * (VAR_2 - VAR_4) / 4000; } for(VAR_16=VAR_4-1; VAR_16>0; VAR_16--) VAR_14[VAR_16] = VAR_14[VAR_16-1] - VAR_14[VAR_16]; } VAR_19 = VAR_4; if(VAR_10 == ORDER_METHOD_EST) { VAR_19 = estimate_best_order(VAR_14, VAR_3, VAR_4); VAR_16 = VAR_19-1; quantize_lpc_coefs(VAR_15[VAR_16], VAR_16+1, VAR_5, VAR_6[VAR_16], &VAR_7[VAR_16], VAR_11, VAR_12); } else { for(VAR_16=VAR_3-1; VAR_16<VAR_4; VAR_16++) { quantize_lpc_coefs(VAR_15[VAR_16], VAR_16+1, VAR_5, VAR_6[VAR_16], &VAR_7[VAR_16], VAR_11, VAR_12); } } return VAR_19; }