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
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.
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.
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.
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.
22 * Sun Microsystems, Inc.
24 * Mountain View, California 94043
27 #ifndef G72X_PRIVATE_H
28 #define G72X_PRIVATE_H
31 #error "This code is not designed to be compiled with a C++ compiler."
35 ** The following is the definition of the state structure used by the
36 ** G.721/G.723 encoder and decoder to preserve their internal state
37 ** between successive calls. The meanings of the majority of the state
38 ** structure fields are explained in detail in the CCITT Recommendation
39 ** G.721. The field names are essentially identical to variable names
40 ** in the bit level description of the coding algorithm included in this
45 { long yl
; /* Locked or steady state step size multiplier. */
46 short yu
; /* Unlocked or non-steady state step size multiplier. */
47 short dms
; /* Short term energy estimate. */
48 short dml
; /* Long term energy estimate. */
49 short ap
; /* Linear weighting coefficient of 'yl' and 'yu'. */
51 short a
[2]; /* Coefficients of pole portion of prediction filter. */
52 short b
[6]; /* Coefficients of zero portion of prediction filter. */
54 ** Signs of previous two samples of a partially
55 ** reconstructed signal.
58 ** Previous 6 samples of the quantized difference
59 ** signal represented in an internal floating point
63 ** Previous 2 samples of the quantized difference
64 ** signal represented in an internal floating point
67 char td
; /* delayed tone detect, new in 1988 version */
69 /* The following struct members were added for libsndfile. The original
70 ** code worked by calling a set of functions on a sample by sample basis
71 ** which is slow on architectures like Intel x86. For libsndfile, this
72 ** was changed so that the encoding and decoding routines could work on
73 ** a block of samples at a time to reduce the function call overhead.
75 int (*encoder
) (int, struct g72x_state
* state
) ;
76 int (*decoder
) (int, struct g72x_state
* state
) ;
78 int codec_bits
, blocksize
, samplesperblock
;
81 typedef struct g72x_state G72x_STATE
;
83 int predictor_zero (G72x_STATE
*state_ptr
);
85 int predictor_pole (G72x_STATE
*state_ptr
);
87 int step_size (G72x_STATE
*state_ptr
);
89 int quantize (int d
, int y
, short *table
, int size
);
91 int reconstruct (int sign
, int dqln
, int y
);
93 void update (int code_size
, int y
, int wi
, int fi
, int dq
, int sr
, int dqsez
, G72x_STATE
*state_ptr
);
95 int g721_encoder (int sample
, G72x_STATE
*state_ptr
);
96 int g721_decoder (int code
, G72x_STATE
*state_ptr
);
98 int g723_16_encoder (int sample
, G72x_STATE
*state_ptr
);
99 int g723_16_decoder (int code
, G72x_STATE
*state_ptr
);
101 int g723_24_encoder (int sample
, G72x_STATE
*state_ptr
);
102 int g723_24_decoder (int code
, G72x_STATE
*state_ptr
);
104 int g723_40_encoder (int sample
, G72x_STATE
*state_ptr
);
105 int g723_40_decoder (int code
, G72x_STATE
*state_ptr
);
107 void private_init_state (G72x_STATE
*state_ptr
) ;
109 #endif /* G72X_PRIVATE_H */