comparison flacenc.c @ 3389:de8cdb05117f libavcodec

simplify
author michael
date Sun, 02 Jul 2006 13:10:08 +0000
parents 22c7b4c96c2d
children 63a4adcaf226
comparison
equal deleted inserted replaced
3388:22c7b4c96c2d 3389:de8cdb05117f
647 */ 647 */
648 static void quantize_lpc_coefs(double *lpc_in, int order, int precision, 648 static void quantize_lpc_coefs(double *lpc_in, int order, int precision,
649 int32_t *lpc_out, int *shift) 649 int32_t *lpc_out, int *shift)
650 { 650 {
651 int i; 651 int i;
652 double d, cmax; 652 double cmax;
653 int32_t qmax; 653 int32_t qmax;
654 int sh; 654 int sh;
655 655
656 /* define maximum levels */ 656 /* define maximum levels */
657 qmax = (1 << (precision - 1)) - 1; 657 qmax = (1 << (precision - 1)) - 1;
658 658
659 /* find maximum coefficient value */ 659 /* find maximum coefficient value */
660 cmax = 0.0; 660 cmax = 0.0;
661 for(i=0; i<order; i++) { 661 for(i=0; i<order; i++) {
662 d = lpc_in[i]; 662 cmax= FFMAX(cmax, fabs(lpc_in[i]));
663 if(d < 0) d = -d;
664 if(d > cmax)
665 cmax = d;
666 } 663 }
667 664
668 /* if maximum value quantizes to zero, return all zeros */ 665 /* if maximum value quantizes to zero, return all zeros */
669 if(cmax * (1 << MAX_LPC_SHIFT) < 1.0) { 666 if(cmax * (1 << MAX_LPC_SHIFT) < 1.0) {
670 *shift = 0; 667 *shift = 0;
671 for(i=0; i<order; i++) { 668 memset(lpc_out, 0, sizeof(int32_t) * order);
672 lpc_out[i] = 0;
673 }
674 return; 669 return;
675 } 670 }
676 671
677 /* calculate level shift which scales max coeff to available bits */ 672 /* calculate level shift which scales max coeff to available bits */
678 sh = MAX_LPC_SHIFT; 673 sh = MAX_LPC_SHIFT;