Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/g726.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 * g726.h - ITU G.726 codec. | |
| 5 * | |
| 6 * Written by Steve Underwood <steveu@coppice.org> | |
| 7 * | |
| 8 * Copyright (C) 2006 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 * $Id: g726.h,v 1.26 2009/04/12 09:12:10 steveu Exp $ | |
| 26 */ | |
| 27 | |
| 28 /*! \file */ | |
| 29 | |
| 30 #if !defined(_SPANDSP_G726_H_) | |
| 31 #define _SPANDSP_G726_H_ | |
| 32 | |
| 33 /*! \page g726_page G.726 encoding and decoding | |
| 34 \section g726_page_sec_1 What does it do? | |
| 35 | |
| 36 The G.726 module is a bit exact implementation of the full ITU G.726 specification. | |
| 37 It supports: | |
| 38 - 16 kbps, 24kbps, 32kbps, and 40kbps operation. | |
| 39 - Tandem adjustment, for interworking with A-law and u-law. | |
| 40 - Annex A support, for use in environments not using A-law or u-law. | |
| 41 | |
| 42 It passes the ITU tests. | |
| 43 | |
| 44 \section g726_page_sec_2 How does it work? | |
| 45 ???. | |
| 46 */ | |
| 47 | |
| 48 enum | |
| 49 { | |
| 50 G726_ENCODING_LINEAR = 0, /* Interworking with 16 bit signed linear */ | |
| 51 G726_ENCODING_ULAW, /* Interworking with u-law */ | |
| 52 G726_ENCODING_ALAW /* Interworking with A-law */ | |
| 53 }; | |
| 54 | |
| 55 enum | |
| 56 { | |
| 57 G726_PACKING_NONE = 0, | |
| 58 G726_PACKING_LEFT = 1, | |
| 59 G726_PACKING_RIGHT = 2 | |
| 60 }; | |
| 61 | |
| 62 /*! | |
| 63 G.726 state | |
| 64 */ | |
| 65 typedef struct g726_state_s g726_state_t; | |
| 66 | |
| 67 typedef int16_t (*g726_decoder_func_t)(g726_state_t *s, uint8_t code); | |
| 68 | |
| 69 typedef uint8_t (*g726_encoder_func_t)(g726_state_t *s, int16_t amp); | |
| 70 | |
| 71 #if defined(__cplusplus) | |
| 72 extern "C" | |
| 73 { | |
| 74 #endif | |
| 75 | |
| 76 /*! Initialise a G.726 encode or decode context. | |
| 77 \param s The G.726 context. | |
| 78 \param bit_rate The required bit rate for the ADPCM data. | |
| 79 The valid rates are 16000, 24000, 32000 and 40000. | |
| 80 \param ext_coding The coding used outside G.726. | |
| 81 \param packing One of the G.726_PACKING_xxx options. | |
| 82 \return A pointer to the G.726 context, or NULL for error. */ | |
| 83 SPAN_DECLARE(g726_state_t *) g726_init(g726_state_t *s, int bit_rate, int ext_coding, int packing); | |
| 84 | |
| 85 /*! Release a G.726 encode or decode context. | |
| 86 \param s The G.726 context. | |
| 87 \return 0 for OK. */ | |
| 88 SPAN_DECLARE(int) g726_release(g726_state_t *s); | |
| 89 | |
| 90 /*! Free a G.726 encode or decode context. | |
| 91 \param s The G.726 context. | |
| 92 \return 0 for OK. */ | |
| 93 SPAN_DECLARE(int) g726_free(g726_state_t *s); | |
| 94 | |
| 95 /*! Decode a buffer of G.726 ADPCM data to linear PCM, a-law or u-law. | |
| 96 \param s The G.726 context. | |
| 97 \param amp The audio sample buffer. | |
| 98 \param g726_data | |
| 99 \param g726_bytes | |
| 100 \return The number of samples returned. */ | |
| 101 SPAN_DECLARE(int) g726_decode(g726_state_t *s, | |
| 102 int16_t amp[], | |
| 103 const uint8_t g726_data[], | |
| 104 int g726_bytes); | |
| 105 | |
| 106 /*! Encode a buffer of linear PCM data to G.726 ADPCM. | |
| 107 \param s The G.726 context. | |
| 108 \param g726_data The G.726 data produced. | |
| 109 \param amp The audio sample buffer. | |
| 110 \param len The number of samples in the buffer. | |
| 111 \return The number of bytes of G.726 data produced. */ | |
| 112 SPAN_DECLARE(int) g726_encode(g726_state_t *s, | |
| 113 uint8_t g726_data[], | |
| 114 const int16_t amp[], | |
| 115 int len); | |
| 116 | |
| 117 #if defined(__cplusplus) | |
| 118 } | |
| 119 #endif | |
| 120 | |
| 121 #endif | |
| 122 /*- End of file ------------------------------------------------------------*/ |
