25 #define LPC_USE_DOUBLE
45 c = 2.0 / (len - 1.0);
52 w_data[-i-1] = data[-i-1] * w;
53 w_data[+i ] = data[+i ] * w;
66 for(j=0; j<lag; j+=2){
67 double sum0 = 1.0, sum1 = 1.0;
69 sum0 += data[i] * data[i-j];
70 sum1 += data[i] * data[i-j-1];
78 for(i=j-1; i<
len; i+=2){
79 sum += data[i ] * data[i-j ]
80 + data[i+1] * data[i-j+1];
90 int32_t *lpc_out,
int *
shift,
int max_shift,
int zero_shift)
98 qmax = (1 << (precision - 1)) - 1;
102 for(i=0; i<order; i++) {
103 cmax=
FFMAX(cmax, fabs(lpc_in[i]));
107 if(cmax * (1 << max_shift) < 1.0) {
109 memset(lpc_out, 0,
sizeof(
int32_t) * order);
115 while((cmax * (1 << sh) > qmax) && (sh > 0)) {
121 if(sh == 0 && cmax > qmax) {
122 double scale = ((double)qmax) / cmax;
123 for(i=0; i<order; i++) {
130 for(i=0; i<order; i++) {
131 error -= lpc_in[i] * (1 << sh);
132 lpc_out[i] = av_clip(
lrintf(error), -qmax, qmax);
143 for(i=max_order-1; i>=min_order-1; i--) {
172 int max_order,
int precision,
175 int omethod,
int max_shift,
int zero_shift)
177 double autoc[MAX_LPC_ORDER+1];
200 for(i=0; i<max_order; i++)
201 ref[i] = fabs(lpc[i][i]);
209 for(pass=0; pass<lpc_passes; pass++){
213 for(i=max_order; i<blocksize; i++){
214 for(j=0; j<=max_order; j++)
215 var[j]= samples[i-j];
218 double eval, inv, rinv;
220 eval= (512>>
pass) + fabs(eval - var[0]);
223 for(j=0; j<=max_order; j++)
234 for(i=0; i<max_order; i++){
235 for(j=0; j<max_order; j++)
236 lpc[i][j]=-m[(pass-1)&1].
coeff[i][j];
237 ref[i]= sqrt(m[(pass-1)&1].variance[i] /
weight) * (blocksize - max_order) / 4000;
239 for(i=max_order-1; i>0; i--)
240 ref[i] = ref[i-1] - ref[i];
243 opt_order = max_order;
248 quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);
250 for(i=min_order-1; i<max_order; i++) {
251 quantize_lpc_coefs(lpc[i], i+1, precision, coefs[i], &shift[i], max_shift, zero_shift);