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  * All rights reserved.
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU Lesser General Public License version 2.1,
00014  * as published by the Free Software Foundation.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00024  *
00025  * Based on a single channel G.722 codec which is:
00026  *
00027  *****    Copyright (c) CMU    1993      *****
00028  * Computer Science, Speech Group
00029  * Chengxiang Lu and Alex Hauptmann
00030  */
00031 
00032 
00033 /*! \file */
00034 
00035 #if !defined(_SPANDSP_G722_H_)
00036 #define _SPANDSP_G722_H_
00037 
00038 /*! \page g722_page G.722 encoding and decoding
00039 \section g722_page_sec_1 What does it do?
00040 The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
00041 specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
00042 
00043 To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
00044 support an option for the linear audio to be an 8k samples/second stream. In this mode the
00045 codec is considerably faster, and still fully compatible with wideband terminals using G.722.
00046 
00047 \section g722_page_sec_2 How does it work?
00048 ???.
00049 */
00050 
00051 enum
00052 {
00053     G722_SAMPLE_RATE_8000 = 0x0001,
00054     G722_PACKED = 0x0002
00055 };
00056 
00057 /*!
00058     G.722 encode state
00059  */
00060 typedef struct g722_encode_state_s g722_encode_state_t;
00061 
00062 /*!
00063     G.722 decode state
00064  */
00065 typedef struct g722_decode_state_s g722_decode_state_t;
00066 
00067 #if defined(__cplusplus)
00068 extern "C"
00069 {
00070 #endif
00071 
00072 /*! Initialise an G.722 encode context.
00073     \param s The G.722 encode context.
00074     \param rate The required bit rate for the G.722 data.
00075            The valid rates are 64000, 56000 and 48000.
00076     \param options
00077     \return A pointer to the G.722 encode context, or NULL for error. */
00078 SPAN_DECLARE(g722_encode_state_t *) g722_encode_init(g722_encode_state_t *s, int rate, int options);
00079 
00080 /*! Release a G.722 encode context.
00081     \param s The G.722 encode context.
00082     \return 0 for OK. */
00083 SPAN_DECLARE(int) g722_encode_release(g722_encode_state_t *s);
00084 
00085 /*! Free a G.722 encode context.
00086     \param s The G.722 encode context.
00087     \return 0 for OK. */
00088 SPAN_DECLARE(int) g722_encode_free(g722_encode_state_t *s);
00089 
00090 /*! Encode a buffer of linear PCM data to G.722
00091     \param s The G.722 context.
00092     \param g722_data The G.722 data produced.
00093     \param amp The audio sample buffer.
00094     \param len The number of samples in the buffer.
00095     \return The number of bytes of G.722 data produced. */
00096 SPAN_DECLARE(int) g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len);
00097 
00098 /*! Initialise an G.722 decode context.
00099     \param s The G.722 decode context.
00100     \param rate The bit rate of the G.722 data.
00101            The valid rates are 64000, 56000 and 48000.
00102     \param options
00103     \return A pointer to the G.722 decode context, or NULL for error. */
00104 SPAN_DECLARE(g722_decode_state_t *) g722_decode_init(g722_decode_state_t *s, int rate, int options);
00105 
00106 /*! Release a G.722 decode context.
00107     \param s The G.722 decode context.
00108     \return 0 for OK. */
00109 SPAN_DECLARE(int) g722_decode_release(g722_decode_state_t *s);
00110 
00111 /*! Free a G.722 decode context.
00112     \param s The G.722 decode context.
00113     \return 0 for OK. */
00114 SPAN_DECLARE(int) g722_decode_free(g722_decode_state_t *s);
00115 
00116 /*! Decode a buffer of G.722 data to linear PCM.
00117     \param s The G.722 context.
00118     \param amp The audio sample buffer.
00119     \param g722_data
00120     \param len
00121     \return The number of samples returned. */
00122 SPAN_DECLARE(int) g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len);
00123 
00124 #if defined(__cplusplus)
00125 }
00126 #endif
00127 
00128 #endif

Generated on 18 Oct 2012 for spandsp by  doxygen 1.6.1