Asterisk - The Open Source Telephony Project
21.4.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
codecs
g722
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
* Despite my general liking of the GPL, I place my own contributions
11
* to this code in the public domain for the benefit of all mankind -
12
* even the slimy ones who might try to proprietize my work and use it
13
* to my detriment.
14
*
15
* Based on a single channel G.722 codec which is:
16
*
17
***** Copyright (c) CMU 1993 *****
18
* Computer Science, Speech Group
19
* Chengxiang Lu and Alex Hauptmann
20
*
21
* $Id$
22
*/
23
24
25
/*! \file */
26
27
#if !defined(_G722_H_)
28
#define _G722_H_
29
30
/*! \page g722_page G.722 encoding and decoding
31
\section g722_page_sec_1 What does it do?
32
The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
33
specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
34
35
To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
36
support an option for the linear audio to be an 8k samples/second stream. In this mode the
37
codec is considerably faster, and still fully compatible with wideband terminals using G.722.
38
39
\section g722_page_sec_2 How does it work?
40
???.
41
*/
42
43
enum
44
{
45
G722_SAMPLE_RATE_8000 = 0x0001,
46
G722_PACKED = 0x0002
47
};
48
49
#ifndef INT16_MAX
50
#define INT16_MAX 32767
51
#endif
52
#ifndef INT16_MIN
53
#define INT16_MIN (-32768)
54
#endif
55
56
typedef
struct
57
{
58
/*! TRUE if the operating in the special ITU test mode, with the band split filters
59
disabled. */
60
int
itu_test_mode
;
61
/*! TRUE if the G.722 data is packed */
62
int
packed
;
63
/*! TRUE if encode from 8k samples/second */
64
int
eight_k
;
65
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
66
int
bits_per_sample
;
67
68
/*! Signal history for the QMF */
69
int
x[24];
70
71
struct
72
{
73
int
s;
74
int
sp;
75
int
sz;
76
int
r[3];
77
int
a[3];
78
int
ap[3];
79
int
p[3];
80
int
d[7];
81
int
b[7];
82
int
bp[7];
83
int
sg[7];
84
int
nb;
85
int
det;
86
} band[2];
87
88
unsigned
int
in_buffer;
89
int
in_bits;
90
unsigned
int
out_buffer;
91
int
out_bits;
92
}
g722_encode_state_t
;
93
94
typedef
struct
95
{
96
/*! TRUE if the operating in the special ITU test mode, with the band split filters
97
disabled. */
98
int
itu_test_mode
;
99
/*! TRUE if the G.722 data is packed */
100
int
packed
;
101
/*! TRUE if decode to 8k samples/second */
102
int
eight_k
;
103
/*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
104
int
bits_per_sample
;
105
106
/*! Signal history for the QMF */
107
int
x[24];
108
109
struct
110
{
111
int
s;
112
int
sp;
113
int
sz;
114
int
r[3];
115
int
a[3];
116
int
ap[3];
117
int
p[3];
118
int
d[7];
119
int
b[7];
120
int
bp[7];
121
int
sg[7];
122
int
nb;
123
int
det;
124
} band[2];
125
126
unsigned
int
in_buffer;
127
int
in_bits;
128
unsigned
int
out_buffer;
129
int
out_bits;
130
}
g722_decode_state_t
;
131
132
#ifdef __cplusplus
133
extern
"C"
{
134
#endif
135
136
g722_encode_state_t
*g722_encode_init(
g722_encode_state_t
*s,
int
rate,
int
options);
137
int
g722_encode_release(
g722_encode_state_t
*s);
138
int
g722_encode(
g722_encode_state_t
*s, uint8_t g722_data[],
const
int16_t amp[],
int
len);
139
140
g722_decode_state_t
*g722_decode_init(
g722_decode_state_t
*s,
int
rate,
int
options);
141
int
g722_decode_release(
g722_decode_state_t
*s);
142
int
g722_decode(
g722_decode_state_t
*s, int16_t amp[],
const
uint8_t g722_data[],
int
len);
143
144
#ifdef __cplusplus
145
}
146
#endif
147
148
#endif
g722_encode_state_t::bits_per_sample
int bits_per_sample
Definition:
g722.h:66
g722_decode_state_t
Definition:
g722.h:94
g722_decode_state_t::eight_k
int eight_k
Definition:
g722.h:102
g722_encode_state_t::eight_k
int eight_k
Definition:
g722.h:64
g722_encode_state_t
Definition:
g722.h:56
g722_decode_state_t::bits_per_sample
int bits_per_sample
Definition:
g722.h:104
g722_encode_state_t::packed
int packed
Definition:
g722.h:62
g722_encode_state_t::itu_test_mode
int itu_test_mode
Definition:
g722.h:60
g722_decode_state_t::packed
int packed
Definition:
g722.h:100
g722_decode_state_t::itu_test_mode
int itu_test_mode
Definition:
g722.h:98
Generated on Tue Jul 15 2025 11:50:40 for Asterisk - The Open Source Telephony Project by
1.8.10