diff options
Diffstat (limited to 'tinyDAV/include/tinydav/codecs/g722')
-rw-r--r-- | tinyDAV/include/tinydav/codecs/g722/g722_enc_dec.h | 156 | ||||
-rw-r--r-- | tinyDAV/include/tinydav/codecs/g722/tdav_codec_g722.h | 44 |
2 files changed, 200 insertions, 0 deletions
diff --git a/tinyDAV/include/tinydav/codecs/g722/g722_enc_dec.h b/tinyDAV/include/tinydav/codecs/g722/g722_enc_dec.h new file mode 100644 index 0000000..efa45ec --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/g722/g722_enc_dec.h @@ -0,0 +1,156 @@ +/* + * SpanDSP - a series of DSP components for telephony + * + * g722.h - The ITU G.722 codec. + * + * Written by Steve Underwood <steveu@coppice.org> + * + * Copyright (C) 2005 Steve Underwood + * + * Despite my general liking of the GPL, I place my own contributions + * to this code in the public domain for the benefit of all mankind - + * even the slimy ones who might try to proprietize my work and use it + * to my detriment. + * + * Based on a single channel G.722 codec which is: + * + ***** Copyright (c) CMU 1993 ***** + * Computer Science, Speech Group + * Chengxiang Lu and Alex Hauptmann + * + * $Id: g722.h,v 1.10 2006/06/16 12:45:53 steveu Exp $ + * + * Modifications for WebRtc, 2011/04/28, by tlegrand: + * -Changed to use WebRtc types + * -Added new defines for minimum and maximum values of short int + */ + + +/*! \file */ + +#if !defined(_G722_ENC_DEC_H_) +#define _G722_ENC_DEC_H_ + +#include "tinydav_config.h" + +/*! \page g722_page G.722 encoding and decoding +\section g722_page_sec_1 What does it do? +The G.722 module is a bit exact implementation of the ITU G.722 specification for all three +specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. + +To allow fast and flexible interworking with narrow band telephony, the encoder and decoder +support an option for the linear audio to be an 8k samples/second stream. In this mode the +codec is considerably faster, and still fully compatible with wideband terminals using G.722. + +\section g722_page_sec_2 How does it work? +???. +*/ + +#define TDAV_INT16_MAX 32767 +#define TDAV_INT16_MIN -32768 + +enum +{ + G722_SAMPLE_RATE_8000 = 0x0001, + G722_PACKED = 0x0002 +}; + +typedef struct +{ + /*! TRUE if the operating in the special ITU test mode, with the band split filters + disabled. */ + int itu_test_mode; + /*! TRUE if the G.722 data is packed */ + int packed; + /*! TRUE if encode from 8k samples/second */ + int eight_k; + /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ + int bits_per_sample; + + /*! Signal history for the QMF */ + int x[24]; + + struct + { + int s; + int sp; + int sz; + int r[3]; + int a[3]; + int ap[3]; + int p[3]; + int d[7]; + int b[7]; + int bp[7]; + int sg[7]; + int nb; + int det; + } band[2]; + + unsigned int in_buffer; + int in_bits; + unsigned int out_buffer; + int out_bits; +} g722_encode_state_t; + +typedef struct +{ + /*! TRUE if the operating in the special ITU test mode, with the band split filters + disabled. */ + int itu_test_mode; + /*! TRUE if the G.722 data is packed */ + int packed; + /*! TRUE if decode to 8k samples/second */ + int eight_k; + /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */ + int bits_per_sample; + + /*! Signal history for the QMF */ + int x[24]; + + struct + { + int s; + int sp; + int sz; + int r[3]; + int a[3]; + int ap[3]; + int p[3]; + int d[7]; + int b[7]; + int bp[7]; + int sg[7]; + int nb; + int det; + } band[2]; + + unsigned int in_buffer; + int in_bits; + unsigned int out_buffer; + int out_bits; +} g722_decode_state_t; + +#ifdef __cplusplus +extern "C" { +#endif + +g722_encode_state_t *g722_encode_init(g722_encode_state_t *s, int rate, int options); +int g722_encode_release(g722_encode_state_t *s); +int g722_encode(g722_encode_state_t *s, + uint8_t g722_data[], + const int16_t amp[], + int len); + +g722_decode_state_t *g722_decode_init(g722_decode_state_t *s, int rate, int options); +int g722_decode_release(g722_decode_state_t *s); +int g722_decode(g722_decode_state_t *s, + int16_t amp[], + const uint8_t g722_data[], + int len); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/tinyDAV/include/tinydav/codecs/g722/tdav_codec_g722.h b/tinyDAV/include/tinydav/codecs/g722/tdav_codec_g722.h new file mode 100644 index 0000000..6484022 --- /dev/null +++ b/tinyDAV/include/tinydav/codecs/g722/tdav_codec_g722.h @@ -0,0 +1,44 @@ +/* +* Copyright (C) 2011 Doubango Telecom <http://www.doubango.org> +* +* Contact: Mamadou Diop <diopmamadou(at)doubango.org> +* +* This file is part of Open Source Doubango Framework. +* +* DOUBANGO is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* DOUBANGO is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with DOUBANGO. +* +*/ + +/**@file tdav_codec_g722.h + * @brief G.722 codec plugins. + * + * @author Mamadou Diop <diopmamadou(at)doubango.org> + * + */ +#ifndef TINYDAV_CODEC_G722_H +#define TINYDAV_CODEC_G722_H + +#include "tinydav_config.h" + +#include "tinydav/codecs/g722/g722_enc_dec.h" + +#include "tinymedia/tmedia_codec.h" + +TDAV_BEGIN_DECLS + +TINYDAV_GEXTERN const tmedia_codec_plugin_def_t *tdav_codec_g722_plugin_def_t; + +TDAV_END_DECLS + +#endif /* TINYDAV_CODEC_G722_H */ |