comparison flacenc.c @ 5733:c2f88af57c16 libavcodec

was computing one more autocorrelation coefficient that was actually used
author lorenm
date Sat, 29 Sep 2007 07:43:52 +0000
parents d6fc148d1a48
children efa3c1f9259a
comparison
equal deleted inserted replaced
5732:d6fc148d1a48 5733:c2f88af57c16
606 */ 606 */
607 static void compute_autocorr(const int32_t *data, int len, int lag, 607 static void compute_autocorr(const int32_t *data, int len, int lag,
608 double *autoc) 608 double *autoc)
609 { 609 {
610 int i, j; 610 int i, j;
611 double tmp[len + lag]; 611 double tmp[len + lag + 1];
612 double *data1= tmp + lag; 612 double *data1= tmp + lag;
613 613
614 apply_welch_window(data, len, data1); 614 apply_welch_window(data, len, data1);
615 615
616 for(j=0; j<lag; j++) 616 for(j=0; j<lag; j++)
617 data1[j-lag]= 0.0; 617 data1[j-lag]= 0.0;
618 data1[len] = 0.0;
618 619
619 for(j=0; j<lag; j+=2){ 620 for(j=0; j<lag; j+=2){
620 double sum0 = 1.0, sum1 = 1.0; 621 double sum0 = 1.0, sum1 = 1.0;
621 for(i=0; i<len; i++){ 622 for(i=0; i<len; i++){
622 sum0 += data1[i] * data1[i-j]; 623 sum0 += data1[i] * data1[i-j];
626 autoc[j+1] = sum1; 627 autoc[j+1] = sum1;
627 } 628 }
628 629
629 if(j==lag){ 630 if(j==lag){
630 double sum = 1.0; 631 double sum = 1.0;
631 for(i=0; i<len; i++) 632 for(i=0; i<len; i+=2){
632 sum += data1[i] * data1[i-j]; 633 sum += data1[i ] * data1[i-j ]
634 + data1[i+1] * data1[i-j+1];
635 }
633 autoc[j] = sum; 636 autoc[j] = sum;
634 } 637 }
635 } 638 }
636 639
637 /** 640 /**
755 int opt_order; 758 int opt_order;
756 759
757 assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER); 760 assert(max_order >= MIN_LPC_ORDER && max_order <= MAX_LPC_ORDER);
758 761
759 if(use_lpc == 1){ 762 if(use_lpc == 1){
760 compute_autocorr(samples, blocksize, max_order+1, autoc); 763 compute_autocorr(samples, blocksize, max_order, autoc);
761 764
762 compute_lpc_coefs(autoc, max_order, lpc, ref); 765 compute_lpc_coefs(autoc, max_order, lpc, ref);
763 }else{ 766 }else{
764 LLSModel m[2]; 767 LLSModel m[2];
765 double var[MAX_LPC_ORDER+1], eval, weight; 768 double var[MAX_LPC_ORDER+1], eval, weight;