comparison flacenc.c @ 3464:9cda085ab7cc libavcodec

dither lpc cpeffs
author michael
date Thu, 13 Jul 2006 11:41:52 +0000
parents 5d133e59ecf2
children 33af013504d5
comparison
equal deleted inserted replaced
3463:444bd402aebe 3464:9cda085ab7cc
659 */ 659 */
660 static void quantize_lpc_coefs(double *lpc_in, int order, int precision, 660 static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
661 int32_t *lpc_out, int *shift) 661 int32_t *lpc_out, int *shift)
662 { 662 {
663 int i; 663 int i;
664 double cmax; 664 double cmax, error;
665 int32_t qmax; 665 int32_t qmax;
666 int sh; 666 int sh;
667 667
668 /* define maximum levels */ 668 /* define maximum levels */
669 qmax = (1 << (precision - 1)) - 1; 669 qmax = (1 << (precision - 1)) - 1;
695 lpc_in[i] *= scale; 695 lpc_in[i] *= scale;
696 } 696 }
697 } 697 }
698 698
699 /* output quantized coefficients and level shift */ 699 /* output quantized coefficients and level shift */
700 error=0;
700 for(i=0; i<order; i++) { 701 for(i=0; i<order; i++) {
701 lpc_out[i] = (int32_t)(lpc_in[i] * (1 << sh)); 702 error += lpc_in[i] * (1 << sh);
703 lpc_out[i] = clip(lrintf(error), -qmax, qmax);
704 error -= lpc_out[i];
702 } 705 }
703 *shift = sh; 706 *shift = sh;
704 } 707 }
705 708
706 static int estimate_best_order(double *ref, int max_order) 709 static int estimate_best_order(double *ref, int max_order)