7 Variables, constants and tables in the C‑code of the GSM EFR codec
06.603GPPEnhanced full rate speech transcodingTS
The various components of the 12,2 kbit/s GSM enhanced full rate codec are described in the form of a fixed‑point bit‑exact ANSI C code, which is found in GSM 06.53 [6]. This C simulation is an integrated software of the speech codec, VAD/DTX, comfort noise and bad frame handler functions. In the fixed‑point ANSI C simulation, all the computations are performed using a predefined set of basic operators.
Two types of variables are used in the fixed‑point implementation. These two types are signed integers in 2’s complement representation, defined by:
Word16 16 bit variables
Word32 32 bit variables
The variables of the Word16 type are denoted var1, var2,…, varn, and those of type Word32 are denoted L_var1, L_var2,…, L_varn.
7.1 Description of the constants and variables used in the C code
The ANSI C code simulation of the codec is, to a large extent, self‑documented. However, a description of the variables and constants used in the code is given to facilitate the understanding of the code. The fixed‑point precision (in terms of Q format, double precision (DP), or normalized precision) of the vectors and variables is given, along with the vectors dimensions and constant values.
Table 3 gives the coder global constants and table 4 describes the variables and vectors used in the encoder routine with their precision. Table 5 describes the fixed tables in the codec.
Table 3: Codec global constants
Parameter 
Value 
Description 
L_TOTAL 
240 
size of speech buffer 
L_WINDOW 
240 
size of LP analysis window 
L_FRAME 
160 
size of speech frame 
L_FRAME_BY2 
80 
half the speech frame size 
L_SUBFR 
40 
size of subframe 
M 
10 
order of LP analysis 
MP1 
11 
M+1 
AZ_SIZE 
44 
4*M+4 
PIT_MAX 
143 
maximum pitch lag 
PIT_MIN 
18 
minimum pitch lag 
L_INTERPOL 
10 
order of sinc filter for interpolating 
the excitations is 2*L_INTERPOL*6+1 

PRM_SIZE 
57 
size of vector of analysis parameters 
SERIAL_SIZE 
245 
number of speech bits + bfi 
MU 
26214 
tilt compensation filter factor (0.8 in Q15) 
AGC_FAC 
29491 
automatic gain control factor (0.9 in Q15) 
Table 4: Description of the coder vectors and variables
Parameter 
Size 
Precision 
Description 
speech 
‑80..159 
Q0 
speech buffer 
wsp 
‑143..159 
Q0 
weighted speech buffer 
exc 
‑(143+11)..159 
Q0 
LP excitation 
F_gamma1 
0..9 
Q15 
spectral expansion factors 
F_gamma2 
0..9 
Q15 
spectral expansion factors 
lsp_old 
0..9 
Q15 
LSP vector in past frame 
lsp_old_q 
0..9 
Q15 
quantified LSP vector in past frame 
mem_syn 
0..9 
Q0 
memory of synthesis filter 
mem_w 
0..9 
Q0 
memory of weighting filter (applied to input) 
mem_wO 
0..9 
Q0 
memory of weighting filter (applied to error) 
error 
‑10..39 
Q0 
error signal (input minus synthesized speech) 
r_1 & r_h 
0..10 
normalized DP 
correlations of windowed speech (low and hi) 
A_t 
11×4 
Q12 
LP filter coefficients in 4 subframes 
Aq_t 
11×4 
Q12 
quantified LP filter coefficients in 4 subframes 
Ap1 
0..10 
Q12 
LP coefficients with spectral expansion 
Ap2 
0..10 
Q12 
LP coefficients with spectral expansion 
lsp_new 
0..9 
Q15 
LSP vector in 4th subframe 
lsp_new_q 
0..9 
Q15 
quantified LSP vector in 4th subframe 
lsp_mid 
0..9 
Q15 
LSP vector in 2nd subframe 
lsp_mid_q 
0..9 
Q15 
quantified LSP vector in 2nd subframe 
code 
0..39 
Q12 
fixed codebook excitation vector 
h1 
0..39 
Q12 
impulse response of weighted synthesis filter 
xn 
0..39 
Q0 
target vector in pitch search 
xn2 
0..39 
Q0 
target vector in algebraic codebook search 
dn 
0..39 
scaled max < 8192 
backward filtered target vector 
y1 
0..39 
Q0 
filtered adaptive codebook vector 
y2 
0..39 
Q12 
filtered fixed codebook vector 
zero 
0..39 
zero vector 

res2 
0..39 
long‑term prediction residual 

gain_pit 
scalar 
Q12 
adaptive codebook gain 
gain_code 
scalar 
Q0 
algebraic codebook gain 
Table 5: Codec fixed tables
Parameter 
Size 
Precision 
Description 
grid [ ] 
61 
Q15 
grid points at which Chebyshev polynomials are evaluated 
lag_h [ ] and lag_1 [ ] 
10 
DP 
higher and lower parts of the lag window table 
window_160_80 [ ] 
240 
Q15 
1st LP analysis window 
window_232_8 [ ] 
240 
Q15 
2nd LP analysis window 
table [ ] in Lsf_lsp ( ) 
65 
Q15 
table to compute cos(x) in Lsf_lsp ( ) 
slope [ ] in Lsp_lsf ( ) 
64 
Q12 
table to compute acos(x) in LSP_lsf ( ) 
table [ ] in Inv_sqrt ( ) 
49 
table used in inverse square root computation 

table [ ] in Log2 ( ) 
33 
table used in base 2 logarithm computation 

table [ ] in Pow2 ( ) 
33 
table used in 2 to the power computation 

mean_lsf [ ] 
10 
Q15 
LSF means in normalized frequency [0.0, 0.5] 
dico1_lsf [ ] 
128 x 4 
Q15 
1st LSF quantizer in normalized frequency [0.0, 0.5] 
dico2_lsf [ ] 
256 x 4 
Q15 
2nd LSF quantizer in normalized frequency [0.0, 0.5] 
dico3_lsf [ ] 
256 x 4 
Q15 
3rd LSF quantizer in normalized frequency [0.0, 0.5] 
dico4_lsf [ ] 
256 x 4 
Q15 
4th LSF quantizer in normalized frequency [0.0, 0.5] 
dico5_lsf [ ] 
64 x 4 
Q15 
5th LSF quantizer in normalized frequency [0.0, 0.5] 
qua_gain_pitch [ ] 
16 
Q14 
quantization table of adaptive codebook gain 
qua_gain_code [ ] 
32 
Q11 
quantization table of fixed codebook gain 
inter_6 [ ] in Interpol_6 ( ) 
25 
Q15 
interpolation filter coefficients in Interpol_6 ( ) 
inter_6 [ ] in Pred_lt_6 ( ) 
61 
Q15 
interpolation filter coefficients in Pred_lt_6 ( ) 
b [ ] 
3 
Q12 
HP filter coefficients (numerator) in Pre_Process ( ) 
a [ ] 
3 
Q12 
HP filter coefficients (denominator) in Pre_Process ( ) 
bitno [ ] 
57 
Q0 
number of bits corresponding to transmitted parameters 
Table 6: Source Encoder output parameters in order of occurrence
and bit allocation within the speech frame of 244 bits/20 ms
Bits (MSB‑LSB) 
Description 
s1 ‑ s7 
index of 1st LSF submatrix 
s8 ‑ s15 
index of 2nd LSF submatrix 
s16 ‑ s23 
index of 3rd LSF submatrix 
s24 
sign of 3rd LSF submatrix 
s25 ‑ s32 
index of 4th LSF submatrix 
s33 ‑ s38 
index of 5th LSF submatrix 
subframe 1 

s39 ‑ s47 
adaptive codebook index 
s48 ‑ s51 
adaptive codebook gain 
s52 
sign information for 1st and 6th pulses 
s53 ‑ s55 
position of 1st pulse 
s56 
sign information for 2nd and 7th pulses 
s57 ‑ s59 
position of 2nd pulse 
s60 
sign information for 3rd and 8th pulses 
s61 ‑ s63 
position of 3rd pulse 
s64 
sign information for 4th and 9th pulses 
s65 ‑ s67 
position of 4th pulse 
s68 
sign information for 5th and 10th pulses 
s69 ‑ s71 
position of 5th pulse 
s72 ‑ s74 
position of 6th pulse 
s75 ‑ s77 
position of 7th pulse 
s78 ‑ s80 
position of 8th pulse 
s81 ‑ s83 
position of 9th pulse 
s84 ‑ s86 
position of 10th pulse 
s87 ‑ s91 
fixed codebook gain 
subframe 2 

s92 ‑ s97 
adaptive codebook index (relative) 
s98 ‑ s141 
same description as s48 ‑ s91 
subframe 3 

s142 ‑ s194 
same description as s39 ‑ s91 
subframe 4 

s195 ‑ s244 
same description as s92 ‑ s141 