www.pudn.com > p_voice.rar > QUA_LSPE.C


/* 
   ITU-T G.729 Annex C+ - Reference C code for floating point 
                         implementation of G.729 Annex C+ 
                         (integration of Annexes B, D and E) 
                          Version 2.1 of October 1999 
*/ 
 
/* 
 File : QUA_LSPE.C 
*/ 
 
/*----------------------------------------------------------* 
 *  qua_lsp.c                                               * 
 *  ~~~~~~~~                                                * 
 * Functions related to the quantization of LSP's           * 
 *----------------------------------------------------------*/ 
#include  
#include "typedef.h" 
#include "ld8k.h" 
#include "tab_ld8k.h" 
#include "ld8cp.h" 
#include "tabld8cp.h" 
 
/* Prototype definitions of static functions */ 
void get_wegt( FLOAT flsp[], FLOAT wegt[] ); 
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[] ); 
void qua_lspe( 
    FLOAT lsp[],       /* (i) : Unquantized LSP            */ 
    FLOAT lsp_q[],     /* (o) : Quantized LSP              */ 
    int ana[],          /* (o) : indexes                    */ 
    FLOAT freq_prev[MA_NP][M],    /* (i) : previous LSP MA vector        */ 
    FLOAT freq_cur[]   /* (o) : current LSP MA vector        */ 
) 
{ 
    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; 
}