spandsp  0.0.6
oki_adpcm.h
Go to the documentation of this file.
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * oki_adpcm.h - Conversion routines between linear 16 bit PCM data and
5  * OKI (Dialogic) ADPCM format.
6  *
7  * Written by Steve Underwood <steveu@coppice.org>
8  *
9  * Copyright (C) 2001 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 
27 /*! \file */
28 
29 #if !defined(_SPANDSP_OKI_ADPCM_H_)
30 #define _SPANDSP_OKI_ADPCM_H_
31 
32 /*! \page okiadpcm_page OKI (Dialogic) ADPCM encoding and decoding
33 \section okiadpcm_page_sec_1 What does it do?
34 OKI ADPCM is widely used in the CTI industry because it is the principal format
35 supported by Dialogic. As the market leader, they tend to define "common
36 practice". It offers a good balance of simplicity and quality at rates of
37 24kbps or 32kbps. 32kbps is obtained by ADPCM compressing 8k samples/second linear
38 PCM. 24kbps is obtained by resampling to 6k samples/second and using the same ADPCM
39 compression algorithm on the slower samples.
40 
41 The algorithms for this ADPCM codec can be found in "PC Telephony - The complete guide
42 to designing, building and programming systems using Dialogic and Related Hardware"
43 by Bob Edgar. pg 272-276. */
44 
45 /*!
46  Oki (Dialogic) ADPCM conversion state descriptor. This defines the state of
47  a single working instance of the Oki ADPCM converter. This is used for
48  either linear to ADPCM or ADPCM to linear conversion.
49 */
51 
52 #if defined(__cplusplus)
53 extern "C"
54 {
55 #endif
56 
57 /*! Initialise an Oki ADPCM encode or decode context.
58  \param s The Oki ADPCM context.
59  \param bit_rate The required bit rate for the ADPCM data.
60  The valid rates are 24000 and 32000.
61  \return A pointer to the Oki ADPCM context, or NULL for error. */
63  int bit_rate);
64 
65 /*! Release an Oki ADPCM encode or decode context.
66  \param s The Oki ADPCM context.
67  \return 0 for OK. */
68 SPAN_DECLARE(int) oki_adpcm_release(oki_adpcm_state_t *s);
69 
70 /*! Free an Oki ADPCM encode or decode context.
71  \param s The Oki ADPCM context.
72  \return 0 for OK. */
73 SPAN_DECLARE(int) oki_adpcm_free(oki_adpcm_state_t *s);
74 
75 /*! Decode a buffer of Oki ADPCM data to linear PCM.
76  \param s The Oki ADPCM context.
77  \param amp The audio sample buffer.
78  \param oki_data
79  \param oki_bytes
80  \return The number of samples returned. */
81 SPAN_DECLARE(int) oki_adpcm_decode(oki_adpcm_state_t *s,
82  int16_t amp[],
83  const uint8_t oki_data[],
84  int oki_bytes);
85 
86 /*! Encode a buffer of linear PCM data to Oki ADPCM.
87  \param s The Oki ADPCM context.
88  \param oki_data The Oki ADPCM data produced
89  \param amp The audio sample buffer.
90  \param len The number of samples in the buffer.
91  \return The number of bytes of Oki ADPCM data produced. */
92 SPAN_DECLARE(int) oki_adpcm_encode(oki_adpcm_state_t *s,
93  uint8_t oki_data[],
94  const int16_t amp[],
95  int len);
96 
97 #if defined(__cplusplus)
98 }
99 #endif
100 
101 #endif
102 /*- End of file ------------------------------------------------------------*/
Definition: private/oki_adpcm.h:37
oki_adpcm_state_t * oki_adpcm_init(oki_adpcm_state_t *s, int bit_rate)
Definition: oki_adpcm.c:243
int oki_adpcm_release(oki_adpcm_state_t *s)
Definition: oki_adpcm.c:259
int oki_adpcm_encode(oki_adpcm_state_t *s, uint8_t oki_data[], const int16_t amp[], int len)
Definition: oki_adpcm.c:325
int oki_adpcm_decode(oki_adpcm_state_t *s, int16_t amp[], const uint8_t oki_data[], int oki_bytes)
Definition: oki_adpcm.c:272
int bit_rate
The bit rate - 24000 or 32000.
Definition: private/oki_adpcm.h:40
int oki_adpcm_free(oki_adpcm_state_t *s)
Definition: oki_adpcm.c:265