2
/******************************************************************
4
iLBC Speech Coder ANSI-C Source Code
8
Copyright (C) The Internet Society (2004).
11
******************************************************************/
15
#include "iLBC_define.h"
16
#include "gainquant.h"
19
/*----------------------------------------------------------------*
20
* Convert the codebook indexes to make the search easier
21
*---------------------------------------------------------------*/
29
int *index /* (i/o) Codebook indexes */
33
for (k=1; k<CB_NSTAGES; k++) {
35
if ((index[k]>=108)&&(index[k]<172)) {
37
} else if (index[k]>=236) {
46
int *index /* (i/o) Codebook indexes */
50
for (k=1; k<CB_NSTAGES; k++) {
52
if ((index[k]>=44)&&(index[k]<108)) {
54
} else if ((index[k]>=108)&&(index[k]<128)) {
62
/*----------------------------------------------------------------*
63
* Construct decoded vector from codebook and gains.
64
*---------------------------------------------------------------*/
67
float *decvector, /* (o) Decoded vector */
68
int *index, /* (i) Codebook indices */
69
int *gain_index,/* (i) Gain quantization indices */
70
float *mem, /* (i) Buffer for codevector construction */
71
int lMem, /* (i) Length of buffer */
72
int veclen, /* (i) Length of vector */
73
int nStages /* (i) Number of codebook stages */
81
float gain[CB_NSTAGES];
84
/* gain de-quantization */
86
gain[0] = gaindequant(gain_index[0], 1.0, 32);
88
gain[1] = gaindequant(gain_index[1],
89
(float)fabs(gain[0]), 16);
92
gain[2] = gaindequant(gain_index[2],
93
(float)fabs(gain[1]), 8);
96
/* codebook vector construction and construction of
99
getCBvec(cbvec, mem, index[0], lMem, veclen);
100
for (j=0;j<veclen;j++){
101
decvector[j] = gain[0]*cbvec[j];
104
for (k=1; k<nStages; k++) {
105
getCBvec(cbvec, mem, index[k], lMem, veclen);
106
for (j=0;j<veclen;j++) {
107
decvector[j] += gain[k]*cbvec[j];