spandsp  3.0.0
g722.h
Go to the documentation of this file.
1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * g722.h - The ITU G.722 codec.
5  *
6  * Written by Steve Underwood <steveu@coppice.org>
7  *
8  * Copyright (C) 2005 Steve Underwood
9  *
10  * All rights reserved.
11  *
12  * This program is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU Lesser General Public License version 2.1,
14  * as published by the Free Software Foundation.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with this program; if not, write to the Free Software
23  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25 
26 /*! \file */
27 
28 #if !defined(_SPANDSP_G722_H_)
29 #define _SPANDSP_G722_H_
30 
31 /*! \page g722_page G.722 encoding and decoding
32 \section g722_page_sec_1 What does it do?
33 The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
34 specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
35 
36 To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
37 support an option for the linear audio to be an 8k samples/second stream. In this mode the
38 codec is considerably faster, and still fully compatible with wideband terminals using G.722.
39 
40 \section g722_page_sec_2 How does it work?
41 ???.
42 */
43 
44 enum
45 {
46  G722_SAMPLE_RATE_8000 = 0x0001,
47  G722_PACKED = 0x0002
48 };
49 
50 /*!
51  G.722 encode state
52  */
54 
55 /*!
56  G.722 decode state
57  */
59 
60 #if defined(__cplusplus)
61 extern "C"
62 {
63 #endif
64 
65 /*! Initialise an G.722 encode context.
66  \param s The G.722 encode context.
67  \param rate The required bit rate for the G.722 data.
68  The valid rates are 64000, 56000 and 48000.
69  \param options
70  \return A pointer to the G.722 encode context, or NULL for error. */
71 SPAN_DECLARE(g722_encode_state_t *) g722_encode_init(g722_encode_state_t *s, int rate, int options);
72 
73 /*! Release a G.722 encode context.
74  \param s The G.722 encode context.
75  \return 0 for OK. */
76 SPAN_DECLARE(int) g722_encode_release(g722_encode_state_t *s);
77 
78 /*! Free a G.722 encode context.
79  \param s The G.722 encode context.
80  \return 0 for OK. */
81 SPAN_DECLARE(int) g722_encode_free(g722_encode_state_t *s);
82 
83 /*! Encode a buffer of linear PCM data to G.722
84  \param s The G.722 context.
85  \param g722_data The G.722 data produced.
86  \param amp The audio sample buffer.
87  \param len The number of samples in the buffer.
88  \return The number of bytes of G.722 data produced. */
89 SPAN_DECLARE(int) g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len);
90 
91 /*! Initialise an G.722 decode context.
92  \param s The G.722 decode context.
93  \param rate The bit rate of the G.722 data.
94  The valid rates are 64000, 56000 and 48000.
95  \param options
96  \return A pointer to the G.722 decode context, or NULL for error. */
97 SPAN_DECLARE(g722_decode_state_t *) g722_decode_init(g722_decode_state_t *s, int rate, int options);
98 
99 /*! Release a G.722 decode context.
100  \param s The G.722 decode context.
101  \return 0 for OK. */
102 SPAN_DECLARE(int) g722_decode_release(g722_decode_state_t *s);
103 
104 /*! Free a G.722 decode context.
105  \param s The G.722 decode context.
106  \return 0 for OK. */
107 SPAN_DECLARE(int) g722_decode_free(g722_decode_state_t *s);
108 
109 /*! Decode a buffer of G.722 data to linear PCM.
110  \param s The G.722 context.
111  \param amp The audio sample buffer.
112  \param g722_data
113  \param len
114  \return The number of samples returned. */
115 SPAN_DECLARE(int) g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len);
116 
117 #if defined(__cplusplus)
118 }
119 #endif
120 
121 #endif
int g722_encode_release(g722_encode_state_t *s)
Definition: g722.c:464
int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len)
Definition: g722.c:477
int g722_decode_free(g722_decode_state_t *s)
Definition: g722.c:289
int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len)
Definition: g722.c:296
int g722_decode_release(g722_decode_state_t *s)
Definition: g722.c:283
g722_encode_state_t * g722_encode_init(g722_encode_state_t *s, int rate, int options)
Definition: g722.c:438
int g722_encode_free(g722_encode_state_t *s)
Definition: g722.c:470
g722_decode_state_t * g722_decode_init(g722_decode_state_t *s, int rate, int options)
Definition: g722.c:257
Definition: private/g722.h:75
Definition: private/g722.h:49