non-gpl-bits/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,v 1.10 2006/06/16 12:45:53 steveu Exp $
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 typedef struct
00050 {
00051     /*! TRUE if the operating in the special ITU test mode, with the band split filters
00052              disabled. */
00053     int itu_test_mode;
00054     /*! TRUE if the G.722 data is packed */
00055     int packed;
00056     /*! TRUE if encode from 8k samples/second */
00057     int eight_k;
00058     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
00059     int bits_per_sample;
00060 
00061     /*! Signal history for the QMF */
00062     int x[24];
00063 
00064     struct
00065     {
00066         int s;
00067         int sp;
00068         int sz;
00069         int r[3];
00070         int a[3];
00071         int ap[3];
00072         int p[3];
00073         int d[7];
00074         int b[7];
00075         int bp[7];
00076         int sg[7];
00077         int nb;
00078         int det;
00079     } band[2];
00080 
00081     unsigned int in_buffer;
00082     int in_bits;
00083     unsigned int out_buffer;
00084     int out_bits;
00085 } g722_encode_state_t;
00086 
00087 typedef struct
00088 {
00089     /*! TRUE if the operating in the special ITU test mode, with the band split filters
00090              disabled. */
00091     int itu_test_mode;
00092     /*! TRUE if the G.722 data is packed */
00093     int packed;
00094     /*! TRUE if decode to 8k samples/second */
00095     int eight_k;
00096     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
00097     int bits_per_sample;
00098 
00099     /*! Signal history for the QMF */
00100     int x[24];
00101 
00102     struct
00103     {
00104         int s;
00105         int sp;
00106         int sz;
00107         int r[3];
00108         int a[3];
00109         int ap[3];
00110         int p[3];
00111         int d[7];
00112         int b[7];
00113         int bp[7];
00114         int sg[7];
00115         int nb;
00116         int det;
00117     } band[2];
00118     
00119     unsigned int in_buffer;
00120     int in_bits;
00121     unsigned int out_buffer;
00122     int out_bits;
00123 } g722_decode_state_t;
00124 
00125 #ifdef __cplusplus
00126 extern "C" {
00127 #endif
00128 
00129 g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options);
00130 int g722_encode_release(g722_encode_state_t *s);
00131 int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len);
00132 
00133 g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options);
00134 int g722_decode_release(g722_decode_state_t *s);
00135 int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len);
00136 
00137 #ifdef __cplusplus
00138 }
00139 #endif
00140 
00141 #endif

Generated on Tue Oct 7 20:25:46 2008 for spandsp by  doxygen 1.5.6