1 /*
2  * SpanDSP - a series of DSP components for telephony
3  *
4  * private/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_PRIVATE_G722_H_)
29 #define _SPANDSP_PRIVATE_G722_H_
30 
31 /*! The per band parameters for both encoding and decoding G.722 */
32 typedef struct
33 {
34     int16_t nb;
35     int16_t det;
36     int16_t s;
37     int16_t sz;
38     int16_t r;
39     int16_t p[2];
40     int16_t a[2];
41     int16_t b[6];
42     int16_t d[7];
43 } g722_band_t;
44 
45 /*!
46     G.722 encode state
47  */
48 struct g722_encode_state_s
49 {
50     /*! True if operating in the special ITU test mode, with the band split filters
51         disabled. */
52     bool itu_test_mode;
53     /*! True if the G.722 data is packed */
54     bool packed;
55     /*! True if encoding from 8k samples/second */
56     bool eight_k;
57     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
58     int bits_per_sample;
59 
60     /*! Signal history for the QMF */
61     int16_t x[12];
62     int16_t y[12];
63     int ptr;
64 
65     g722_band_t band[2];
66 
67     uint32_t out_buffer;
68     int out_bits;
69 };
70 
71 /*!
72     G.722 decode state
73  */
74 struct g722_decode_state_s
75 {
76     /*! True if operating in the special ITU test mode, with the band split filters
77         disabled. */
78     bool itu_test_mode;
79     /*! True if the G.722 data is packed */
80     bool packed;
81     /*! True if decoding to 8k samples/second */
82     bool eight_k;
83     /*! 6 for 48000kbps, 7 for 56000kbps, or 8 for 64000kbps. */
84     int bits_per_sample;
85 
86     /*! Signal history for the QMF */
87     int16_t x[12];
88     int16_t y[12];
89     int ptr;
90 
91     g722_band_t band[2];
92 
93     uint32_t in_buffer;
94     int in_bits;
95 };
96 
97 #endif
98 /*- End of file ------------------------------------------------------------*/
99