FreeCalypso > hg > gsmhr-codec-ref
annotate host.c @ 6:9cbb19619a9f default tip
README: punctuation fix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 20 Aug 2024 19:00:23 +0000 |
parents | 9008dbc8ca74 |
children |
rev | line source |
---|---|
0
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * File Name: host.c |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * Purpose: Contains functions for file I/O and formatting, no signal |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * processing. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 * The functions in this file are listed below. All are level 2 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 * fuctions, where level 0 is main(), except for fillBitAlloc() which |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 * is level 3. The two "Interface" routines perform truncation of the |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 * three least significant bits of the 16 bit linear input. The others |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 * are simply file I/O functions and data reformatters. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 * fillBitAlloc() |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 * hostEncoderInterface() |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 * readDecfile() |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 * speechDecoderHostInterface() |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 * writeEncfile() |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 | Include Files | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 #include <stdio.h> |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 #include "typedefs.h" |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 * FUNCTION NAME: fillBitAlloc |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 * Arrange speech parameters for encoder output |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 * The speechcoders codewords: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 * iR0 - Frame energy |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 * piVqIndeces[0:2] - LPC vector quantizer codewords |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 * iSoftInterp - Soft interpolation bit 1 or 0 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 * iVoicing - voicing mode 0,1,2,3 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 * piLags[0:3] - Frame and delta lag codewords |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 * piCodeWrdsA[0:3] - VSELP codevector 1 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 * piCodeWrdsB[0:3] - VSELP codevector 2 (n/a for voiced modes) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 * piGsp0s[0:3] - GSP0 codewords |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 * swVadFlag - voice activity detection flag |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 * swSP - Speech flag |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 * pswBAlloc[0:20] - an array into which the coded data is moved |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 * none |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 * REFERENCES: Sub-clause 2.1 and 4.1.12 of GSM Recomendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 void fillBitAlloc(int iVoicing, int iR0, int *piVqIndeces, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 int iSoftInterp, int *piLags, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 int *piCodeWrdsA, int *piCodeWrdsB, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 int *piGsp0s, Shortword swVadFlag, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 Shortword swSP, Shortword *pswBAlloc) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 int i; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 Shortword *pswNxt; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 pswNxt = pswBAlloc; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 *pswNxt++ = iR0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 for (i = 0; i < 3; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 *pswNxt++ = *piVqIndeces++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 *pswNxt++ = iSoftInterp; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 *pswNxt++ = iVoicing; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 /* check voicing mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 if (iVoicing) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 /* voiced mode */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 for (i = 0; i < N_SUB; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 *pswNxt++ = *piLags++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 *pswNxt++ = *piCodeWrdsA++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 *pswNxt++ = *piGsp0s++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 { /* unvoiced frame */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 for (i = 0; i < N_SUB; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 *pswNxt++ = *piCodeWrdsA++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 *pswNxt++ = *piCodeWrdsB++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 *pswNxt++ = *piGsp0s++; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 *pswNxt++ = swVadFlag; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 *pswNxt++ = swSP; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 * FUNCTION NAME: hostEncoderInterface |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 * Read in speech data from a file. Zero the least significant 3 bits. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 * pfileInSpeech |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 * FILE pointer to the binary input file |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 * iNumToRead |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 * Number of samples to read from the file, typically |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 * 160 (20 ms of speech). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 * pswSamplesRead[] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 * The speech samples read in from the file. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 * iNumRead |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 * The number of samples actually read. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 * The input speech file should be in "native" format. This means that |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 * the file is to be read (by this program) and written (by another |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 * program) as short ints (not chars). |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 * If not enough samples are available in the file, the number actually |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 * read is returned. If the read fails to fill the requested iNumToRead |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 * samples, then the rest are zeroed. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 * In all cases the least significant 3 bits of all speech samples are |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 * zeroed. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 * REFERENCES: Sub-clause 4.1 of GSM Recomendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 * KEYWORDS: read, read speech, get speech data |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 int hostEncoderInterface(FILE *pfileInSpeech, int iNumToRead, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 Shortword pswSamplesRead[]) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 int iNumRead, |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 i; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 iNumRead = fread((char *) pswSamplesRead, sizeof (Shortword), |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 iNumToRead, pfileInSpeech); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 /* Delete the 3 LSB's - 13 bit speech input */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 /*------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 for (i = 0; i < iNumRead; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 pswSamplesRead[i] &= 0xfff8; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 /* Fill out the iNumToRead buffer with zeroes */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 /*--------------------------------------------*/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 if (iNumRead != iNumToRead) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 for (i = iNumRead; i < iNumToRead; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 pswSamplesRead[i] = 0; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 return (iNumRead); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 * FUNCTION NAME: readDecfile |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 * Reads decoder parameter input file |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 * INPUT: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 * infile decoder parameter input file. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 * OUTPUT: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 * pswSpeechPara array of received 16-bit values |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 * RETURN: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 * 0 successfully read a complete frame of data |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 * REFERENCES: Sub-clause 4.2 of GSM Recomendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 * KEYWORDS: pswSpeechPara |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 int readDecfile(FILE *infile, Shortword pswSpeechPara[]) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 if (fread((char *) pswSpeechPara, sizeof (Shortword), 22, infile) == 0) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 return (1); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 else |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 return (0); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 * FUNCTION NAME: speechDecoderHostInterface |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 * The purpose of this function is to truncate the linear pcm and write |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 * it into the output file |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 * INPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 * F_LEN |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 * 160 = linear pcm output frame size |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 * pswDecodedSpeechFrame[0:F_LEN-1] |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 * 16 bit linear pcm |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 * OUTPUTS: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 * fpfileSpeechOut |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 * 13 bit linear pcm stored to file given by this pointer |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 * RETURN VALUE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 * none |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 * IMPLEMENTATION: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 * REFERENCES: Sub-clause 4.2 of GSM Recomendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 * KEYWORDS: synthesis, speechdecoder, decoding, truncation |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 **************************************************************************/ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 void speechDecoderHostInterface(Shortword pswDecodedSpeechFrame[], |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 FILE *fpfileSpeechOut) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 | Local Constants | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 #define PCM_MASK 0xfff8 /* 16 to 13 bit linear PCM mask */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 | Automatic Variables | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 short int i; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 /*_________________________________________________________________________ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 | | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 | Executable Code | |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 |_________________________________________________________________________| |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 /* truncate the 16 bit linear pcm to 13 bits */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 /* ----------------------------------------- */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 for (i = 0; i < F_LEN; i++) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 pswDecodedSpeechFrame[i] = pswDecodedSpeechFrame[i] & PCM_MASK; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 /* F_LEN samples of linear pcm to output file */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 /* ------------------------------------------ */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 fwrite((char *) pswDecodedSpeechFrame, sizeof (Shortword), |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 F_LEN, fpfileSpeechOut); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 } |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 /*************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 * FUNCTION NAME: writeEncfile |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 * PURPOSE: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 * Writes encoded parameters to ouput file |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 * INPUT: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 * pswSpeechPara array of encoded parameter words. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 * OUTPUT: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 * fpfileEnc 16-bit encoded values. |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 * RETURN: |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 * i number of bytes written |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 * REFERENCES: Sub-clause 4.1 of GSM Recomendation 06.20 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 * KEYWORDS: pswSpeechPara, fpfileEnc |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 * |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 ************************************************************************** |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 */ |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 int writeEncfile(Shortword pswSpeechPara[], FILE *fpfileEnc) |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 { |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 int i; |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 i = fwrite((char *) pswSpeechPara, sizeof (Shortword), 20, fpfileEnc); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 return (i); |
9008dbc8ca74
import original C code from GSM 06.06
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 } |