FFmpeg
qdm2data.h
Go to the documentation of this file.
1 /*
2  * QDM2 compatible decoder
3  * Copyright (c) 2003 Ewald Snel
4  * Copyright (c) 2005 Benjamin Larsson
5  * Copyright (c) 2005 Alex Beregszaszi
6  * Copyright (c) 2005 Roberto Togni
7  *
8  * This file is part of FFmpeg.
9  *
10  * FFmpeg is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU Lesser General Public
12  * License as published by the Free Software Foundation; either
13  * version 2.1 of the License, or (at your option) any later version.
14  *
15  * FFmpeg is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  * Lesser General Public License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public
21  * License along with FFmpeg; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23  */
24 
25  /**
26  * @file
27  * Various QDM2 tables.
28  */
29 
30 #ifndef AVCODEC_QDM2DATA_H
31 #define AVCODEC_QDM2DATA_H
32 
33 #include <stdint.h>
34 
35 /** VLC TABLES **/
36 
37 /* values in this table range from -1..23; adjust retrieved value by -1 */
38 static const uint8_t tab_level[24][2] = {
39  { 12, 4 }, { 17, 4 }, { 1, 6 }, { 8, 6 }, { 9, 5 }, { 20, 7 },
40  { 3, 7 }, { 5, 6 }, { 6, 6 }, { 2, 7 }, { 22, 9 }, { 23, 10 },
41  { 0, 10 }, { 21, 8 }, { 11, 4 }, { 19, 5 }, { 7, 6 }, { 4, 6 },
42  { 16, 3 }, { 10, 4 }, { 18, 4 }, { 15, 3 }, { 13, 3 }, { 14, 3 },
43 };
44 
45 /* values in this table range from -1..36; adjust retrieved value by -1 */
46 static const uint8_t tab_diff[33][2] = {
47  { 2, 3 }, { 1, 3 }, { 5, 3 }, { 14, 8 }, { 20, 9 }, { 26, 10 },
48  { 25, 12 }, { 32, 12 }, { 19, 11 }, { 16, 8 }, { 24, 9 }, { 17, 9 },
49  { 12, 7 }, { 13, 7 }, { 9, 5 }, { 7, 4 }, { 3, 2 }, { 4, 3 },
50  { 8, 6 }, { 11, 6 }, { 18, 8 }, { 15, 8 }, { 30, 11 }, { 36, 13 },
51  { 34, 13 }, { 29, 13 }, { 0, 13 }, { 21, 10 }, { 28, 10 }, { 23, 10 },
52  { 22, 8 }, { 10, 6 }, { 6, 4 },
53 };
54 
55 /* values in this table range from -1..5; adjust retrieved value by -1 */
56 static const uint8_t tab_run[6][2] = {
57  { 1, 1 }, { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 0, 5 },
58 };
59 
60 /* values in this table range from -1..19; adjust retrieved value by -1 */
61 static const uint8_t tab_tone_level_idx_hi1[20][2] = {
62  { 4, 3 }, { 5, 5 }, { 9, 10 }, { 11, 11 }, { 13, 12 }, { 14, 12 },
63  { 10, 10 }, { 12, 11 }, { 17, 14 }, { 16, 14 }, { 18, 15 }, { 0, 15 },
64  { 19, 14 }, { 15, 12 }, { 8, 8 }, { 7, 7 }, { 6, 6 }, { 1, 4 },
65  { 2, 2 }, { 3, 1 },
66 };
67 
68 /* values in this table range from -1..23; adjust retrieved value by -1 */
69 static const uint8_t tab_tone_level_idx_mid[13][2] = {
70  { 18, 2 }, { 19, 4 }, { 20, 6 }, { 14, 7 }, { 21, 8 }, { 13, 9 },
71  { 22, 10 }, { 12, 11 }, { 23, 12 }, { 0, 12 }, { 15, 5 }, { 16, 3 },
72  { 17, 1 },
73 };
74 
75 /* values in this table range from -1..23; adjust retrieved value by -1 */
76 static const uint8_t tab_tone_level_idx_hi2[18][2] = {
77  { 14, 4 }, { 11, 6 }, { 19, 7 }, { 9, 7 }, { 13, 5 }, { 10, 6 },
78  { 20, 8 }, { 8, 8 }, { 6, 10 }, { 23, 11 }, { 0, 11 }, { 21, 9 },
79  { 7, 8 }, { 12, 5 }, { 18, 4 }, { 16, 2 }, { 15, 2 }, { 17, 2 },
80 };
81 
82 /* values in this table range from -1..8; adjust retrieved value by -1 */
83 static const uint8_t tab_type30[9][2] = {
84  { 2, 3 }, { 6, 4 }, { 7, 5 }, { 8, 6 }, { 0, 6 }, { 5, 3 }, { 1, 3 },
85  { 3, 2 }, { 4, 2 },
86 };
87 
88 /* values in this table range from -1..9; adjust retrieved value by -1 */
89 static const uint8_t tab_type34[10][2] = {
90  { 1, 4 }, { 9, 5 }, { 0, 5 }, { 3, 3 }, { 7, 3 }, { 8, 3 }, { 2, 3 },
91  { 4, 3 }, { 6, 3 }, { 5, 3 },
92 };
93 
95  23, 28, 31, 34, 37
96 };
97 
98 static const uint8_t tab_fft_tone_offset[][2] = {
99  /* First table - 23 entries with range -1..21 */
100  { 2, 2 }, { 7, 7 }, { 15, 8 }, { 21, 8 }, { 3, 6 }, { 6, 6 },
101  { 13, 7 }, { 14, 8 }, { 18, 8 }, { 4, 4 }, { 5, 5 }, { 11, 7 },
102  { 10, 7 }, { 20, 6 }, { 12, 8 }, { 16, 9 }, { 22, 10 }, { 0, 10 },
103  { 17, 7 }, { 19, 6 }, { 8, 6 }, { 9, 6 }, { 1, 1 },
104  /* Second table - 28 entries with range -1..26 */
105  { 8, 6 }, { 2, 6 }, { 7, 6 }, { 23, 7 }, { 12, 7 }, { 5, 4 },
106  { 10, 6 }, { 20, 8 }, { 25, 9 }, { 26, 10 }, { 27, 11 }, { 0, 11 },
107  { 22, 7 }, { 9, 5 }, { 13, 6 }, { 17, 6 }, { 4, 5 }, { 14, 6 },
108  { 19, 7 }, { 24, 7 }, { 3, 6 }, { 11, 6 }, { 21, 6 }, { 18, 6 },
109  { 16, 6 }, { 15, 6 }, { 6, 3 }, { 1, 1 },
110  /* Third table - 31 entries with range -1..30 (1 omitted) */
111  { 14, 7 }, { 17, 7 }, { 15, 7 }, { 23, 9 }, { 28, 10 }, { 29, 11 },
112  { 30, 13 }, { 0, 13 }, { 31, 12 }, { 25, 8 }, { 10, 5 }, { 8, 4 },
113  { 9, 4 }, { 4, 4 }, { 22, 8 }, { 3, 8 }, { 21, 8 }, { 26, 9 },
114  { 27, 9 }, { 12, 6 }, { 11, 5 }, { 16, 7 }, { 18, 7 }, { 20, 8 },
115  { 24, 8 }, { 19, 7 }, { 13, 5 }, { 5, 3 }, { 1, 2 }, { 6, 3 },
116  { 7, 3 },
117  /* Fourth table - 34 entries with range -1..33 (1 omitted) */
118  { 4, 4 }, { 7, 4 }, { 10, 4 }, { 3, 10 }, { 27, 10 }, { 29, 10 },
119  { 28, 10 }, { 22, 8 }, { 21, 7 }, { 15, 6 }, { 14, 5 }, { 8, 4 },
120  { 16, 6 }, { 19, 7 }, { 23, 8 }, { 26, 9 }, { 30, 10 }, { 33, 13 },
121  { 34, 14 }, { 0, 14 }, { 32, 12 }, { 31, 11 }, { 12, 5 }, { 5, 3 },
122  { 9, 3 }, { 1, 4 }, { 20, 7 }, { 25, 8 }, { 24, 8 }, { 18, 6 },
123  { 17, 5 }, { 6, 3 }, { 11, 4 }, { 13, 4 },
124  /* Fifth table - 37 entries with range -1..36 (1 omitted) */
125  { 5, 3 }, { 4, 3 }, { 19, 8 }, { 33, 12 }, { 31, 12 }, { 28, 11 },
126  { 34, 14 }, { 37, 14 }, { 35, 15 }, { 0, 15 }, { 36, 14 }, { 32, 12 },
127  { 30, 11 }, { 24, 9 }, { 22, 8 }, { 23, 9 }, { 29, 10 }, { 27, 10 },
128  { 17, 6 }, { 14, 5 }, { 7, 4 }, { 12, 5 }, { 1, 6 }, { 26, 9 },
129  { 3, 9 }, { 25, 8 }, { 20, 7 }, { 8, 4 }, { 10, 4 }, { 13, 4 },
130  { 15, 6 }, { 16, 6 }, { 18, 6 }, { 21, 6 }, { 11, 4 }, { 9, 3 },
131  { 6, 3 },
132 };
133 
134 /** FFT TABLES **/
135 
136 /* values in this table range from -1..27; adjust retrieved value by -1 */
137 static const uint8_t fft_level_exp_alt[28][2] = {
138  { 18, 3 }, { 16, 3 }, { 22, 7 }, { 8, 10 }, { 4, 10 }, { 3, 9 },
139  { 2, 8 }, { 23, 8 }, { 10, 8 }, { 11, 7 }, { 21, 5 }, { 20, 4 },
140  { 1, 7 }, { 7, 10 }, { 5, 10 }, { 9, 9 }, { 6, 10 }, { 25, 11 },
141  { 26, 12 }, { 27, 13 }, { 0, 13 }, { 24, 9 }, { 12, 6 }, { 13, 5 },
142  { 14, 4 }, { 19, 3 }, { 15, 3 }, { 17, 2 },
143 };
144 
145 /* values in this table range from -1..19; adjust retrieved value by -1 */
146 static const uint8_t fft_level_exp[20][2] = {
147  { 3, 3 }, { 11, 6 }, { 16, 9 }, { 17, 10 }, { 18, 11 }, { 19, 12 },
148  { 0, 12 }, { 15, 8 }, { 14, 7 }, { 9, 5 }, { 7, 4 }, { 2, 3 },
149  { 4, 3 }, { 1, 3 }, { 5, 3 }, { 12, 6 }, { 13, 6 }, { 10, 5 },
150  { 8, 4 }, { 6, 3 },
151 };
152 
153 /* values in this table range from -1..6; adjust retrieved value by -1 */
154 static const uint8_t fft_stereo_exp[7][2] = {
155  { 2, 2 }, { 3, 3 }, { 4, 4 }, { 5, 5 }, { 6, 6 }, { 0, 6 }, { 1, 1 },
156 };
157 
158 /* values in this table range from -1..8; adjust retrieved value by -1 */
159 static const uint8_t fft_stereo_phase[9][2] = {
160  { 2, 2 }, { 1, 2 }, { 3, 4 }, { 7, 4 }, { 6, 5 }, { 5, 6 }, { 0, 6 },
161  { 4, 4 }, { 8, 2 },
162 };
163 
164 static const int fft_cutoff_index_table[4][2] = {
165  { 1, 2 }, {-1, 0 }, {-1,-2 }, { 0, 0 }
166 };
167 
168 static const int16_t fft_level_index_table[256] = {
169  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
170  2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
171  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
172  3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
173  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
174  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
175  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
176  4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
177  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
178  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
179  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
180  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
181  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
182  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
183  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
184  5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
185 };
186 
187 static const uint8_t last_coeff[3] = {
188  4, 7, 10
189 };
190 
191 static const uint8_t coeff_per_sb_for_avg[3][30] = {
192  { 0, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
193  { 0, 1, 2, 2, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
194  { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9 }
195 };
196 
197 static const uint32_t dequant_table[3][10][30] = {
198  { { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
199  { 0, 256, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
200  { 0, 0, 0, 51, 102, 154, 205, 256, 238, 219, 201, 183, 165, 146, 128, 110, 91, 73, 55, 37, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
201  { 0, 0, 0, 0, 0, 0, 0, 0, 18, 37, 55, 73, 91, 110, 128, 146, 165, 183, 201, 219, 238, 256, 228, 199, 171, 142, 114, 85, 57, 28 },
202  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
203  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
204  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
205  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
206  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
207  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
208  { { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
209  { 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
210  { 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
211  { 0, 0, 0, 85, 171, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
212  { 0, 0, 0, 0, 0, 0, 85, 171, 256, 219, 183, 146, 110, 73, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
213  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 73, 110, 146, 183, 219, 256, 228, 199, 171, 142, 114, 85, 57, 28, 0, 0, 0, 0, 0, 0 },
214  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 57, 85, 114, 142, 171, 199, 228, 256, 213, 171, 128, 85, 43 },
215  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
216  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
217  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } },
218  { { 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
219  { 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
220  { 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
221  { 0, 0, 0, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
222  { 0, 0, 0, 0, 256, 256, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
223  { 0, 0, 0, 0, 0, 0, 256, 171, 85, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
224  { 0, 0, 0, 0, 0, 0, 0, 85, 171, 256, 192, 128, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
225  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 128, 192, 256, 205, 154, 102, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
226  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 102, 154, 205, 256, 213, 171, 128, 85, 43, 0, 0, 0, 0, 0, 0 },
227  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 85, 128, 171, 213, 256, 213, 171, 128, 85, 43 } }
228 };
229 
230 static const uint8_t coeff_per_sb_for_dequant[3][30] = {
231  { 0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3 },
232  { 0, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6 },
233  { 0, 1, 2, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9 }
234 };
235 
236 /* first index is subband, 2nd index is 0, 1 or 3 (2 is unused) */
237 static const int8_t tone_level_idx_offset_table[30][4] = {
238  { -50, -50, 0, -50 },
239  { -50, -50, 0, -50 },
240  { -50, -9, 0, -19 },
241  { -16, -6, 0, -12 },
242  { -11, -4, 0, -8 },
243  { -8, -3, 0, -6 },
244  { -7, -3, 0, -5 },
245  { -6, -2, 0, -4 },
246  { -5, -2, 0, -3 },
247  { -4, -1, 0, -3 },
248  { -4, -1, 0, -2 },
249  { -3, -1, 0, -2 },
250  { -3, -1, 0, -2 },
251  { -3, -1, 0, -2 },
252  { -2, -1, 0, -1 },
253  { -2, -1, 0, -1 },
254  { -2, -1, 0, -1 },
255  { -2, 0, 0, -1 },
256  { -2, 0, 0, -1 },
257  { -1, 0, 0, -1 },
258  { -1, 0, 0, -1 },
259  { -1, 0, 0, -1 },
260  { -1, 0, 0, -1 },
261  { -1, 0, 0, -1 },
262  { -1, 0, 0, -1 },
263  { -1, 0, 0, -1 },
264  { -1, 0, 0, 0 },
265  { -1, 0, 0, 0 },
266  { -1, 0, 0, 0 },
267  { -1, 0, 0, 0 }
268 };
269 
270 /* all my samples have 1st index 0 or 1 */
271 /* second index is subband, only indexes 0-29 seem to be used */
272 static const int8_t coding_method_table[5][30] = {
273  { 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
274  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
275  },
276  { 34, 30, 24, 24, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10,
277  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
278  },
279  { 34, 30, 30, 30, 24, 24, 16, 16, 16, 16, 16, 16, 10, 10, 10,
280  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10
281  },
282  { 34, 34, 30, 30, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16,
283  16, 16, 16, 16, 16, 16, 16, 10, 10, 10, 10, 10, 10, 10, 10
284  },
285  { 34, 34, 30, 30, 30, 30, 30, 30, 24, 24, 24, 24, 24, 24, 24,
286  24, 24, 24, 24, 24, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16
287  },
288 };
289 
290 static const int vlc_stage3_values[60] = {
291  0, 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24,
292  28, 36, 44, 52, 60, 76, 92, 108, 124, 156, 188, 220,
293  252, 316, 380, 444, 508, 636, 764, 892, 1020, 1276, 1532, 1788,
294  2044, 2556, 3068, 3580, 4092, 5116, 6140, 7164, 8188, 10236, 12284, 14332,
295  16380, 20476, 24572, 28668, 32764, 40956, 49148, 57340, 65532, 81916, 98300,114684
296 };
297 
298 static const float fft_tone_sample_table[4][16][5] = {
299  { { .0100000000f,-.0037037037f,-.0020000000f,-.0069444444f,-.0018416207f },
300  { .0416666667f, .0000000000f, .0000000000f,-.0208333333f,-.0123456791f },
301  { .1250000000f, .0558035709f, .0330687836f,-.0164473690f,-.0097465888f },
302  { .1562500000f, .0625000000f, .0370370370f,-.0062500000f,-.0037037037f },
303  { .1996007860f, .0781250000f, .0462962948f, .0022727272f, .0013468013f },
304  { .2000000000f, .0625000000f, .0370370373f, .0208333333f, .0074074073f },
305  { .2127659619f, .0555555556f, .0329218097f, .0208333333f, .0123456791f },
306  { .2173913121f, .0473484844f, .0280583613f, .0347222239f, .0205761325f },
307  { .2173913121f, .0347222239f, .0205761325f, .0473484844f, .0280583613f },
308  { .2127659619f, .0208333333f, .0123456791f, .0555555556f, .0329218097f },
309  { .2000000000f, .0208333333f, .0074074073f, .0625000000f, .0370370370f },
310  { .1996007860f, .0022727272f, .0013468013f, .0781250000f, .0462962948f },
311  { .1562500000f,-.0062500000f,-.0037037037f, .0625000000f, .0370370370f },
312  { .1250000000f,-.0164473690f,-.0097465888f, .0558035709f, .0330687836f },
313  { .0416666667f,-.0208333333f,-.0123456791f, .0000000000f, .0000000000f },
314  { .0100000000f,-.0069444444f,-.0018416207f,-.0037037037f,-.0020000000f } },
315 
316  { { .0050000000f,-.0200000000f, .0125000000f,-.3030303030f, .0020000000f },
317  { .1041666642f, .0400000000f,-.0250000000f, .0333333333f,-.0200000000f },
318  { .1250000000f, .0100000000f, .0142857144f,-.0500000007f,-.0200000000f },
319  { .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
320  { .1562500000f,-.0006250000f,-.00049382716f,-.000625000f,-.00049382716f },
321  { .1250000000f,-.0500000000f,-.0200000000f, .0100000000f, .0142857144f },
322  { .1041666667f, .0333333333f,-.0200000000f, .0400000000f,-.0250000000f },
323  { .0050000000f,-.3030303030f, .0020000001f,-.0200000000f, .0125000000f },
324  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
325  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
326  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
327  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
328  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
329  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
330  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
331  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
332 
333  { { .1428571492f, .1250000000f,-.0285714287f,-.0357142873f, .0208333333f },
334  { .1818181818f, .0588235296f, .0333333333f, .0212765951f, .0100000000f },
335  { .1818181818f, .0212765951f, .0100000000f, .0588235296f, .0333333333f },
336  { .1428571492f,-.0357142873f, .0208333333f, .1250000000f,-.0285714287f },
337  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
338  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
339  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
340  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
341  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
342  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
343  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
344  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
345  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
346  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
347  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
348  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } },
349 
350  { { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
351  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
352  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
353  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
354  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
355  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
356  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
357  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
358  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
359  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
360  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
361  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
362  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
363  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
364  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f },
365  { .0000000000f, .0000000000f, .0000000000f, .0000000000f, .0000000000f } }
366 };
367 
368 static const float fft_tone_level_table[2][64] = { {
369 /* pow ~ (i > 46) ? 0 : (((((i & 1) ? 431 : 304) << (i >> 1))) / 1024.0); */
370  0.17677669f, 0.42677650f, 0.60355347f, 0.85355347f,
371  1.20710683f, 1.68359375f, 2.37500000f, 3.36718750f,
372  4.75000000f, 6.73437500f, 9.50000000f, 13.4687500f,
373  19.0000000f, 26.9375000f, 38.0000000f, 53.8750000f,
374  76.0000000f, 107.750000f, 152.000000f, 215.500000f,
375  304.000000f, 431.000000f, 608.000000f, 862.000000f,
376  1216.00000f, 1724.00000f, 2432.00000f, 3448.00000f,
377  4864.00000f, 6896.00000f, 9728.00000f, 13792.0000f,
378  19456.0000f, 27584.0000f, 38912.0000f, 55168.0000f,
379  77824.0000f, 110336.000f, 155648.000f, 220672.000f,
380  311296.000f, 441344.000f, 622592.000f, 882688.000f,
381  1245184.00f, 1765376.00f, 2490368.00f, 0.00000000f,
382  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
383  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
384  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
385  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
386  }, {
387 /* pow = (i > 45) ? 0 : ((((i & 1) ? 431 : 304) << (i >> 1)) / 512.0); */
388  0.59375000f, 0.84179688f, 1.18750000f, 1.68359375f,
389  2.37500000f, 3.36718750f, 4.75000000f, 6.73437500f,
390  9.50000000f, 13.4687500f, 19.0000000f, 26.9375000f,
391  38.0000000f, 53.8750000f, 76.0000000f, 107.750000f,
392  152.000000f, 215.500000f, 304.000000f, 431.000000f,
393  608.000000f, 862.000000f, 1216.00000f, 1724.00000f,
394  2432.00000f, 3448.00000f, 4864.00000f, 6896.00000f,
395  9728.00000f, 13792.0000f, 19456.0000f, 27584.0000f,
396  38912.0000f, 55168.0000f, 77824.0000f, 110336.000f,
397  155648.000f, 220672.000f, 311296.000f, 441344.000f,
398  622592.000f, 882688.000f, 1245184.00f, 1765376.00f,
399  2490368.00f, 3530752.00f, 0.00000000f, 0.00000000f,
400  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
401  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
402  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f,
403  0.00000000f, 0.00000000f, 0.00000000f, 0.00000000f
404 } };
405 
406 static const float fft_tone_envelope_table[4][31] = {
407  { .009607375f, .038060248f, .084265202f, .146446645f, .222214907f, .308658302f,
408  .402454883f, .500000060f, .597545207f, .691341758f, .777785182f, .853553414f,
409  .915734828f, .961939812f, .990392685f, 1.00000000f, .990392625f, .961939752f,
410  .915734768f, .853553295f, .777785063f, .691341639f, .597545087f, .500000000f,
411  .402454853f, .308658272f, .222214878f, .146446615f, .084265172f, .038060218f,
412  .009607345f },
413  { .038060248f, .146446645f, .308658302f, .500000060f, .691341758f, .853553414f,
414  .961939812f, 1.00000000f, .961939752f, .853553295f, .691341639f, .500000000f,
415  .308658272f, .146446615f, .038060218f, .000000000f, .000000000f, .000000000f,
416  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
417  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
418  .000000000f },
419  { .146446645f, .500000060f, .853553414f, 1.00000000f, .853553295f, .500000000f,
420  .146446615f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
421  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
422  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
423  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
424  .000000000f },
425  { .500000060f, 1.00000000f, .500000000f, .000000000f, .000000000f, .000000000f,
426  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
427  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
428  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
429  .000000000f, .000000000f, .000000000f, .000000000f, .000000000f, .000000000f,
430  .000000000f }
431 };
432 
433 static const float sb_noise_attenuation[32] = {
434  0.0f, 0.0f, 0.3f, 0.4f, 0.5f, 0.7f, 1.0f, 1.0f,
435  1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
436  1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
437  1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f,
438 };
439 
440 static const uint8_t fft_subpackets[32] = {
441  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0,
442  0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0
443 };
444 
445 /* first index is joined_stereo, second index is 0 or 2 (1 is unused) */
446 static const float dequant_1bit[2][3] = {
447  {-0.920000f, 0.000000f, 0.920000f },
448  {-0.890000f, 0.000000f, 0.890000f }
449 };
450 
451 static const float type30_dequant[8] = {
452  -1.0f,-0.625f,-0.291666656732559f,0.0f,
453  0.25f,0.5f,0.75f,1.0f,
454 };
455 
456 static const float type34_delta[10] = { // FIXME: covers 8 entries..
457  -1.0f,-0.60947573184967f,-0.333333343267441f,-0.138071194291115f,0.0f,
458  0.138071194291115f,0.333333343267441f,0.60947573184967f,1.0f,0.0f,
459 };
460 
461 #endif /* AVCODEC_QDM2DATA_H */
fft_level_index_table
static const int16_t fft_level_index_table[256]
Definition: qdm2data.h:168
dequant_table
static const uint32_t dequant_table[3][10][30]
Definition: qdm2data.h:197
coding_method_table
static const int8_t coding_method_table[5][30]
Definition: qdm2data.h:272
tab_run
static const uint8_t tab_run[6][2]
Definition: qdm2data.h:56
tab_diff
static const uint8_t tab_diff[33][2]
Definition: qdm2data.h:46
fft_tone_level_table
static const float fft_tone_level_table[2][64]
Definition: qdm2data.h:368
dequant_1bit
static const float dequant_1bit[2][3]
Definition: qdm2data.h:446
sb_noise_attenuation
static const float sb_noise_attenuation[32]
Definition: qdm2data.h:433
fft_level_exp_alt
static const uint8_t fft_level_exp_alt[28][2]
FFT TABLES.
Definition: qdm2data.h:137
coeff_per_sb_for_dequant
static const uint8_t coeff_per_sb_for_dequant[3][30]
Definition: qdm2data.h:230
tab_fft_tone_offset_sizes
static const uint8_t tab_fft_tone_offset_sizes[]
Definition: qdm2data.h:94
fft_tone_envelope_table
static const float fft_tone_envelope_table[4][31]
Definition: qdm2data.h:406
tab_type34
static const uint8_t tab_type34[10][2]
Definition: qdm2data.h:89
last_coeff
static const uint8_t last_coeff[3]
Definition: qdm2data.h:187
fft_stereo_exp
static const uint8_t fft_stereo_exp[7][2]
Definition: qdm2data.h:154
fft_stereo_phase
static const uint8_t fft_stereo_phase[9][2]
Definition: qdm2data.h:159
tab_level
static const uint8_t tab_level[24][2]
VLC TABLES.
Definition: qdm2data.h:38
tab_tone_level_idx_hi1
static const uint8_t tab_tone_level_idx_hi1[20][2]
Definition: qdm2data.h:61
vlc_stage3_values
static const int vlc_stage3_values[60]
Definition: qdm2data.h:290
fft_subpackets
static const uint8_t fft_subpackets[32]
Definition: qdm2data.h:440
fft_level_exp
static const uint8_t fft_level_exp[20][2]
Definition: qdm2data.h:146
uint8_t
uint8_t
Definition: audio_convert.c:194
tone_level_idx_offset_table
static const int8_t tone_level_idx_offset_table[30][4]
Definition: qdm2data.h:237
tab_fft_tone_offset
static const uint8_t tab_fft_tone_offset[][2]
Definition: qdm2data.h:98
tab_tone_level_idx_hi2
static const uint8_t tab_tone_level_idx_hi2[18][2]
Definition: qdm2data.h:76
fft_tone_sample_table
static const float fft_tone_sample_table[4][16][5]
Definition: qdm2data.h:298
type34_delta
static const float type34_delta[10]
Definition: qdm2data.h:456
coeff_per_sb_for_avg
static const uint8_t coeff_per_sb_for_avg[3][30]
Definition: qdm2data.h:191
tab_type30
static const uint8_t tab_type30[9][2]
Definition: qdm2data.h:83
type30_dequant
static const float type30_dequant[8]
Definition: qdm2data.h:451
fft_cutoff_index_table
static const int fft_cutoff_index_table[4][2]
Definition: qdm2data.h:164
tab_tone_level_idx_mid
static const uint8_t tab_tone_level_idx_mid[13][2]
Definition: qdm2data.h:69