Asterisk - The Open Source Telephony Project GIT-master-0bf3178
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?
32The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
33specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
34
35To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
36support an option for the linear audio to be an 8k samples/second stream. In this mode the
37codec 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
43enum
44{
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
56typedef struct
57{
58 /*! TRUE if the operating in the special ITU test mode, with the band split filters
59 disabled. */
61 /*! TRUE if the G.722 data is packed */
62 int packed;
63 /*! TRUE if encode from 8k samples/second */
65 /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
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;
90 unsigned int out_buffer;
93
94typedef struct
95{
96 /*! TRUE if the operating in the special ITU test mode, with the band split filters
97 disabled. */
99 /*! TRUE if the G.722 data is packed */
101 /*! TRUE if decode to 8k samples/second */
103 /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
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;
128 unsigned int out_buffer;
131
132#ifdef __cplusplus
133extern "C" {
134#endif
135
138int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len);
139
142int 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
short int16_t
Definition: db.h:59
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int g722_encode_release(g722_encode_state_t *s)
Definition: g722_encode.c:178
int g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const int16_t amp[], int len)
Definition: g722_encode.c:185
g722_encode_state_t * g722_encode_init(g722_encode_state_t *s, int rate, int options)
Definition: g722_encode.c:152
int g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8_t g722_data[], int len)
Definition: g722_decode.c:186
int g722_decode_release(g722_decode_state_t *s)
Definition: g722_decode.c:179
@ G722_PACKED
Definition: g722.h:46
@ G722_SAMPLE_RATE_8000
Definition: g722.h:45
g722_decode_state_t * g722_decode_init(g722_decode_state_t *s, int rate, int options)
Definition: g722_decode.c:153
int bits_per_sample
Definition: g722.h:104
unsigned int out_buffer
Definition: g722.h:128
unsigned int in_buffer
Definition: g722.h:126
int itu_test_mode
Definition: g722.h:98
int bits_per_sample
Definition: g722.h:66
unsigned int out_buffer
Definition: g722.h:90
unsigned int in_buffer
Definition: g722.h:88
int itu_test_mode
Definition: g722.h:60
static struct test_options options
static struct test_val b
static struct test_val a
static struct test_val d