www.pudn.com > p_voice.rar > LSPGETQE.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 : LSPGETQE.C 
*/ 
 
#include "typedef.h" 
#include "ld8k.h" 
#include "ld8cp.h" 
 
/*---------------------------------------------------------------------------- 
 * lsp_get_quant - reconstruct quantized LSP parameter and check the stabilty 
 *---------------------------------------------------------------------------- 
 */ 
void lsp_get_quante( 
    FLOAT  lspcb1[][M],    /*input : first stage LSP codebook     */ 
    FLOAT  lspcb2[][M],    /*input : Second stage LSP codebook    */ 
    int    code0,          /*input : selected code of first stage */ 
    int    code1,          /*input : selected code of second stage*/ 
    int    code2,          /*input : selected code of second stage*/ 
    FLOAT  fg[][M],        /*input : MA prediction coef.          */ 
    FLOAT  freq_prev[][M], /*input : previous LSP vector          */ 
    FLOAT  lspq[],         /*output: quantized LSP parameters     */ 
    FLOAT  fg_sum[],        /*input : present MA prediction coef.  */ 
    FLOAT freq_cur[]        /* (o)  : current LSP MA vector        */ 
) 
{ 
    int  j; 
    FLOAT  buf[M]; 
     
    for(j=0; j  0) { 
            buf[j-1] -= tmp; 
            buf[j]   += tmp; 
        } 
    } 
    return; 
} 
 
/*---------------------------------------------------------------------------- 
* lsp_expand_2 - check for higher (5-9) 
*---------------------------------------------------------------------------- 
*/ 
void lsp_expand_2( 
    FLOAT  buf[],          /*in/out: lsp vectors  */ 
    FLOAT gap 
) 
{ 
    int   j; 
    FLOAT diff, tmp; 
     
    for(j=NC; j  0) { 
            buf[j-1] -= tmp; 
            buf[j]   += tmp; 
        } 
    } 
    return; 
} 
 
/*---------------------------------------------------------------------------- 
* lsp_expand_1_2 - .. 
*---------------------------------------------------------------------------- 
*/ 
void lsp_expand_1_2( 
    FLOAT  buf[],          /*in/out: LSP parameters  */ 
    FLOAT  gap             /*input      */ 
) 
{ 
    int   j; 
    FLOAT diff, tmp; 
     
    for(j=1; j  0) { 
            buf[j-1] -= tmp; 
            buf[j]   += tmp; 
        } 
    } 
    return; 
} 
 
/* 
Functions which use previous LSP parameter (freq_prev). 
*/ 
 
/* 
compose LSP parameter from elementary LSP with previous LSP. 
*/ 
void lsp_prev_compose( 
    FLOAT lsp_ele[],             /* (i)  : LSP vectors                 */ 
    FLOAT lsp[],                 /* (o)  : quantized LSP parameters    */ 
    FLOAT fg[][M],               /* (i)  : MA prediction coef.         */ 
    FLOAT freq_prev[][M],        /* (i)  : previous LSP vector         */ 
    FLOAT fg_sum[]               /* (i)  : present MA prediction coef. */ 
) 
{ 
    int j, k; 
     
    for(j=0; j 0 ; k-- ) 
        copy(freq_prev[k-1], freq_prev[k], M); 
     
    copy(lsp_ele, freq_prev[0], M); 
    return; 
} 
/*---------------------------------------------------------------------------- 
* lsp_stability - check stability of lsp coefficients 
*---------------------------------------------------------------------------- 
*/ 
void lsp_stability( 
    FLOAT  buf[]           /*in/out: LSP parameters  */ 
) 
{ 
    int   j; 
    FLOAT diff, tmp; 
     
    for(j=0; j M_LIMIT ) { 
        buf[M-1] = M_LIMIT; 
        printf("warning LSP High \n"); 
    } 
    return; 
}