g722.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * g722.h - The ITU G.722 codec.
00005  *
00006  * Written by Steve Underwood <steveu@coppice.org>
00007  *
00008  * Copyright (C) 2005 Steve Underwood
00009  *
00010  *  Despite my general liking of the GPL, I place my own contributions 
00011  *  to this code in the public domain for the benefit of all mankind -
00012  *  even the slimy ones who might try to proprietize my work and use it
00013  *  to my detriment.
00014  *
00015  * Based on a single channel G.722 codec which is:
00016  *
00017  *****    Copyright (c) CMU    1993      *****
00018  * Computer Science, Speech Group
00019  * Chengxiang Lu and Alex Hauptmann
00020  *
00021  * $Id: g722.h 48959 2006-12-25 06:42:15Z rizzo $
00022  */
00023 
00024 
00025 /*! \file */
00026 
00027 #if !defined(_G722_H_)
00028 #define _G722_H_
00029 
00030 /*! \page g722_page G.722 encoding and decoding
00031 \section g722_page_sec_1 What does it do?
00032 The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
00033 specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
00034 
00035 To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
00036 support an option for the linear audio to be an 8k samples/second stream. In this mode the
00037 codec is considerably faster, and still fully compatible with wideband terminals using G.722.
00038 
00039 \section g722_page_sec_2 How does it work?
00040 ???.
00041 */
00042 
00043 enum
00044 {
00045     G722_SAMPLE_RATE_8000 = 0x0001,
00046     G722_PACKED = 0x0002
00047 };
00048 
00049 #ifndef INT16_MAX
00050 #define INT16_MAX       32767
00051 #endif
00052 #ifndef INT16_MIN
00053 #define INT16_MIN       (-32768)
00054 #endif
00055 
00056 typedef struct
00057 {
00058     /*! TRUE if the operating in the special ITU test mode, with the band split filters
00059              disabled. */
00060     int itu_test_mode;
00061     /*! TRUE if the G.722 data is packed */
00062     int packed;
00063     /*! TRUE if encode from 8k samples/second */
00064     int eight_k;
00065     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
00066     int bits_per_sample;
00067 
00068     /*! Signal history for the QMF */
00069     int x[24];
00070 
00071     struct
00072     {
00073         int s;
00074         int sp;
00075         int sz;
00076         int r[3];
00077         int a[3];
00078         int ap[3];
00079         int p[3];
00080         int d[7];
00081         int b[7];
00082         int bp[7];
00083         int sg[7];
00084         int nb;
00085         int det;
00086     } band[2];
00087 
00088     unsigned int in_buffer;
00089     int in_bits;
00090     unsigned int out_buffer;
00091     int out_bits;
00092 } g722_encode_state_t;
00093 
00094 typedef struct
00095 {
00096     /*! TRUE if the operating in the special ITU test mode, with the band split filters
00097              disabled. */
00098     int itu_test_mode;
00099     /*! TRUE if the G.722 data is packed */
00100     int packed;
00101     /*! TRUE if decode to 8k samples/second */
00102     int eight_k;
00103     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
00104     int bits_per_sample;
00105 
00106     /*! Signal history for the QMF */
00107     int x[24];
00108 
00109     struct
00110     {
00111         int s;
00112         int sp;
00113         int sz;
00114         int r[3];
00115         int a[3];
00116         int ap[3];
00117         int p[3];
00118         int d[7];
00119         int b[7];
00120         int bp[7];
00121         int sg[7];
00122         int nb;
00123         int det;
00124     } band[2];
00125     
00126     unsigned int in_buffer;
00127     int in_bits;
00128     unsigned int out_buffer;
00129     int out_bits;
00130 } g722_decode_state_t;
00131 
00132 #ifdef __cplusplus
00133 extern "C" {
00134 #endif
00135 
00136 g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options);
00137 int g722_encode_release(g722_encode_state_t *s);
00138 int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len);
00139 
00140 g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options);
00141 int g722_decode_release(g722_decode_state_t *s);
00142 int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len);
00143 
00144 #ifdef __cplusplus
00145 }
00146 #endif
00147 
00148 #endif

Generated on Thu Apr 16 06:27:36 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6