GNU Radio 3.6.5 C++ API

g72x.h

Go to the documentation of this file.
00001 /*
00002  * This source code is a product of Sun Microsystems, Inc. and is provided
00003  * for unrestricted use.  Users may copy or modify this source code without
00004  * charge.
00005  *
00006  * SUN SOURCE CODE IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING
00007  * THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
00008  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
00009  *
00010  * Sun source code is provided with no support and without any obligation on
00011  * the part of Sun Microsystems, Inc. to assist in its use, correction,
00012  * modification or enhancement.
00013  *
00014  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
00015  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THIS SOFTWARE
00016  * OR ANY PART THEREOF.
00017  *
00018  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
00019  * or profits or other special, indirect and consequential damages, even if
00020  * Sun has been advised of the possibility of such damages.
00021  *
00022  * Sun Microsystems, Inc.
00023  * 2550 Garcia Avenue
00024  * Mountain View, California  94043
00025  */
00026 
00027 /*
00028  * g72x.h
00029  *
00030  * Header file for CCITT conversion routines.
00031  *
00032  */
00033 #ifndef _G72X_H
00034 #define _G72X_H
00035 
00036 #define AUDIO_ENCODING_ULAW     (1)     /* ISDN u-law */
00037 #define AUDIO_ENCODING_ALAW     (2)     /* ISDN A-law */
00038 #define AUDIO_ENCODING_LINEAR   (3)     /* PCM 2's-complement (0-center) */
00039 
00040 /*
00041  * The following is the definition of the state structure
00042  * used by the G.721/G.723 encoder and decoder to preserve their internal
00043  * state between successive calls.  The meanings of the majority
00044  * of the state structure fields are explained in detail in the
00045  * CCITT Recommendation G.721.  The field names are essentially indentical
00046  * to variable names in the bit level description of the coding algorithm
00047  * included in this Recommendation.
00048  */
00049 struct g72x_state {
00050         long yl;        /* Locked or steady state step size multiplier. */
00051         short yu;       /* Unlocked or non-steady state step size multiplier. */
00052         short dms;      /* Short term energy estimate. */
00053         short dml;      /* Long term energy estimate. */
00054         short ap;       /* Linear weighting coefficient of 'yl' and 'yu'. */
00055 
00056         short a[2];     /* Coefficients of pole portion of prediction filter. */
00057         short b[6];     /* Coefficients of zero portion of prediction filter. */
00058         short pk[2];    /*
00059                          * Signs of previous two samples of a partially
00060                          * reconstructed signal.
00061                          */
00062         short dq[6];    /*
00063                          * Previous 6 samples of the quantized difference
00064                          * signal represented in an internal floating point
00065                          * format.
00066                          */
00067         short sr[2];    /*
00068                          * Previous 2 samples of the quantized difference
00069                          * signal represented in an internal floating point
00070                          * format.
00071                          */
00072         char td;        /* delayed tone detect, new in 1988 version */
00073 };
00074 
00075 /* External function definitions. */
00076 
00077 extern void g72x_init_state(struct g72x_state *);
00078 extern int g721_encoder(
00079                 int sample,
00080                 int in_coding,
00081                 struct g72x_state *state_ptr);
00082 extern int g721_decoder(
00083                 int code,
00084                 int out_coding,
00085                 struct g72x_state *state_ptr);
00086 extern int g723_24_encoder(
00087                 int sample,
00088                 int in_coding,
00089                 struct g72x_state *state_ptr);
00090 extern int g723_24_decoder(
00091                 int code,
00092                 int out_coding,
00093                 struct g72x_state *state_ptr);
00094 extern int g723_40_encoder(
00095                 int sample,
00096                 int in_coding,
00097                 struct g72x_state *state_ptr);
00098 extern int g723_40_decoder(
00099                 int code,
00100                 int out_coding,
00101                 struct g72x_state *state_ptr);
00102 
00103 
00104 extern int
00105 quantize(
00106          int            d,
00107          int            y,
00108         short           *table,
00109         int             size);
00110 extern int reconstruct(int,int,int);void
00111 
00112 extern update(
00113         int             code_size,
00114         int             y,
00115         int             wi,
00116         int             fi,
00117         int             dq,
00118         int             sr,
00119         int             dqsez,
00120         struct g72x_state *state_ptr);
00121 extern int
00122 tandem_adjust_alaw(
00123         int             sr,
00124         int             se,
00125         int             y,
00126         int             i,
00127         int             sign,
00128         short           *qtab);
00129 
00130 extern int
00131 tandem_adjust_ulaw(
00132         int             sr,
00133         int             se,
00134         int             y,
00135         int             i,
00136         int             sign,
00137         short           *qtab);
00138 
00139 extern unsigned char
00140 linear2alaw(
00141         int             pcm_val);
00142 
00143 extern int
00144 alaw2linear(
00145         unsigned char   a_val);
00146 
00147 extern unsigned char
00148 linear2ulaw(int         pcm_val);
00149 
00150 extern int ulaw2linear( unsigned char   u_val);
00151 
00152 extern int predictor_zero(struct g72x_state *state_ptr);
00153 
00154 extern int predictor_pole(      struct g72x_state *state_ptr);
00155 extern int step_size(   struct g72x_state *state_ptr);
00156 #endif /* !_G72X_H */