int ff_lpc_calc_coefs(DSPContext *s,

                      const int32_t *samples, int blocksize, int min_order,

                      int max_order, int precision,

                      int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,

                      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;



    assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0);



    if(use_lpc == 1){

        s->flac_compute_autocorr(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{

        LLSModel m[2];

        double var[MAX_LPC_ORDER+1], weight;



        for(pass=0; pass<use_lpc-1; 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(DSPContext *s,

                      const int32_t *samples, int blocksize, int min_order,

                      int max_order, int precision,

                      int32_t coefs[][MAX_LPC_ORDER], int *shift, int use_lpc,

                      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;



    assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER && use_lpc > 0);



    if(use_lpc == 1){

        s->flac_compute_autocorr(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{

        LLSModel m[2];

        double var[MAX_LPC_ORDER+1], weight;



        for(pass=0; pass<use_lpc-1; 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;

}

        double var[MAX_LPC_ORDER+1], weight;
int FUNC_0(DSPContext *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, int VAR_8,

                      int VAR_9, int VAR_10, int VAR_11)

{

    double VAR_12[MAX_LPC_ORDER+1];

    double VAR_13[MAX_LPC_ORDER];

    double VAR_14[MAX_LPC_ORDER][MAX_LPC_ORDER];

    int VAR_15, VAR_16, VAR_17;

    int VAR_18;



    assert(VAR_4 >= MIN_LPC_ORDER && VAR_4 <= MAX_LPC_ORDER && VAR_8 > 0);



    if(VAR_8 == 1){

        VAR_0->flac_compute_autocorr(VAR_1, VAR_2, VAR_4, VAR_12);



        compute_lpc_coefs(VAR_12, VAR_4, &VAR_14[0][0], MAX_LPC_ORDER, 0, 1);



        for(VAR_15=0; VAR_15<VAR_4; VAR_15++)

            VAR_13[VAR_15] = fabs(VAR_14[VAR_15][VAR_15]);

    }else{

        LLSModel m[2];

        double VAR_19[MAX_LPC_ORDER+1], weight;



        for(VAR_17=0; VAR_17<VAR_8-1; VAR_17++){

            av_init_lls(&m[VAR_17&1], VAR_4);



            weight=0;

            for(VAR_15=VAR_4; VAR_15<VAR_2; VAR_15++){

                for(VAR_16=0; VAR_16<=VAR_4; VAR_16++)

                    VAR_19[VAR_16]= VAR_1[VAR_15-VAR_16];



                if(VAR_17){

                    double VAR_20, VAR_21, VAR_22;

                    VAR_20= av_evaluate_lls(&m[(VAR_17-1)&1], VAR_19+1, VAR_4-1);

                    VAR_20= (512>>VAR_17) + fabs(VAR_20 - VAR_19[0]);

                    VAR_21 = 1/VAR_20;

                    VAR_22 = sqrt(VAR_21);

                    for(VAR_16=0; VAR_16<=VAR_4; VAR_16++)

                        VAR_19[VAR_16] *= VAR_22;

                    weight += VAR_21;

                }else

                    weight++;



                av_update_lls(&m[VAR_17&1], VAR_19, 1.0);

            }

            av_solve_lls(&m[VAR_17&1], 0.001, 0);

        }



        for(VAR_15=0; VAR_15<VAR_4; VAR_15++){

            for(VAR_16=0; VAR_16<VAR_4; VAR_16++)

                VAR_14[VAR_15][VAR_16]=-m[(VAR_17-1)&1].coeff[VAR_15][VAR_16];

            VAR_13[VAR_15]= sqrt(m[(VAR_17-1)&1].variance[VAR_15] / weight) * (VAR_2 - VAR_4) / 4000;

        }

        for(VAR_15=VAR_4-1; VAR_15>0; VAR_15--)

            VAR_13[VAR_15] = VAR_13[VAR_15-1] - VAR_13[VAR_15];

    }

    VAR_18 = VAR_4;



    if(VAR_9 == ORDER_METHOD_EST) {

        VAR_18 = estimate_best_order(VAR_13, VAR_3, VAR_4);

        VAR_15 = VAR_18-1;

        quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11);

    } else {

        for(VAR_15=VAR_3-1; VAR_15<VAR_4; VAR_15++) {

            quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11);

        }

    }



    return VAR_18;

}

int FUNC_0(DSPContext *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, int VAR_8,
int VAR_9, int VAR_10, int VAR_11)
{ double VAR_12[MAX_LPC_ORDER+1]; double VAR_13[MAX_LPC_ORDER]; double VAR_14[MAX_LPC_ORDER][MAX_LPC_ORDER]; int VAR_15, VAR_16, VAR_17; int VAR_18; assert(VAR_4 >= MIN_LPC_ORDER && VAR_4 <= MAX_LPC_ORDER && VAR_8 > 0); if(VAR_8 == 1){ VAR_0->flac_compute_autocorr(VAR_1, VAR_2, VAR_4, VAR_12); compute_lpc_coefs(VAR_12, VAR_4, &VAR_14[0][0], MAX_LPC_ORDER, 0, 1); for(VAR_15=0; VAR_15<VAR_4; VAR_15++) VAR_13[VAR_15] = fabs(VAR_14[VAR_15][VAR_15]); }else{ LLSModel m[2]; double VAR_19[MAX_LPC_ORDER+1], weight; for(VAR_17=0; VAR_17<VAR_8-1; VAR_17++){ av_init_lls(&m[VAR_17&1], VAR_4); weight=0; for(VAR_15=VAR_4; VAR_15<VAR_2; VAR_15++){ for(VAR_16=0; VAR_16<=VAR_4; VAR_16++) VAR_19[VAR_16]= VAR_1[VAR_15-VAR_16]; if(VAR_17){ double VAR_20, VAR_21, VAR_22; VAR_20= av_evaluate_lls(&m[(VAR_17-1)&1], VAR_19+1, VAR_4-1); VAR_20= (512>>VAR_17) + fabs(VAR_20 - VAR_19[0]); VAR_21 = 1/VAR_20; VAR_22 = sqrt(VAR_21); for(VAR_16=0; VAR_16<=VAR_4; VAR_16++) VAR_19[VAR_16] *= VAR_22; weight += VAR_21; }else weight++; av_update_lls(&m[VAR_17&1], VAR_19, 1.0); } av_solve_lls(&m[VAR_17&1], 0.001, 0); } for(VAR_15=0; VAR_15<VAR_4; VAR_15++){ for(VAR_16=0; VAR_16<VAR_4; VAR_16++) VAR_14[VAR_15][VAR_16]=-m[(VAR_17-1)&1].coeff[VAR_15][VAR_16]; VAR_13[VAR_15]= sqrt(m[(VAR_17-1)&1].variance[VAR_15] / weight) * (VAR_2 - VAR_4) / 4000; } for(VAR_15=VAR_4-1; VAR_15>0; VAR_15--) VAR_13[VAR_15] = VAR_13[VAR_15-1] - VAR_13[VAR_15]; } VAR_18 = VAR_4; if(VAR_9 == ORDER_METHOD_EST) { VAR_18 = estimate_best_order(VAR_13, VAR_3, VAR_4); VAR_15 = VAR_18-1; quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11); } else { for(VAR_15=VAR_3-1; VAR_15<VAR_4; VAR_15++) { quantize_lpc_coefs(VAR_14[VAR_15], VAR_15+1, VAR_5, VAR_6[VAR_15], &VAR_7[VAR_15], VAR_10, VAR_11); } } return VAR_18; }