Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/g722.h @ 4:26cd8f1ef0b1
import spandsp-0.0.6pre17
| author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
|---|---|
| date | Fri, 25 Jun 2010 15:50:58 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 3:c6c5a16ce2f2 | 4:26cd8f1ef0b1 |
|---|---|
| 1 /* | |
| 2 * SpanDSP - a series of DSP components for telephony | |
| 3 * | |
| 4 * g722.h - The ITU G.722 codec. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2005 Steve Underwood | |
| 9 * | |
| 10 * All rights reserved. | |
| 11 * | |
| 12 * This program is free software; you can redistribute it and/or modify | |
| 13 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 14 * as published by the Free Software Foundation. | |
| 15 * | |
| 16 * This program is distributed in the hope that it will be useful, | |
| 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 * GNU Lesser General Public License for more details. | |
| 20 * | |
| 21 * You should have received a copy of the GNU Lesser General Public | |
| 22 * License along with this program; if not, write to the Free Software | |
| 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 24 * | |
| 25 * Based on a single channel G.722 codec which is: | |
| 26 * | |
| 27 ***** Copyright (c) CMU 1993 ***** | |
| 28 * Computer Science, Speech Group | |
| 29 * Chengxiang Lu and Alex Hauptmann | |
| 30 * | |
| 31 * $Id: g722.h,v 1.26 2009/04/12 09:12:10 steveu Exp $ | |
| 32 */ | |
| 33 | |
| 34 | |
| 35 /*! \file */ | |
| 36 | |
| 37 #if !defined(_SPANDSP_G722_H_) | |
| 38 #define _SPANDSP_G722_H_ | |
| 39 | |
| 40 /*! \page g722_page G.722 encoding and decoding | |
| 41 \section g722_page_sec_1 What does it do? | |
| 42 The G.722 module is a bit exact implementation of the ITU G.722 specification for all three | |
| 43 specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests. | |
| 44 | |
| 45 To allow fast and flexible interworking with narrow band telephony, the encoder and decoder | |
| 46 support an option for the linear audio to be an 8k samples/second stream. In this mode the | |
| 47 codec is considerably faster, and still fully compatible with wideband terminals using G.722. | |
| 48 | |
| 49 \section g722_page_sec_2 How does it work? | |
| 50 ???. | |
| 51 */ | |
| 52 | |
| 53 enum | |
| 54 { | |
| 55 G722_SAMPLE_RATE_8000 = 0x0001, | |
| 56 G722_PACKED = 0x0002 | |
| 57 }; | |
| 58 | |
| 59 /*! | |
| 60 G.722 encode state | |
| 61 */ | |
| 62 typedef struct g722_encode_state_s g722_encode_state_t; | |
| 63 | |
| 64 /*! | |
| 65 G.722 decode state | |
| 66 */ | |
| 67 typedef struct g722_decode_state_s g722_decode_state_t; | |
| 68 | |
| 69 #if defined(__cplusplus) | |
| 70 extern "C" | |
| 71 { | |
| 72 #endif | |
| 73 | |
| 74 /*! Initialise an G.722 encode context. | |
| 75 \param s The G.722 encode context. | |
| 76 \param rate The required bit rate for the G.722 data. | |
| 77 The valid rates are 64000, 56000 and 48000. | |
| 78 \param options | |
| 79 \return A pointer to the G.722 encode context, or NULL for error. */ | |
| 80 SPAN_DECLARE(g722_encode_state_t *) g722_encode_init(g722_encode_state_t *s, int rate, int options); | |
| 81 | |
| 82 /*! Release a G.722 encode context. | |
| 83 \param s The G.722 encode context. | |
| 84 \return 0 for OK. */ | |
| 85 SPAN_DECLARE(int) g722_encode_release(g722_encode_state_t *s); | |
| 86 | |
| 87 /*! Free a G.722 encode context. | |
| 88 \param s The G.722 encode context. | |
| 89 \return 0 for OK. */ | |
| 90 SPAN_DECLARE(int) g722_encode_free(g722_encode_state_t *s); | |
| 91 | |
| 92 /*! Encode a buffer of linear PCM data to G.722 | |
| 93 \param s The G.722 context. | |
| 94 \param g722_data The G.722 data produced. | |
| 95 \param amp The audio sample buffer. | |
| 96 \param len The number of samples in the buffer. | |
| 97 \return The number of bytes of G.722 data produced. */ | |
| 98 SPAN_DECLARE(int) g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len); | |
| 99 | |
| 100 /*! Initialise an G.722 decode context. | |
| 101 \param s The G.722 decode context. | |
| 102 \param rate The bit rate of the G.722 data. | |
| 103 The valid rates are 64000, 56000 and 48000. | |
| 104 \param options | |
| 105 \return A pointer to the G.722 decode context, or NULL for error. */ | |
| 106 SPAN_DECLARE(g722_decode_state_t *) g722_decode_init(g722_decode_state_t *s, int rate, int options); | |
| 107 | |
| 108 /*! Release a G.722 decode context. | |
| 109 \param s The G.722 decode context. | |
| 110 \return 0 for OK. */ | |
| 111 SPAN_DECLARE(int) g722_decode_release(g722_decode_state_t *s); | |
| 112 | |
| 113 /*! Free a G.722 decode context. | |
| 114 \param s The G.722 decode context. | |
| 115 \return 0 for OK. */ | |
| 116 SPAN_DECLARE(int) g722_decode_free(g722_decode_state_t *s); | |
| 117 | |
| 118 /*! Decode a buffer of G.722 data to linear PCM. | |
| 119 \param s The G.722 context. | |
| 120 \param amp The audio sample buffer. | |
| 121 \param g722_data | |
| 122 \param len | |
| 123 \return The number of samples returned. */ | |
| 124 SPAN_DECLARE(int) g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len); | |
| 125 | |
| 126 #if defined(__cplusplus) | |
| 127 } | |
| 128 #endif | |
| 129 | |
| 130 #endif |
