1 /*
2  * g722.h - The ITU G.722 codec.
3  *
4  * Written by Steve Underwood <steveu@coppice.org>
5  *
6  * Copyright (C) 2005 Steve Underwood
7  *
8  *  Despite my general liking of the GPL, I place my own contributions
9  *  to this code in the public domain for the benefit of all mankind -
10  *  even the slimy ones who might try to proprietize my work and use it
11  *  to my detriment.
12  *
13  * Based on a single channel G.722 codec which is:
14  *
15  *****    Copyright (c) CMU    1993      *****
16  * Computer Science, Speech Group
17  * Chengxiang Lu and Alex Hauptmann
18  *
19  * $Id: g722_private.h,v 1.1 2012/08/07 11:33:45 sobomax Exp $
20  */
21 
22 
23 /*! \file */
24 
25 #if !defined(_G722_PRIVATE_H_)
26 #define _G722_PRIVATE_H_
27 
28 /*! \page g722_page G.722 encoding and decoding
29 \section g722_page_sec_1 What does it do?
30 The G.722 module is a bit exact implementation of the ITU G.722 specification for all three
31 specified bit rates - 64000bps, 56000bps and 48000bps. It passes the ITU tests.
32 
33 To allow fast and flexible interworking with narrow band telephony, the encoder and decoder
34 support an option for the linear audio to be an 8k samples/second stream. In this mode the
35 codec is considerably faster, and still fully compatible with wideband terminals using G.722.
36 
37 \section g722_page_sec_2 How does it work?
38 ???.
39 */
40 
41 typedef struct g722_encode_state G722_ENC_CTX;
42 #define _G722_ENC_CTX_DEFINED
43 typedef struct g722_decode_state G722_DEC_CTX;
44 #define _G722_DEC_CTX_DEFINED
45 
46 struct g722_encode_state
47 {
48     /*! TRUE if the operating in the special ITU test mode, with the band split filters
49              disabled. */
50     int itu_test_mode;
51     /*! TRUE if the G.722 data is packed */
52     int packed;
53     /*! TRUE if encode from 8k samples/second */
54     int eight_k;
55     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
56     int bits_per_sample;
57 
58     /*! Signal history for the QMF */
59     int x[24];
60 
61     struct
62     {
63         int s;
64         int sp;
65         int sz;
66         int r[3];
67         int a[3];
68         int ap[3];
69         int p[3];
70         int d[7];
71         int b[7];
72         int bp[7];
73         int sg[7];
74         int nb;
75         int det;
76     } band[2];
77 
78     unsigned int in_buffer;
79     int in_bits;
80     unsigned int out_buffer;
81     int out_bits;
82 };
83 
84 struct g722_decode_state
85 {
86     /*! TRUE if the operating in the special ITU test mode, with the band split filters
87              disabled. */
88     int itu_test_mode;
89     /*! TRUE if the G.722 data is packed */
90     int packed;
91     /*! TRUE if decode to 8k samples/second */
92     int eight_k;
93     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
94     int bits_per_sample;
95 
96     /*! Signal history for the QMF */
97     int x[24];
98 
99     struct
100     {
101         int s;
102         int sp;
103         int sz;
104         int r[3];
105         int a[3];
106         int ap[3];
107         int p[3];
108         int d[7];
109         int b[7];
110         int bp[7];
111         int sg[7];
112         int nb;
113         int det;
114     } band[2];
115 
116     unsigned int in_buffer;
117     int in_bits;
118     unsigned int out_buffer;
119     int out_bits;
120 };
121 
122 #endif
123