www.pudn.com > AVS_M_ver10.rar > q_gain2p.c
/* *********************************************************************** * COPYRIGHT AND WARRANTY INFORMATION * * Copyright 2007 Audio Video Coding Standard, Part ¢ú * * This software module was developed by AVS Audio sub-group * * DISCLAIMER OF WARRANTY * * These software programs are available to the users without any * license fee or royalty on an "as is" basis. The AVS disclaims * any and all warranties, whether express, implied, or statutory, * including any implied warranties of merchantability or of fitness * for a particular purpose. In no event shall the contributors or * the AVS be liable for any incidental, punitive, or consequential * damages of any kind whatsoever arising from the use of this program. * * This disclaimer of warranty extends to the user of this program * and user's customers, employees, agents, transferees, successors, * and assigns. * * The AVS does not represent or warrant that the program furnished * hereunder are free of infringement of any third-party patents. * Commercial implementations of AVS, including shareware, may be * subject to royalty fees to patent holders. Information regarding * the AVS patent policy is available from the AVS Web site at * http://www.avs.org.cn * * THIS IS NOT A GRANT OF PATENT RIGHTS - SEE THE AVS PATENT POLICY. ************************************************************************ */ /*-------------------------------------------------------------------------* * procedure q_gain2_plus * * ~~~~~~~~~~~~~~~~~~~~~~ * * Quantization of pitch and codebook gains. * * The following routines is Q_gains updated for AMR_WB_PLUS. * * MA prediction is removed and MEAN_ENER is now quantized with 2 bits and * * transmitted once every ACELP frame to the gains decoder. * * The pitch gain and the code gain are vector quantized and the * * mean-squared weighted error criterion is used in the quantizer search. * *-------------------------------------------------------------------------*/ #include#include #include "../include/amr_plus.h" #define RANGE 64 int q_gain2_plus( /* (o) : index of quantizer */ float code[], /* (i) : Innovative code vector */ int lcode, /* (i) : Subframe size */ float *gain_pit, /* (i/o): Pitch gain / Quantized pitch gain */ float *gain_code, /* (i/o): code gain / Quantized codebook gain */ float *coeff, /* (i) : correlations , -2 , */ /* , -2 and 2 */ float mean_ener, /* (i) : mean_ener defined in open-loop (2 bits) */ float *g0 /* (o) : 'correction factor' */ ) { int i, indice=0, min_ind, size; float ener_code, gcode0; float dist, dist_min, g_pitch, g_code; const float *t_qua_gain, *p; /*-----------------------------------------------------------------* * - Find the initial quantization pitch index * * - Set gains search range * *-----------------------------------------------------------------*/ t_qua_gain = E_ROM_qua_gain7b; p = (const float *) (E_ROM_qua_gain7b + RANGE); /* pt at 1/4th of table */ min_ind = 0; g_pitch = *gain_pit; for (i=0; i<(NB_QUA_GAIN7B-RANGE); i++, p+=2) { if (g_pitch > *p) { min_ind++; } } size = RANGE; min_ind=0; size=128; /* innovation energy (without gain) */ ener_code = 0.01F; for(i=0; i