spandsp
0.0.6
Main Page
Related Pages
Classes
Files
File List
File Members
ima_adpcm.h
Go to the documentation of this file.
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
30
/*! \file */
31
32
#if !defined(_SPANDSP_IMA_ADPCM_H_)
33
#define _SPANDSP_IMA_ADPCM_H_
34
35
/*! \page ima_adpcm_page IMA/DVI/Intel ADPCM encoding and decoding
36
\section ima_adpcm_page_sec_1 What does it do?
37
IMA ADPCM offers a good balance of simplicity and quality at a rate of
38
32kbps.
39
40
\section ima_adpcm_page_sec_2 How does it work?
41
42
\section ima_adpcm_page_sec_3 How do I use it?
43
*/
44
45
enum
46
{
47
/*! IMA4 is the original IMA ADPCM variant */
48
IMA_ADPCM_IMA4
= 0,
49
/*! DVI4 is the IMA ADPCM variant defined in RFC3551 */
50
IMA_ADPCM_DVI4
= 1,
51
/*! VDVI is the variable bit rate IMA ADPCM variant defined in RFC3551 */
52
IMA_ADPCM_VDVI
= 2
53
};
54
55
/*!
56
IMA (DVI/Intel) ADPCM conversion state descriptor. This defines the state of
57
a single working instance of the IMA ADPCM converter. This is used for
58
either linear to ADPCM or ADPCM to linear conversion.
59
*/
60
typedef
struct
ima_adpcm_state_s
ima_adpcm_state_t
;
61
62
#if defined(__cplusplus)
63
extern
"C"
64
{
65
#endif
66
67
/*! Initialise an IMA ADPCM encode or decode context.
68
\param s The IMA ADPCM context.
69
\param variant IMA_ADPCM_IMA4, IMA_ADPCM_DVI4, or IMA_ADPCM_VDVI.
70
\param chunk_size The size of a chunk, in samples. A chunk size of
71
zero sample samples means treat each encode or decode operation
72
as a chunk.
73
\return A pointer to the IMA ADPCM context, or NULL for error. */
74
SPAN_DECLARE(
ima_adpcm_state_t
*)
ima_adpcm_init
(
ima_adpcm_state_t
*s,
75
int
variant,
76
int
chunk_size
);
77
78
/*! Release an IMA ADPCM encode or decode context.
79
\param s The IMA ADPCM context.
80
\return 0 for OK. */
81
SPAN_DECLARE(
int
)
ima_adpcm_release
(
ima_adpcm_state_t
*s);
82
83
/*! Free an IMA ADPCM encode or decode context.
84
\param s The IMA ADPCM context.
85
\return 0 for OK. */
86
SPAN_DECLARE(
int
)
ima_adpcm_free
(
ima_adpcm_state_t
*s);
87
88
/*! Encode a buffer of linear PCM data to IMA ADPCM.
89
\param s The IMA ADPCM context.
90
\param ima_data The IMA 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 IMA ADPCM data produced. */
94
SPAN_DECLARE(
int
)
ima_adpcm_encode
(
ima_adpcm_state_t
*s,
95
uint8_t ima_data[],
96
const int16_t amp[],
97
int
len);
98
99
/*! Decode a buffer of IMA ADPCM data to linear PCM.
100
\param s The IMA ADPCM context.
101
\param amp The audio sample buffer.
102
\param ima_data The IMA ADPCM data
103
\param ima_bytes The number of bytes of IMA ADPCM data
104
\return The number of samples returned. */
105
SPAN_DECLARE(
int
)
ima_adpcm_decode
(
ima_adpcm_state_t
*s,
106
int16_t amp[],
107
const uint8_t ima_data[],
108
int
ima_bytes);
109
110
#if defined(__cplusplus)
111
}
112
#endif
113
114
#endif
115
/*- End of file ------------------------------------------------------------*/
src
spandsp
ima_adpcm.h
Generated by
1.8.1.2