www.pudn.com > source.rar > QUA_LSP.C


/* ITU-T G.729 Software Package Release 2 (November 2006) */ 
/* 
   ITU-T G.729 Annex C - Reference C code for floating point 
                         implementation of G.729 
                         Version 1.01 of 15.September.98 
*/ 
 
/* 
---------------------------------------------------------------------- 
                    COPYRIGHT NOTICE 
---------------------------------------------------------------------- 
   ITU-T G.729 Annex C ANSI C source code 
   Copyright (C) 1998, AT&T, France Telecom, NTT, University of 
   Sherbrooke.  All rights reserved. 
 
---------------------------------------------------------------------- 
*/ 
 
/* 
 File : QUA_LSP.C 
 Used for the floating point version of both 
 G.729 main body and G.729A 
*/ 
 
/*----------------------------------------------------------* 
 *  qua_lsp.c                                               * 
 *  ~~~~~~~~                                                * 
 * Functions related to the quantization of LSP's           * 
 *----------------------------------------------------------*/ 
#include  
#include "typedef.h" 
#include "version.h" 
#ifdef VER_G729A 
 #include "ld8a.h" 
 #include "tab_ld8a.h" 
#else 
 #include "ld8k.h" 
 #include "tab_ld8k.h" 
#endif 
 
/* Prototype definitions of static functions */ 
 
static void get_wegt( FLOAT     flsp[], FLOAT   wegt[] ); 
static void relspwed( FLOAT *lsp, FLOAT wegt[M], FLOAT *lspq, 
                     FLOAT lspcb1[][M], FLOAT lspcb2[][M], 
                     FLOAT fg[MODE][MA_NP][M], 
                     FLOAT      freq_prev[MA_NP][M], FLOAT fg_sum[MODE][M], 
                     FLOAT      fg_sum_inv[MODE][M], int cod[] ); 
static void lsp_pre_select( FLOAT rbuf[], FLOAT lspcb1[][M], int *cand); 
static void lsp_select_1( FLOAT rbuf[], FLOAT   lspcb1[], FLOAT wegt[], 
                         FLOAT  lspcb2[][M], int        *index ); 
static void lsp_select_2( FLOAT rbuf[], FLOAT   lspcb1[], FLOAT wegt[], 
                         FLOAT  lspcb2[][M], int *index ); 
static void lsp_last_select( FLOAT      tdist[MODE], int        *mode_index ); 
static void lsp_get_tdist( FLOAT        wegt[], FLOAT   buf[], 
                          FLOAT *tdist, FLOAT   rbuf[], FLOAT   fg_sum[] ); 
static void lsp_qua_cs( FLOAT *freq_in, FLOAT *freqout, int *cod); 
 
 
/* static memory */ 
static FLOAT freq_prev[MA_NP][M];    /* previous LSP vector       */ 
static FLOAT freq_prev_reset[M] = {  /* previous LSP vector(init) */ 
 (F)0.285599,  (F)0.571199,  (F)0.856798,  (F)1.142397,  (F)1.427997, 
 (F)1.713596,  (F)1.999195,  (F)2.284795,  (F)2.570394,  (F)2.855993 
};     /* PI*(float)(j+1)/(float)(M+1) */ 
 
 
void qua_lsp( 
  FLOAT lsp[],       /* (i) : Unquantized LSP            */ 
  FLOAT lsp_q[],     /* (o) : Quantized LSP              */ 
  int ana[]          /* (o) : indexes                    */ 
) 
{ 
  int i; 
  FLOAT lsf[M], lsf_q[M];  /* domain 0.0<= lsf  (F)0.0)       wegt[0] = (F)1.0; 
   else         wegt[0] = tmp * tmp * (F)10. + (F)1.0; 
 
   for ( i=1; i (F)0.0)    wegt[i] = (F)1.0; 
      else              wegt[i] = tmp * tmp * (F)10. + (F)1.0; 
   } 
 
   tmp = PI92 - flsp[M-2] - (F)1.0; 
   if (tmp > (F)0.0)       wegt[M-1] = (F)1.0; 
   else         wegt[M-1] = tmp * tmp * (F)10. + (F)1.0; 
 
   wegt[4] *= CONST12; 
   wegt[5] *= CONST12; 
   return; 
}