oki_adpcm.h

Go to the documentation of this file.
00001 /*
00002  * SpanDSP - a series of DSP components for telephony
00003  *
00004  * oki_adpcm.h - Conversion routines between linear 16 bit PCM data and
00005  *                       OKI (Dialogic) ADPCM format.
00006  *
00007  * Written by Steve Underwood <steveu@coppice.org>
00008  *
00009  * Copyright (C) 2001 Steve Underwood
00010  *
00011  * All rights reserved.
00012  *
00013  * This program is free software; you can redistribute it and/or modify
00014  * it under the terms of the GNU Lesser General Public License version 2.1,
00015  * as published by the Free Software Foundation.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU Lesser General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU Lesser General Public
00023  * License along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00025  *
00026  * $Id: oki_adpcm.h,v 1.24 2009/02/10 13:06:47 steveu Exp $
00027  */
00028 
00029 /*! \file */
00030 
00031 #if !defined(_SPANDSP_OKI_ADPCM_H_)
00032 #define _SPANDSP_OKI_ADPCM_H_
00033 
00034 /*! \page okiadpcm_page OKI (Dialogic) ADPCM encoding and decoding
00035 \section okiadpcm_page_sec_1 What does it do?
00036 OKI ADPCM is widely used in the CTI industry because it is the principal format
00037 supported by Dialogic. As the market leader, they tend to define "common
00038 practice". It offers a good balance of simplicity and quality at rates of
00039 24kbps or 32kbps. 32kbps is obtained by ADPCM compressing 8k samples/second linear
00040 PCM. 24kbps is obtained by resampling to 6k samples/second and using the same ADPCM
00041 compression algorithm on the slower samples.
00042 
00043 The algorithms for this ADPCM codec can be found in "PC Telephony - The complete guide
00044 to designing, building and programming systems using Dialogic and Related Hardware"
00045 by Bob Edgar. pg 272-276. */
00046 
00047 /*!
00048     Oki (Dialogic) ADPCM conversion state descriptor. This defines the state of
00049     a single working instance of the Oki ADPCM converter. This is used for
00050     either linear to ADPCM or ADPCM to linear conversion.
00051 */
00052 typedef struct oki_adpcm_state_s oki_adpcm_state_t;
00053 
00054 #if defined(__cplusplus)
00055 extern "C"
00056 {
00057 #endif
00058 
00059 /*! Initialise an Oki ADPCM encode or decode context.
00060     \param s The Oki ADPCM context.
00061     \param bit_rate The required bit rate for the ADPCM data.
00062            The valid rates are 24000 and 32000.
00063     \return A pointer to the Oki ADPCM context, or NULL for error. */
00064 SPAN_DECLARE(oki_adpcm_state_t *) oki_adpcm_init(oki_adpcm_state_t *s,
00065                                                  int bit_rate);
00066 
00067 /*! Release an Oki ADPCM encode or decode context.
00068     \param s The Oki ADPCM context.
00069     \return 0 for OK. */
00070 SPAN_DECLARE(int) oki_adpcm_release(oki_adpcm_state_t *s);
00071 
00072 /*! Free an Oki ADPCM encode or decode context.
00073     \param s The Oki ADPCM context.
00074     \return 0 for OK. */
00075 SPAN_DECLARE(int) oki_adpcm_free(oki_adpcm_state_t *s);
00076 
00077 /*! Decode a buffer of Oki ADPCM data to linear PCM.
00078     \param s The Oki ADPCM context.
00079     \param amp The audio sample buffer.
00080     \param oki_data
00081     \param oki_bytes
00082     \return The number of samples returned. */
00083 SPAN_DECLARE(int) oki_adpcm_decode(oki_adpcm_state_t *s,
00084                                    int16_t amp[],
00085                                    const uint8_t oki_data[],
00086                                    int oki_bytes);
00087 
00088 /*! Encode a buffer of linear PCM data to Oki ADPCM.
00089     \param s The Oki ADPCM context.
00090     \param oki_data The Oki ADPCM data produced
00091     \param amp The audio sample buffer.
00092     \param len The number of samples in the buffer.
00093     \return The number of bytes of Oki ADPCM data produced. */
00094 SPAN_DECLARE(int) oki_adpcm_encode(oki_adpcm_state_t *s,
00095                                    uint8_t oki_data[],
00096                                    const int16_t amp[],
00097                                    int len);
00098 
00099 #if defined(__cplusplus)
00100 }
00101 #endif
00102 
00103 #endif
00104 /*- End of file ------------------------------------------------------------*/

Generated on Tue Aug 4 03:36:01 2009 for spandsp by  doxygen 1.5.9