06.063GPPHalf Rate Speech: ANSI-C Code for GSM Half Rate Speech CodecTS
This clause gives an overview of the structure of the bit‑exact C code and provides an overview of the contents and organization of the electronic attachment accompanying the present document.
The C code has been verified on the following systems:
‑ Sun Microsystem’s 1) workstations and Sun Microsystems acc;
‑ VAX 4) and Digital Equipment Corporations CC.
ANSI‑C 9899  was selected as the programming language because portability was desirable.
The code representation is contained in a MS‑DOS 5) file (called Disk and contained in archive en_300967v080001p0.ZIP which accompanies the present document.
4.1 Directory structure
A listing of the directories is given in table 1.
Table 1: Directory structure listing
C files and headers
1 215 563
example binary data input and output files
executables and makefiles
utility programs and the "reid" program
usage description of files
The C code file (called Disk and contained in archive en_300967v080001p0.ZIP) which accompanies the present document has one main directory and four subdirectories. The top directory has in it the file readme.txt which explains the installation procedure, along with some miscellaneous descriptive information regarding the code.
Below this directory, are the four subdirectories. The "c" subdirectory contains all the source code and header files. This directory alone is essential, the others aid in the building, or testing of the code. All ROM data is in this source directory. After installation, this directory can be made read only.
The "d" subdirectory contains all the speech coder installation verification data files. All of the data files are written/read as 16 bit words, so these may require byte swapping on the target platform. All data and text files are formatted such that they are correct for an IBM PC/AT compatible.
Final verification is to be performed using the GSM half rate test sequences described in GSM 06.07 .
The "utils" subdirectory contains miscellaneous utilities which may be useful in the installation of the software. Two programs are provided to transform text files: topcwild and tosnwild. The program topcwild takes UNIX text files and converts them to pc text files. tosnwild does the opposite. The program swapbin is also in this directory. This performs byte swapping on a binary data file. A fourth program, reid, is also contained in this sub directory. This is the residual error insertion program which also provides the format conversion between the encoder output file format and the decoder input file format.
The "exec" subdirectory contains the makefiles for the various platforms. Once the software is installed, this directory will have a compiled version of gsm_hr (the bit‑exact C executable), programs from the "utils" directory, and all the object files.
The program gsm_hr is the name of the GSM half rate codec executable file.
4.2 Program execution
The GSM half rate speech codec is implemented as two separate programs:
‑ (gsm_hr) speech codec;
‑ (reid) encoder/decoder interface.
The gsm_hr program operates in one of two modes:
‑ (0) encoding only;
‑ (1) decoding only.
For encoding, the input is a binary speech file (*.inp) and the output is a binary encoded parameter file (*.cod). For decoding, the input is a binary parameter files (*.dec) and the output is a binary synthesized speech file (*.out). Note that the format for the parameter input file required for decoding (*.dec) is not the same as the format of the parameter output file generated by encoding (*.cod). The reid program will translate an *.cod file into an *.dec file (select error‑free mode, EP0).
See the file readme.txt for more information on how to run the gsm_hr and reid programs.
4.3 Code hierarchy
Figures 1 to 7 are call graphs that show the functions used in the speech codec.
The encode call graph is broken down into six separate call graphs. Those clauses, which are large, are separated from the primary encode call tree and given their own call tree. Each vertical column represents a call level. For example, main() is at level 0, encode() at level 1, speechEncoder() at level 2, openLoopLagSearch() at level 3, getCCThreshold() at level 4, etc. The basic operations are not counted as extending the depth, therefore the deepest level is this software is level 6.
Some items have been omitted from this call graph. All standard C functions: printf(), fwrite(), etc. have been omitted. Also, no basic operations (add(), L_add(), mac(), etc.) or double precision extended operations (e.g. L_mpy_ls()) appear in the graphs.
Figure 1: Speech decoder call graph
Figure 2: Speech encoder call graph
Figure 3: Speech encoder LPC quantization call graph
Figure 4: Speech encoder open‑loop lag search call graph
Figure 5: Speech encoder subframe processing call graph
Figure 6: Comfort noise call graph
Figure 7: Voice Activity Detector (VAD) call graph