3 * Revision 1.2 1996/08/20 20:20:24 jaf
4 * Removed all static local variables that were SAVE'd in the Fortran
5 * code, and put them in struct lpc10_encoder_state that is passed as an
8 * Revision 1.1 1996/08/19 22:40:31 jaf
14 /* -- translated by f2c (version 19951025).
15 You must link the resulting object file with the libraries:
16 -lf2c -lm (in that order)
21 int chanwr_(integer
*order
, integer
*ipitv
, integer
*irms
, integer
*irc
, integer
*ibits
, struct lpc10_encoder_state
*st
);
22 int chanrd_(integer
*order
, integer
*ipitv
, integer
*irms
, integer
*irc
, integer
*ibits
);
24 /* *********************************************************************** */
26 /* CHANL Version 49 */
29 * Revision 1.2 1996/08/20 20:20:24 jaf
30 * Removed all static local variables that were SAVE'd in the Fortran
31 * code, and put them in struct lpc10_encoder_state that is passed as an
34 * Revision 1.1 1996/08/19 22:40:31 jaf
37 /* Revision 1.3 1996/03/21 15:14:57 jaf */
38 /* Added comments about which indices of argument arrays are read or */
39 /* written, and about the one bit of local state in CHANWR. CHANRD */
40 /* has no local state. */
42 /* Revision 1.2 1996/03/13 18:55:10 jaf */
43 /* Comments added explaining which of the local variables of this */
44 /* subroutine need to be saved from one invocation to the next, and which */
47 /* Revision 1.1 1996/02/07 14:43:31 jaf */
48 /* Initial revision */
51 /* *********************************************************************** */
54 /* Place quantized parameters into bitstream */
57 /* ORDER - Number of reflection coefficients (not really variable) */
58 /* IPITV - Quantized pitch/voicing parameter */
59 /* IRMS - Quantized energy parameter */
60 /* IRC - Quantized reflection coefficients */
61 /* Indices 1 through ORDER read. */
63 /* IBITS - Serial bitstream */
64 /* Indices 1 through 54 written. */
65 /* Bit 54, the SYNC bit, alternates from one call to the next. */
67 /* Subroutine CHANWR maintains one bit of local state from one call to */
68 /* the next, in the variable ISYNC. I believe that this one bit is only */
69 /* intended to allow a receiver to resynchronize its interpretation of */
70 /* the bit stream, by looking for which of the 54 bits alternates every */
71 /* frame time. This is just a simple framing mechanism that is not */
72 /* useful when other, higher overhead framing mechanisms are used to */
73 /* transmit the coded frames. */
75 /* I'm not going to make an entry to reinitialize this bit, since it */
76 /* doesn't help a receiver much to know whether the first sync bit is a 0 */
77 /* or a 1. It needs to examine several frames in sequence to have */
78 /* reasonably good assurance that its framing is correct. */
82 /* Reconstruct parameters from bitstream */
85 /* ORDER - Number of reflection coefficients (not really variable) */
86 /* IBITS - Serial bitstream */
87 /* Indices 1 through 53 read (SYNC bit is ignored). */
89 /* IPITV - Quantized pitch/voicing parameter */
90 /* IRMS - Quantized energy parameter */
91 /* IRC - Quantized reflection coefficients */
92 /* Indices 1 through ORDER written */
94 /* Entry CHANRD has no local state. */
98 /* IBITS is 54 bits of LPC data ordered as follows: */
99 /* R1-0, R2-0, R3-0, P-0, A-0, */
100 /* R1-1, R2-1, R3-1, P-1, A-1, */
101 /* R1-2, R4-0, R3-2, A-2, P-2, R4-1, */
102 /* R1-3, R2-2, R3-3, R4-2, A-3, */
103 /* R1-4, R2-3, R3-4, R4-3, A-4, */
104 /* P-3, R2-4, R7-0, R8-0, P-4, R4-4, */
105 /* R5-0, R6-0, R7-1,R10-0, R8-1, */
106 /* R5-1, R6-1, R7-2, R9-0, P-5, */
107 /* R5-2, R6-2,R10-1, R8-2, P-6, R9-1, */
108 /* R5-3, R6-3, R7-3, R9-2, R8-3, SYNC */
109 static int chanwr_0_(int n__
, integer
*order
, integer
*ipitv
,
110 integer
*irms
, integer
*irc
, integer
*ibits
,
111 struct lpc10_encoder_state
*st
)
113 /* Initialized data */
116 static integer bit
[10] = { 2,4,8,8,8,8,16,16,16,16 };
117 static integer iblist
[53] = { 13,12,11,1,2,13,12,11,1,2,13,10,11,2,1,10,
118 13,12,11,10,2,13,12,11,10,2,1,12,7,6,1,10,9,8,7,4,6,9,8,7,5,1,9,8,
121 /* System generated locals */
124 /* Local variables */
125 integer itab
[13], i__
;
128 /* Parameters/constants */
129 /* These arrays are not Fortran PARAMETER's, but they are defined */
130 /* by DATA statements below, and their contents are never altered.
132 /* Local variables that need not be saved */
134 /* ISYNC is only used by CHANWR, not by ENTRY CHANRD. */
136 /* Parameter adjustments */
142 case 1: goto L_chanrd
;
145 isync
= &(st
->isync
);
147 /* ***********************************************************************
149 /* Place quantized parameters into bitstream */
150 /* ***********************************************************************
152 /* Place parameters into ITAB */
157 for (i__
= 1; i__
<= i__1
; ++i__
) {
158 itab
[i__
+ 2] = irc
[*order
+ 1 - i__
] & 32767;
160 /* Put 54 bits into IBITS array */
161 for (i__
= 1; i__
<= 53; ++i__
) {
162 ibits
[i__
] = itab
[iblist
[i__
- 1] - 1] & 1;
163 itab
[iblist
[i__
- 1] - 1] /= 2;
165 ibits
[54] = *isync
& 1;
168 /* ***********************************************************************
170 /* Reconstruct parameters from bitstream */
171 /* ***********************************************************************
175 /* Reconstruct ITAB */
176 for (i__
= 1; i__
<= 13; ++i__
) {
179 for (i__
= 1; i__
<= 53; ++i__
) {
180 itab
[iblist
[54 - i__
- 1] - 1] = (itab
[iblist
[54 - i__
- 1] - 1] << 1)
183 /* Sign extend RC's */
185 for (i__
= 1; i__
<= i__1
; ++i__
) {
186 if ((itab
[i__
+ 2] & bit
[i__
- 1]) != 0) {
187 itab
[i__
+ 2] -= bit
[i__
- 1] << 1;
190 /* Restore variables */
194 for (i__
= 1; i__
<= i__1
; ++i__
) {
195 irc
[i__
] = itab
[*order
+ 4 - i__
- 1];
200 /* Subroutine */ int chanwr_(integer
*order
, integer
*ipitv
, integer
*irms
,
201 integer
*irc
, integer
*ibits
, struct lpc10_encoder_state
*st
)
203 return chanwr_0_(0, order
, ipitv
, irms
, irc
, ibits
, st
);
206 /* Subroutine */ int chanrd_(integer
*order
, integer
*ipitv
, integer
*irms
,
207 integer
*irc
, integer
*ibits
)
209 return chanwr_0_(1, order
, ipitv
, irms
, irc
, ibits
, 0);