Debian Codegraph @

src/speech/g72x.h

raw
1 /*************************************************************************/
2 /* */
3 /* Language Technologies Institute */
4 /* Carnegie Mellon University */
5 /* Copyright (c) 2010 */
6 /* All Rights Reserved. */
7 /* */
8 /* Permission is hereby granted, free of charge, to use and distribute */
9 /* this software and its documentation without restriction, including */
10 /* without limitation the rights to use, copy, modify, merge, publish, */
11 /* distribute, sublicense, and/or sell copies of this work, and to */
12 /* permit persons to whom this work is furnished to do so, subject to */
13 /* the following conditions: */
14 /* 1. The code must retain the above copyright notice, this list of */
15 /* conditions and the following disclaimer. */
16 /* 2. Any modifications must be clearly marked as such. */
17 /* 3. Original authors' names are not deleted. */
18 /* 4. The authors' names are not used to endorse or promote products */
19 /* derived from this software without specific prior written */
20 /* permission. */
21 /* */
22 /* CARNEGIE MELLON UNIVERSITY AND THE CONTRIBUTORS TO THIS WORK */
23 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
24 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
25 /* SHALL CARNEGIE MELLON UNIVERSITY NOR THE CONTRIBUTORS BE LIABLE */
26 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
27 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
28 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
29 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
30 /* THIS SOFTWARE. */
31 /* */
32 /*************************************************************************/
33 /* Author: Alan W Black ([email protected]) */
34 /* Date: March 2001 */
35 /*************************************************************************/
36 /* */
37 /* Minor fixes to make it properly ansi and fit into cst */
38 /* */
39 /*************************************************************************/
40 /*
41 * This source code is a product of Sun Microsystems, Inc. and is provided
42 * for unrestricted use. Users may copy or modify this source code without
43 * charge.
44 *
45 * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
46 * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
47 * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
48 *
49 * Sun source code is provided with no support and without any obligation on
50 * the part of Sun Microsystems, Inc. to assist in its use, correction,
51 * modification or enhancement.
52 *
53 * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
54 * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
55 * OR ANY PART THEREOF.
56 *
57 * In no event will Sun Microsystems, Inc. be liable for any lost revenue
58 * or profits or other special, indirect and consequential damages, even if
59 * Sun has been advised of the possibility of such damages.
60 *
61 * Sun Microsystems, Inc.
62 * 2550 Garcia Avenue
63 * Mountain View, California 94043
64 */
65
66 /*
67 * g72x.h
68 *
69 * Header file for CCITT conversion routines.
70 *
71 */
72 #ifndef _G72X_H
73 #define _G72X_H
74
75 #include "cst_wave.h"
76
77
78
79 #define AUDIO_ENCODING_ULAW (1) /* ISDN u-law */
80 #define AUDIO_ENCODING_ALAW (2) /* ISDN A-law */
81 #define AUDIO_ENCODING_LINEAR (3) /* PCM 2's-complement (0-center) */
82
83 /*
84 * The following is the definition of the state structure
85 * used by the G.721/G.723 encoder and decoder to preserve their internal
86 * state between successive calls. The meanings of the majority
87 * of the state structure fields are explained in detail in the
88 * CCITT Recommendation G.721. The field names are essentially indentical
89 * to variable names in the bit level description of the coding algorithm
90 * included in this Recommendation.
91 */
92 struct g72x_state {
93 long yl; /* Locked or steady state step size multiplier. */
94 short yu; /* Unlocked or non-steady state step size multiplier. */
95 short dms; /* Short term energy estimate. */
96 short dml; /* Long term energy estimate. */
97 short ap; /* Linear weighting coefficient of 'yl' and 'yu'. */
98
99 short a[2]; /* Coefficients of pole portion of prediction filter. */
100 short b[6]; /* Coefficients of zero portion of prediction filter. */
101 short pk[2]; /*
102 * Signs of previous two samples of a partially
103 * reconstructed signal.
104 */
105 short dq[6]; /*
106 * Previous 6 samples of the quantized difference
107 * signal represented in an internal floating point
108 * format.
109 */
110 short sr[2]; /*
111 * Previous 2 samples of the quantized difference
112 * signal represented in an internal floating point
113 * format.
114 */
115 char td; /* delayed tone detect, new in 1988 version */
116 };
117
118 /* External function definitions. */
119
120 extern void g72x_init_state(struct g72x_state *);
121 extern int g721_encoder(
122 int sample,
123 int in_coding,
124 struct g72x_state *state_ptr);
125 extern int g721_decoder(
126 int code,
127 int out_coding,
128 struct g72x_state *state_ptr);
129 extern int g723_24_encoder(
130 int sample,
131 int in_coding,
132 struct g72x_state *state_ptr);
133 extern int g723_24_decoder(
134 int code,
135 int out_coding,
136 struct g72x_state *state_ptr);
137 extern int g723_40_encoder(
138 int sample,
139 int in_coding,
140 struct g72x_state *state_ptr);
141 extern int g723_40_decoder(
142 int code,
143 int out_coding,
144 struct g72x_state *state_ptr);
145
146 /* Internal functions */
147 int g72x_predictor_zero(struct g72x_state *state_ptr);
148 int g72x_predictor_pole(struct g72x_state *state_ptr);
149 int g72x_step_size(struct g72x_state *state_ptr);
150 int
151 g72x_quantize(
152 int d, /* Raw difference signal sample */
153 int y, /* Step size multiplier */
154 short *table, /* quantization table */
155 int size); /* table size of short integers */
156 int
157 g72x_reconstruct(
158 int sign, /* 0 for non-negative value */
159 int dqln, /* G.72x codeword */
160 int y); /* Step size multiplier */
161 void
162 g72x_update(
163 int code_size, /* distinguish 723_40 with others */
164 int y, /* quantizer step size */
165 int wi, /* scale factor multiplier */
166 int fi, /* for long/short term energies */
167 int dq, /* quantized prediction difference */
168 int sr, /* reconstructed signal */
169 int dqsez, /* difference from 2-pole predictor */
170 struct g72x_state *state_ptr); /* coder state pointer */
171
172
173
174 #endif /* !_G72X_H */