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 = 0;

    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_passes <= 0)

        lpc_passes = 2;



    if (lpc_type == FF_LPC_TYPE_LEVINSON || (lpc_type == FF_LPC_TYPE_CHOLESKY && lpc_passes > 1)) {

        s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples);



        s->lpc_compute_autocorr(s->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]);



        pass++;

    }



    if (lpc_type == FF_LPC_TYPE_CHOLESKY) {

        LLSModel m[2];

        LOCAL_ALIGNED(32, double, var, [FFALIGN(MAX_LPC_ORDER+1,4)]);

        double av_uninit(weight);

        memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));



        for(j=0; j<max_order; j++)

            m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];



        for(; pass<lpc_passes; pass++){

            avpriv_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= m[(pass-1)&1].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++;



                m[pass&1].update_lls(&m[pass&1], var);

            }

            avpriv_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 = 0;

    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_passes <= 0)

        lpc_passes = 2;



    if (lpc_type == FF_LPC_TYPE_LEVINSON || (lpc_type == FF_LPC_TYPE_CHOLESKY && lpc_passes > 1)) {

        s->lpc_apply_welch_window(samples, blocksize, s->windowed_samples);



        s->lpc_compute_autocorr(s->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]);



        pass++;

    }



    if (lpc_type == FF_LPC_TYPE_CHOLESKY) {

        LLSModel m[2];

        LOCAL_ALIGNED(32, double, var, [FFALIGN(MAX_LPC_ORDER+1,4)]);

        double av_uninit(weight);

        memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));



        for(j=0; j<max_order; j++)

            m[0].coeff[max_order-1][j] = -lpc[max_order-1][j];



        for(; pass<lpc_passes; pass++){

            avpriv_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= m[(pass-1)&1].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++;



                m[pass&1].update_lls(&m[pass&1], var);

            }

            avpriv_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;

}

                    eval= m[(pass-1)&1].evaluate_lls(&m[(pass-1)&1], var+1, max_order-1);
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 = 0;

    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_9 <= 0)

        VAR_9 = 2;



    if (VAR_8 == FF_LPC_TYPE_LEVINSON || (VAR_8 == FF_LPC_TYPE_CHOLESKY && VAR_9 > 1)) {

        VAR_0->lpc_apply_welch_window(VAR_1, VAR_2, VAR_0->windowed_samples);



        VAR_0->lpc_compute_autocorr(VAR_0->windowed_samples, 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]);



        VAR_18++;

    }



    if (VAR_8 == FF_LPC_TYPE_CHOLESKY) {

        LLSModel m[2];

        LOCAL_ALIGNED(32, double, var, [FFALIGN(MAX_LPC_ORDER+1,4)]);

        double FUNC_1(weight);

        memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var));



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

            m[0].coeff[VAR_4-1][VAR_17] = -VAR_15[VAR_4-1][VAR_17];



        for(; VAR_18<VAR_9; VAR_18++){

            avpriv_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[VAR_17]= VAR_1[VAR_16-VAR_17];



                if(VAR_18){

                    double VAR_20, VAR_21, VAR_22;

                    VAR_20= m[(VAR_18-1)&1].evaluate_lls(&m[(VAR_18-1)&1], var+1, VAR_4-1);

                    VAR_20= (512>>VAR_18) + fabs(VAR_20 - var[0]);

                    VAR_21 = 1/VAR_20;

                    VAR_22 = sqrt(VAR_21);

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

                        var[VAR_17] *= VAR_22;

                    weight += VAR_21;

                }else

                    weight++;



                m[VAR_18&1].update_lls(&m[VAR_18&1], var);

            }

            avpriv_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 = 0; 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_9 <= 0)
VAR_9 = 2; if (VAR_8 == FF_LPC_TYPE_LEVINSON || (VAR_8 == FF_LPC_TYPE_CHOLESKY && VAR_9 > 1)) { VAR_0->lpc_apply_welch_window(VAR_1, VAR_2, VAR_0->windowed_samples); VAR_0->lpc_compute_autocorr(VAR_0->windowed_samples, 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]); VAR_18++; } if (VAR_8 == FF_LPC_TYPE_CHOLESKY) { LLSModel m[2]; LOCAL_ALIGNED(32, double, var, [FFALIGN(MAX_LPC_ORDER+1,4)]); double FUNC_1(weight); memset(var, 0, FFALIGN(MAX_LPC_ORDER+1,4)*sizeof(*var)); for(VAR_17=0; VAR_17<VAR_4; VAR_17++) m[0].coeff[VAR_4-1][VAR_17] = -VAR_15[VAR_4-1][VAR_17]; for(; VAR_18<VAR_9; VAR_18++){ avpriv_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[VAR_17]= VAR_1[VAR_16-VAR_17]; if(VAR_18){ double VAR_20, VAR_21, VAR_22; VAR_20= m[(VAR_18-1)&1].evaluate_lls(&m[(VAR_18-1)&1], var+1, VAR_4-1); VAR_20= (512>>VAR_18) + fabs(VAR_20 - var[0]); VAR_21 = 1/VAR_20; VAR_22 = sqrt(VAR_21); for(VAR_17=0; VAR_17<=VAR_4; VAR_17++) var[VAR_17] *= VAR_22; weight += VAR_21; }else weight++; m[VAR_18&1].update_lls(&m[VAR_18&1], var); } avpriv_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; }