www.pudn.com > source.rar > LSPGETQ.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 : LSPGETQ.C
Used for the floating point version of both
G.729 main body and G.729A
*/
#include "typedef.h"
#include "version.h"
#ifdef VER_G729A
#include "ld8a.h"
#else
#include "ld8k.h"
#endif
/* Prototype definitions of static functions */
static void lsp_stability(
FLOAT buf[] /*in/out: LSP parameters */
);
static void lsp_prev_compose(
FLOAT lsp_ele[],
FLOAT lsp[],
FLOAT fg[][M],
FLOAT freq_prev[][M],
FLOAT fg_sum[]
);
/*----------------------------------------------------------------------------
* lsp_get_quant - reconstruct quantized LSP parameter and check the stabilty
*----------------------------------------------------------------------------
*/
void lsp_get_quant(
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. */
)
{
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.
*/
static void lsp_prev_compose(
FLOAT lsp_ele[], /* (i) Q13 : LSP vectors */
FLOAT lsp[], /* (o) Q13 : quantized LSP parameters */
FLOAT fg[][M], /* (i) Q15 : MA prediction coef. */
FLOAT freq_prev[][M], /* (i) Q13 : previous LSP vector */
FLOAT fg_sum[] /* (i) Q15 : 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
*----------------------------------------------------------------------------
*/
static 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;
}