From 408ec4e2a6c3fb40e14ac4f0fb2fb9e40ff3e6a3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 15 Jul 2006 23:43:38 +0000 Subject: calculate all coefficients for several orders during cholesky factorization, the resulting coefficients are not strictly optimal though as there is a small difference in the autocorrelation matrixes which is ignored for the smaller orders Originally committed as revision 5758 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/flacenc.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'libavcodec/flacenc.c') diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c index b72da9093f..af36976d77 100644 --- a/libavcodec/flacenc.c +++ b/libavcodec/flacenc.c @@ -742,35 +742,41 @@ static int lpc_calc_coefs(const int32_t *samples, int blocksize, int max_order, compute_autocorr(samples, blocksize, max_order+1, autoc); compute_lpc_coefs(autoc, max_order, lpc, ref); - - opt_order = estimate_best_order(ref, max_order); }else{ LLSModel m[2]; - double var[MAX_LPC_ORDER+1], eval; + double var[MAX_LPC_ORDER+1], eval, weight; for(pass=0; pass>pass) + fabs(eval - var[0]); for(j=0; j<=max_order; j++) var[j]/= sqrt(eval); - } + weight += 1/eval; + }else + weight++; av_update_lls(&m[pass&1], var, 1.0); } - av_solve_lls(&m[pass&1], 0.001); - opt_order= max_order; //FIXME + av_solve_lls(&m[pass&1], 0.001, 0); } - for(i=0; i0; i--) + ref[i] = ref[i-1] - ref[i]; } + opt_order = estimate_best_order(ref, max_order); i = opt_order-1; quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i]); -- cgit v1.2.3