Mercurial > hg > audiostuff
comparison spandsp-0.0.6pre17/src/spandsp/ima_adpcm.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 * ima_adpcm.c - Conversion routines between linear 16 bit PCM data and | |
| 5 * IMA/DVI/Intel ADPCM format. | |
| 6 * | |
| 7 * Written by Steve Underwood <steveu@coppice.org> | |
| 8 * | |
| 9 * Copyright (C) 2004 Steve Underwood | |
| 10 * | |
| 11 * All rights reserved. | |
| 12 * | |
| 13 * This program is free software; you can redistribute it and/or modify | |
| 14 * it under the terms of the GNU Lesser General Public License version 2.1, | |
| 15 * as published by the Free Software Foundation. | |
| 16 * | |
| 17 * This program is distributed in the hope that it will be useful, | |
| 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 * GNU Lesser General Public License for more details. | |
| 21 * | |
| 22 * You should have received a copy of the GNU Lesser General Public | |
| 23 * License along with this program; if not, write to the Free Software | |
| 24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
| 25 * | |
| 26 * Based on a bit from here, a bit from there, eye of toad, | |
| 27 * ear of bat, etc - plus, of course, my own 2 cents. | |
| 28 * | |
| 29 * $Id: ima_adpcm.h,v 1.25 2009/04/11 18:11:19 steveu Exp $ | |
| 30 */ | |
| 31 | |
| 32 /*! \file */ | |
| 33 | |
| 34 #if !defined(_SPANDSP_IMA_ADPCM_H_) | |
| 35 #define _SPANDSP_IMA_ADPCM_H_ | |
| 36 | |
| 37 /*! \page ima_adpcm_page IMA/DVI/Intel ADPCM encoding and decoding | |
| 38 \section ima_adpcm_page_sec_1 What does it do? | |
| 39 IMA ADPCM offers a good balance of simplicity and quality at a rate of | |
| 40 32kbps. | |
| 41 | |
| 42 \section ima_adpcm_page_sec_2 How does it work? | |
| 43 | |
| 44 \section ima_adpcm_page_sec_3 How do I use it? | |
| 45 */ | |
| 46 | |
| 47 enum | |
| 48 { | |
| 49 /*! IMA4 is the original IMA ADPCM variant */ | |
| 50 IMA_ADPCM_IMA4 = 0, | |
| 51 /*! DVI4 is the IMA ADPCM variant defined in RFC3551 */ | |
| 52 IMA_ADPCM_DVI4 = 1, | |
| 53 /*! VDVI is the variable bit rate IMA ADPCM variant defined in RFC3551 */ | |
| 54 IMA_ADPCM_VDVI = 2 | |
| 55 }; | |
| 56 | |
| 57 /*! | |
| 58 IMA (DVI/Intel) ADPCM conversion state descriptor. This defines the state of | |
| 59 a single working instance of the IMA ADPCM converter. This is used for | |
| 60 either linear to ADPCM or ADPCM to linear conversion. | |
| 61 */ | |
| 62 typedef struct ima_adpcm_state_s ima_adpcm_state_t; | |
| 63 | |
| 64 #if defined(__cplusplus) | |
| 65 extern "C" | |
| 66 { | |
| 67 #endif | |
| 68 | |
| 69 /*! Initialise an IMA ADPCM encode or decode context. | |
| 70 \param s The IMA ADPCM context. | |
| 71 \param variant IMA_ADPCM_IMA4, IMA_ADPCM_DVI4, or IMA_ADPCM_VDVI. | |
| 72 \param chunk_size The size of a chunk, in samples. A chunk size of | |
| 73 zero sample samples means treat each encode or decode operation | |
| 74 as a chunk. | |
| 75 \return A pointer to the IMA ADPCM context, or NULL for error. */ | |
| 76 SPAN_DECLARE(ima_adpcm_state_t *) ima_adpcm_init(ima_adpcm_state_t *s, | |
| 77 int variant, | |
| 78 int chunk_size); | |
| 79 | |
| 80 /*! Release an IMA ADPCM encode or decode context. | |
| 81 \param s The IMA ADPCM context. | |
| 82 \return 0 for OK. */ | |
| 83 SPAN_DECLARE(int) ima_adpcm_release(ima_adpcm_state_t *s); | |
| 84 | |
| 85 /*! Free an IMA ADPCM encode or decode context. | |
| 86 \param s The IMA ADPCM context. | |
| 87 \return 0 for OK. */ | |
| 88 SPAN_DECLARE(int) ima_adpcm_free(ima_adpcm_state_t *s); | |
| 89 | |
| 90 /*! Encode a buffer of linear PCM data to IMA ADPCM. | |
| 91 \param s The IMA ADPCM context. | |
| 92 \param ima_data The IMA ADPCM data produced. | |
| 93 \param amp The audio sample buffer. | |
| 94 \param len The number of samples in the buffer. | |
| 95 \return The number of bytes of IMA ADPCM data produced. */ | |
| 96 SPAN_DECLARE(int) ima_adpcm_encode(ima_adpcm_state_t *s, | |
| 97 uint8_t ima_data[], | |
| 98 const int16_t amp[], | |
| 99 int len); | |
| 100 | |
| 101 /*! Decode a buffer of IMA ADPCM data to linear PCM. | |
| 102 \param s The IMA ADPCM context. | |
| 103 \param amp The audio sample buffer. | |
| 104 \param ima_data The IMA ADPCM data | |
| 105 \param ima_bytes The number of bytes of IMA ADPCM data | |
| 106 \return The number of samples returned. */ | |
| 107 SPAN_DECLARE(int) ima_adpcm_decode(ima_adpcm_state_t *s, | |
| 108 int16_t amp[], | |
| 109 const uint8_t ima_data[], | |
| 110 int ima_bytes); | |
| 111 | |
| 112 #if defined(__cplusplus) | |
| 113 } | |
| 114 #endif | |
| 115 | |
| 116 #endif | |
| 117 /*- End of file ------------------------------------------------------------*/ |
