www.pudn.com > AVS_M_ver10.rar > d_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 d_gain2_plus                                            * 
 * ~~~~~~~~~~~~~~~~~~~~~~                                            * 
 * Decoding of pitch and codebook gains  (see q_gain2_plus.c)        * 
 *-------------------------------------------------------------------* 
 * input arguments:                                                  * 
 *                                                                   * 
 *   indice     :Quantization index                                  * 
 *   code[]     :Innovative code vector                              * 
 *   lcode      :Subframe size                                       * 
 *   bfi        :Bad frame indicator                                 * 
 *                                                                   * 
 * output arguments:                                                 * 
 *                                                                   * 
 *   gain_pit   :Quantized pitch gain                                * 
 *   gain_code  :Quantized codeebook gain                            * 
 *                                                                   * 
 * Global variables defining quantizer (in qua_gns.h)                * 
 *                                                                   * 
 *   t_qua_gain[]    :Table of gain quantizers                       * 
 *   nb_qua_gain     :Nombre de quantization levels                  * 
 *                                                                   * 
 *-------------------------------------------------------------------*/ 
#include  
#include  
#include  
#include "../include/amr_plus.h" 
float d_gain2_plus( /* (o)  : 'correction factor' */ 
  int index,        /* (i)  : index of quantizer                      */ 
  float code[],     /* (i)  : Innovative code vector                  */ 
  int lcode,        /* (i)  : Subframe size                           */ 
  float *gain_pit,  /* (o)  : Quantized pitch gain                    */ 
  float *gain_code, /* (o)  : Quantized codebook gain                 */ 
  int bfi,          /* (i)  : Bad frame indicato                      */ 
  float mean_ener,  /* (i)  : mean_ener defined in open-loop (2 bits) */ 
  float *past_gpit, /* (i)  : past gain of pitch                      */ 
  float *past_gcode)/* (i/o): past gain of code                       */ 
{ 
  int   i; 
  float ener_code, gcode0; 
  const float *t_qua_gain; 
  float ener_inov, gcode_inov; 
  t_qua_gain = E_ROM_qua_gain7b; 
  ener_inov = 0.01f; 
  for(i=0; i 0.95f) { 
     *past_gpit = 0.95f; 
    } 
    if (*past_gpit < 0.5f) { 
      *past_gpit = 0.5f; 
    } 
    *gain_pit = *past_gpit; 
    *past_gpit *= 0.95f; 
    *past_gcode *= (1.4f - *past_gpit); 
    *gain_code = *past_gcode * gcode_inov; 
    return *past_gcode; 
  } 
  /*-------------- Decode gains ---------------*/ 
  /* innovation energy (without gain) */ 
  ener_code = 0.01F; 
  for(i=0; i