GNU Radio 3.6.4.1 C++ API
g72x.h
Go to the documentation of this file.
1 /*
2  * This source code is a product of Sun Microsystems, Inc. and is provided
3  * for unrestricted use. Users may copy or modify this source code without
4  * charge.
5  *
6  * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
7  * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
8  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
9  *
10  * Sun source code is provided with no support and without any obligation on
11  * the part of Sun Microsystems, Inc. to assist in its use, correction,
12  * modification or enhancement.
13  *
14  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
15  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
16  * OR ANY PART THEREOF.
17  *
18  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
19  * or profits or other special, indirect and consequential damages, even if
20  * Sun has been advised of the possibility of such damages.
21  *
22  * Sun Microsystems, Inc.
23  * 2550 Garcia Avenue
24  * Mountain View, California 94043
25  */
26 
27 /*
28  * g72x.h
29  *
30  * Header file for CCITT conversion routines.
31  *
32  */
33 #ifndef _G72X_H
34 #define _G72X_H
35 
36 #define AUDIO_ENCODING_ULAW (1) /* ISDN u-law */
37 #define AUDIO_ENCODING_ALAW (2) /* ISDN A-law */
38 #define AUDIO_ENCODING_LINEAR (3) /* PCM 2's-complement (0-center) */
39 
40 /*
41  * The following is the definition of the state structure
42  * used by the G.721/G.723 encoder and decoder to preserve their internal
43  * state between successive calls. The meanings of the majority
44  * of the state structure fields are explained in detail in the
45  * CCITT Recommendation G.721. The field names are essentially indentical
46  * to variable names in the bit level description of the coding algorithm
47  * included in this Recommendation.
48  */
49 struct g72x_state {
50  long yl; /* Locked or steady state step size multiplier. */
51  short yu; /* Unlocked or non-steady state step size multiplier. */
52  short dms; /* Short term energy estimate. */
53  short dml; /* Long term energy estimate. */
54  short ap; /* Linear weighting coefficient of 'yl' and 'yu'. */
55 
56  short a[2]; /* Coefficients of pole portion of prediction filter. */
57  short b[6]; /* Coefficients of zero portion of prediction filter. */
58  short pk[2]; /*
59  * Signs of previous two samples of a partially
60  * reconstructed signal.
61  */
62  short dq[6]; /*
63  * Previous 6 samples of the quantized difference
64  * signal represented in an internal floating point
65  * format.
66  */
67  short sr[2]; /*
68  * Previous 2 samples of the quantized difference
69  * signal represented in an internal floating point
70  * format.
71  */
72  char td; /* delayed tone detect, new in 1988 version */
73 };
74 
75 /* External function definitions. */
76 
77 extern void g72x_init_state(struct g72x_state *);
78 extern int g721_encoder(
79  int sample,
80  int in_coding,
81  struct g72x_state *state_ptr);
82 extern int g721_decoder(
83  int code,
84  int out_coding,
85  struct g72x_state *state_ptr);
86 extern int g723_24_encoder(
87  int sample,
88  int in_coding,
89  struct g72x_state *state_ptr);
90 extern int g723_24_decoder(
91  int code,
92  int out_coding,
93  struct g72x_state *state_ptr);
94 extern int g723_40_encoder(
95  int sample,
96  int in_coding,
97  struct g72x_state *state_ptr);
98 extern int g723_40_decoder(
99  int code,
100  int out_coding,
101  struct g72x_state *state_ptr);
102 
103 
104 extern int
105 quantize(
106  int d,
107  int y,
108  short *table,
109  int size);
110 extern int reconstruct(int,int,int);void
111 
112 extern update(
113  int code_size,
114  int y,
115  int wi,
116  int fi,
117  int dq,
118  int sr,
119  int dqsez,
120  struct g72x_state *state_ptr);
121 extern int
123  int sr,
124  int se,
125  int y,
126  int i,
127  int sign,
128  short *qtab);
129 
130 extern int
132  int sr,
133  int se,
134  int y,
135  int i,
136  int sign,
137  short *qtab);
138 
139 extern unsigned char
141  int pcm_val);
142 
143 extern int
145  unsigned char a_val);
146 
147 extern unsigned char
148 linear2ulaw(int pcm_val);
149 
150 extern int ulaw2linear( unsigned char u_val);
151 
152 extern int predictor_zero(struct g72x_state *state_ptr);
153 
154 extern int predictor_pole( struct g72x_state *state_ptr);
155 extern int step_size( struct g72x_state *state_ptr);
156 #endif /* !_G72X_H */