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

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.