int ff_lpc_calc_coefs(DSPContext *s,

                      const int32_t *samples, int blocksize, 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);



    if(use_lpc == 1){

        s->flac_compute_autocorr(samples, blocksize, max_order, autoc);



        compute_lpc_coefs(autoc, max_order, lpc, ref);

    }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, 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=0; 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 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);



    if(use_lpc == 1){

        s->flac_compute_autocorr(samples, blocksize, max_order, autoc);



        compute_lpc_coefs(autoc, max_order, lpc, ref);

    }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, 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=0; 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(DSPContext *VAR_0,

                      const int32_t *VAR_1, int VAR_2, int VAR_3,

                      int VAR_4, int32_t VAR_5[][MAX_LPC_ORDER],

                      int *VAR_6, int VAR_7, int VAR_8, int VAR_9, int VAR_10)

{

    double VAR_11[MAX_LPC_ORDER+1];

    double VAR_12[MAX_LPC_ORDER];

    double VAR_13[MAX_LPC_ORDER][MAX_LPC_ORDER];

    int VAR_14, VAR_15, VAR_16;

    int VAR_17;



    assert(VAR_3 >= MIN_LPC_ORDER && VAR_3 <= MAX_LPC_ORDER);



    if(VAR_7 == 1){

        VAR_0->flac_compute_autocorr(VAR_1, VAR_2, VAR_3, VAR_11);



        compute_lpc_coefs(VAR_11, VAR_3, VAR_13, VAR_12);

    }else{

        LLSModel m[2];

        double VAR_18[MAX_LPC_ORDER+1], weight;



        for(VAR_16=0; VAR_16<VAR_7-1; VAR_16++){

            av_init_lls(&m[VAR_16&1], VAR_3);



            weight=0;

            for(VAR_14=VAR_3; VAR_14<VAR_2; VAR_14++){

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

                    VAR_18[VAR_15]= VAR_1[VAR_14-VAR_15];



                if(VAR_16){

                    double VAR_19, VAR_20, VAR_21;

                    VAR_19= av_evaluate_lls(&m[(VAR_16-1)&1], VAR_18+1, VAR_3-1);

                    VAR_19= (512>>VAR_16) + fabs(VAR_19 - VAR_18[0]);

                    VAR_20 = 1/VAR_19;

                    VAR_21 = sqrt(VAR_20);

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

                        VAR_18[VAR_15] *= VAR_21;

                    weight += VAR_20;

                }else

                    weight++;



                av_update_lls(&m[VAR_16&1], VAR_18, 1.0);

            }

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

        }



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

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

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

            VAR_12[VAR_14]= sqrt(m[(VAR_16-1)&1].variance[VAR_14] / weight) * (VAR_2 - VAR_3) / 4000;

        }

        for(VAR_14=VAR_3-1; VAR_14>0; VAR_14--)

            VAR_12[VAR_14] = VAR_12[VAR_14-1] - VAR_12[VAR_14];

    }

    VAR_17 = VAR_3;



    if(VAR_8 == ORDER_METHOD_EST) {

        VAR_17 = estimate_best_order(VAR_12, VAR_3);

        VAR_14 = VAR_17-1;

        quantize_lpc_coefs(VAR_13[VAR_14], VAR_14+1, VAR_4, VAR_5[VAR_14], &VAR_6[VAR_14], VAR_9, VAR_10);

    } else {

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

            quantize_lpc_coefs(VAR_13[VAR_14], VAR_14+1, VAR_4, VAR_5[VAR_14], &VAR_6[VAR_14], VAR_9, VAR_10);

        }

    }



    return VAR_17;

}

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