Mercurial > mplayer.hg
annotate libfaad2/ps_syntax.c @ 17928:e0f20946e398
Convert fullscreen, panscan, color controls, ontop, rootwin,
border, framedrop and vsync to properties. Also add a couple
of video related properties like width, height, etc.
author | albeu |
---|---|
date | Thu, 23 Mar 2006 01:22:43 +0000 |
parents | 2ae5ab4331ca |
children | 59b6fa5b4201 |
rev | line source |
---|---|
13453 | 1 /* |
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR and PS decoding | |
3 ** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com | |
4 ** | |
5 ** This program is free software; you can redistribute it and/or modify | |
6 ** it under the terms of the GNU General Public License as published by | |
7 ** the Free Software Foundation; either version 2 of the License, or | |
8 ** (at your option) any later version. | |
9 ** | |
10 ** This program is distributed in the hope that it will be useful, | |
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 ** GNU General Public License for more details. | |
14 ** | |
15 ** You should have received a copy of the GNU General Public License | |
16 ** along with this program; if not, write to the Free Software | |
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
18 ** | |
19 ** Any non-GPL usage of this software or parts of this software is strictly | |
20 ** forbidden. | |
21 ** | |
22 ** Commercial non-GPL licensing of this software is possible. | |
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | |
24 ** | |
14727
2ae5ab4331ca
Remove modification notice from files that have not been locally modified.
diego
parents:
13453
diff
changeset
|
25 ** $Id: ps_syntax.c,v 1.3 2004/06/30 12:45:56 menno Exp $ |
13453 | 26 **/ |
27 | |
28 #include "common.h" | |
29 | |
30 #ifdef PS_DEC | |
31 | |
32 #include "bits.h" | |
33 #include "ps_dec.h" | |
34 | |
35 /* type definitaions */ | |
36 typedef const int8_t (*ps_huff_tab)[2]; | |
37 | |
38 /* static data tables */ | |
39 static const uint8_t nr_iid_par_tab[] = { | |
40 10, 20, 34, 10, 20, 34, 0, 0 | |
41 }; | |
42 static const uint8_t nr_ipdopd_par_tab[] = { | |
43 5, 11, 17, 5, 11, 17, 0, 0 | |
44 }; | |
45 static const uint8_t nr_icc_par_tab[] = { | |
46 10, 20, 34, 10, 20, 34, 0, 0 | |
47 }; | |
48 static const uint8_t num_env_tab[][4] = { | |
49 { 0, 1, 2, 4 }, | |
50 { 1, 2, 3, 4 } | |
51 }; | |
52 | |
53 /* binary lookup huffman tables */ | |
54 static const int8_t f_huff_iid_def[][2] = { | |
55 { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ | |
56 { 2, 3 }, /* index 1: 2 bits: 1x */ | |
57 { /*1*/ -30, /*-1*/ -32 }, /* index 2: 3 bits: 10x */ | |
58 { 4, 5 }, /* index 3: 3 bits: 11x */ | |
59 { /*2*/ -29, /*-2*/ -33 }, /* index 4: 4 bits: 110x */ | |
60 { 6, 7 }, /* index 5: 4 bits: 111x */ | |
61 { /*3*/ -28, /*-3*/ -34 }, /* index 6: 5 bits: 1110x */ | |
62 { 8, 9 }, /* index 7: 5 bits: 1111x */ | |
63 { /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 11110x */ | |
64 { /*5*/ -26, 10 }, /* index 9: 6 bits: 11111x */ | |
65 { /*-5*/ -36, 11 }, /* index 10: 7 bits: 111111x */ | |
66 { /*6*/ -25, 12 }, /* index 11: 8 bits: 1111111x */ | |
67 { /*-6*/ -37, 13 }, /* index 12: 9 bits: 11111111x */ | |
68 { /*-7*/ -38, 14 }, /* index 13: 10 bits: 111111111x */ | |
69 { /*7*/ -24, 15 }, /* index 14: 11 bits: 1111111111x */ | |
70 { 16, 17 }, /* index 15: 12 bits: 11111111111x */ | |
71 { /*8*/ -23, /*-8*/ -39 }, /* index 16: 13 bits: 111111111110x */ | |
72 { 18, 19 }, /* index 17: 13 bits: 111111111111x */ | |
73 { /*9*/ -22, /*10*/ -21 }, /* index 18: 14 bits: 1111111111110x */ | |
74 { 20, 21 }, /* index 19: 14 bits: 1111111111111x */ | |
75 { /*-9*/ -40, /*11*/ -20 }, /* index 20: 15 bits: 11111111111110x */ | |
76 { 22, 23 }, /* index 21: 15 bits: 11111111111111x */ | |
77 { /*-10*/ -41, 24 }, /* index 22: 16 bits: 111111111111110x */ | |
78 { 25, 26 }, /* index 23: 16 bits: 111111111111111x */ | |
79 { /*-11*/ -42, /*-14*/ -45 }, /* index 24: 17 bits: 1111111111111101x */ | |
80 { /*-13*/ -44, /*-12*/ -43 }, /* index 25: 17 bits: 1111111111111110x */ | |
81 { /*12*/ -19, 27 }, /* index 26: 17 bits: 1111111111111111x */ | |
82 { /*13*/ -18, /*14*/ -17 } /* index 27: 18 bits: 11111111111111111x */ | |
83 }; | |
84 | |
85 static const int8_t t_huff_iid_def[][2] = { | |
86 { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ | |
87 { /*-1*/ -32, 2 }, /* index 1: 2 bits: 1x */ | |
88 { /*1*/ -30, 3 }, /* index 2: 3 bits: 11x */ | |
89 { /*-2*/ -33, 4 }, /* index 3: 4 bits: 111x */ | |
90 { /*2*/ -29, 5 }, /* index 4: 5 bits: 1111x */ | |
91 { /*-3*/ -34, 6 }, /* index 5: 6 bits: 11111x */ | |
92 { /*3*/ -28, 7 }, /* index 6: 7 bits: 111111x */ | |
93 { /*-4*/ -35, 8 }, /* index 7: 8 bits: 1111111x */ | |
94 { /*4*/ -27, 9 }, /* index 8: 9 bits: 11111111x */ | |
95 { /*-5*/ -36, 10 }, /* index 9: 10 bits: 111111111x */ | |
96 { /*5*/ -26, 11 }, /* index 10: 11 bits: 1111111111x */ | |
97 { /*-6*/ -37, 12 }, /* index 11: 12 bits: 11111111111x */ | |
98 { /*6*/ -25, 13 }, /* index 12: 13 bits: 111111111111x */ | |
99 { /*7*/ -24, 14 }, /* index 13: 14 bits: 1111111111111x */ | |
100 { /*-7*/ -38, 15 }, /* index 14: 15 bits: 11111111111111x */ | |
101 { 16, 17 }, /* index 15: 16 bits: 111111111111111x */ | |
102 { /*8*/ -23, /*-8*/ -39 }, /* index 16: 17 bits: 1111111111111110x */ | |
103 { 18, 19 }, /* index 17: 17 bits: 1111111111111111x */ | |
104 { 20, 21 }, /* index 18: 18 bits: 11111111111111110x */ | |
105 { 22, 23 }, /* index 19: 18 bits: 11111111111111111x */ | |
106 { /*9*/ -22, /*-14*/ -45 }, /* index 20: 19 bits: 111111111111111100x */ | |
107 { /*-13*/ -44, /*-12*/ -43 }, /* index 21: 19 bits: 111111111111111101x */ | |
108 { 24, 25 }, /* index 22: 19 bits: 111111111111111110x */ | |
109 { 26, 27 }, /* index 23: 19 bits: 111111111111111111x */ | |
110 { /*-11*/ -42, /*-10*/ -41 }, /* index 24: 20 bits: 1111111111111111100x */ | |
111 { /*-9*/ -40, /*10*/ -21 }, /* index 25: 20 bits: 1111111111111111101x */ | |
112 { /*11*/ -20, /*12*/ -19 }, /* index 26: 20 bits: 1111111111111111110x */ | |
113 { /*13*/ -18, /*14*/ -17 } /* index 27: 20 bits: 1111111111111111111x */ | |
114 }; | |
115 | |
116 static const int8_t f_huff_iid_fine[][2] = { | |
117 { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ | |
118 { 2, 3 }, /* index 1: 2 bits: 0x */ | |
119 { 4, /*-1*/ -32 }, /* index 2: 3 bits: 00x */ | |
120 { /*1*/ -30, 5 }, /* index 3: 3 bits: 01x */ | |
121 { /*-2*/ -33, /*2*/ -29 }, /* index 4: 4 bits: 000x */ | |
122 { 6, 7 }, /* index 5: 4 bits: 011x */ | |
123 { /*-3*/ -34, /*3*/ -28 }, /* index 6: 5 bits: 0110x */ | |
124 { 8, 9 }, /* index 7: 5 bits: 0111x */ | |
125 { /*-4*/ -35, /*4*/ -27 }, /* index 8: 6 bits: 01110x */ | |
126 { 10, 11 }, /* index 9: 6 bits: 01111x */ | |
127 { /*-5*/ -36, /*5*/ -26 }, /* index 10: 7 bits: 011110x */ | |
128 { 12, 13 }, /* index 11: 7 bits: 011111x */ | |
129 { /*-6*/ -37, /*6*/ -25 }, /* index 12: 8 bits: 0111110x */ | |
130 { 14, 15 }, /* index 13: 8 bits: 0111111x */ | |
131 { /*7*/ -24, 16 }, /* index 14: 9 bits: 01111110x */ | |
132 { 17, 18 }, /* index 15: 9 bits: 01111111x */ | |
133 { 19, /*-8*/ -39 }, /* index 16: 10 bits: 011111101x */ | |
134 { /*8*/ -23, 20 }, /* index 17: 10 bits: 011111110x */ | |
135 { 21, /*-7*/ -38 }, /* index 18: 10 bits: 011111111x */ | |
136 { /*10*/ -21, 22 }, /* index 19: 11 bits: 0111111010x */ | |
137 { 23, /*-9*/ -40 }, /* index 20: 11 bits: 0111111101x */ | |
138 { /*9*/ -22, 24 }, /* index 21: 11 bits: 0111111110x */ | |
139 { /*-11*/ -42, /*11*/ -20 }, /* index 22: 12 bits: 01111110101x */ | |
140 { 25, 26 }, /* index 23: 12 bits: 01111111010x */ | |
141 { 27, /*-10*/ -41 }, /* index 24: 12 bits: 01111111101x */ | |
142 { 28, /*-12*/ -43 }, /* index 25: 13 bits: 011111110100x */ | |
143 { /*12*/ -19, 29 }, /* index 26: 13 bits: 011111110101x */ | |
144 { 30, 31 }, /* index 27: 13 bits: 011111111010x */ | |
145 { 32, /*-14*/ -45 }, /* index 28: 14 bits: 0111111101000x */ | |
146 { /*14*/ -17, 33 }, /* index 29: 14 bits: 0111111101011x */ | |
147 { 34, /*-13*/ -44 }, /* index 30: 14 bits: 0111111110100x */ | |
148 { /*13*/ -18, 35 }, /* index 31: 14 bits: 0111111110101x */ | |
149 { 36, 37 }, /* index 32: 15 bits: 01111111010000x */ | |
150 { 38, /*-15*/ -46 }, /* index 33: 15 bits: 01111111010111x */ | |
151 { /*15*/ -16, 39 }, /* index 34: 15 bits: 01111111101000x */ | |
152 { 40, 41 }, /* index 35: 15 bits: 01111111101011x */ | |
153 { 42, 43 }, /* index 36: 16 bits: 011111110100000x */ | |
154 { /*-17*/ -48, /*17*/ -14 }, /* index 37: 16 bits: 011111110100001x */ | |
155 { 44, 45 }, /* index 38: 16 bits: 011111110101110x */ | |
156 { 46, 47 }, /* index 39: 16 bits: 011111111010001x */ | |
157 { 48, 49 }, /* index 40: 16 bits: 011111111010110x */ | |
158 { /*-16*/ -47, /*16*/ -15 }, /* index 41: 16 bits: 011111111010111x */ | |
159 { /*-21*/ -52, /*21*/ -10 }, /* index 42: 17 bits: 0111111101000000x */ | |
160 { /*-19*/ -50, /*19*/ -12 }, /* index 43: 17 bits: 0111111101000001x */ | |
161 { /*-18*/ -49, /*18*/ -13 }, /* index 44: 17 bits: 0111111101011100x */ | |
162 { 50, 51 }, /* index 45: 17 bits: 0111111101011101x */ | |
163 { 52, 53 }, /* index 46: 17 bits: 0111111110100010x */ | |
164 { 54, 55 }, /* index 47: 17 bits: 0111111110100011x */ | |
165 { 56, 57 }, /* index 48: 17 bits: 0111111110101100x */ | |
166 { 58, 59 }, /* index 49: 17 bits: 0111111110101101x */ | |
167 { /*-26*/ -57, /*-25*/ -56 }, /* index 50: 18 bits: 01111111010111010x */ | |
168 { /*-28*/ -59, /*-27*/ -58 }, /* index 51: 18 bits: 01111111010111011x */ | |
169 { /*-22*/ -53, /*22*/ -9 }, /* index 52: 18 bits: 01111111101000100x */ | |
170 { /*-24*/ -55, /*-23*/ -54 }, /* index 53: 18 bits: 01111111101000101x */ | |
171 { /*25*/ -6, /*26*/ -5 }, /* index 54: 18 bits: 01111111101000110x */ | |
172 { /*23*/ -8, /*24*/ -7 }, /* index 55: 18 bits: 01111111101000111x */ | |
173 { /*29*/ -2, /*30*/ -1 }, /* index 56: 18 bits: 01111111101011000x */ | |
174 { /*27*/ -4, /*28*/ -3 }, /* index 57: 18 bits: 01111111101011001x */ | |
175 { /*-30*/ -61, /*-29*/ -60 }, /* index 58: 18 bits: 01111111101011010x */ | |
176 { /*-20*/ -51, /*20*/ -11 } /* index 59: 18 bits: 01111111101011011x */ | |
177 }; | |
178 | |
179 static const int8_t t_huff_iid_fine[][2] = { | |
180 { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ | |
181 { /*1*/ -30, 2 }, /* index 1: 2 bits: 0x */ | |
182 { 3, /*-1*/ -32 }, /* index 2: 3 bits: 01x */ | |
183 { 4, 5 }, /* index 3: 4 bits: 010x */ | |
184 { 6, 7 }, /* index 4: 5 bits: 0100x */ | |
185 { /*-2*/ -33, /*2*/ -29 }, /* index 5: 5 bits: 0101x */ | |
186 { 8, /*-3*/ -34 }, /* index 6: 6 bits: 01000x */ | |
187 { /*3*/ -28, 9 }, /* index 7: 6 bits: 01001x */ | |
188 { /*-4*/ -35, /*4*/ -27 }, /* index 8: 7 bits: 010000x */ | |
189 { 10, 11 }, /* index 9: 7 bits: 010011x */ | |
190 { /*5*/ -26, 12 }, /* index 10: 8 bits: 0100110x */ | |
191 { 13, 14 }, /* index 11: 8 bits: 0100111x */ | |
192 { /*-6*/ -37, /*6*/ -25 }, /* index 12: 9 bits: 01001101x */ | |
193 { 15, 16 }, /* index 13: 9 bits: 01001110x */ | |
194 { 17, /*-5*/ -36 }, /* index 14: 9 bits: 01001111x */ | |
195 { 18, /*-7*/ -38 }, /* index 15: 10 bits: 010011100x */ | |
196 { /*7*/ -24, 19 }, /* index 16: 10 bits: 010011101x */ | |
197 { 20, 21 }, /* index 17: 10 bits: 010011110x */ | |
198 { /*9*/ -22, 22 }, /* index 18: 11 bits: 0100111000x */ | |
199 { 23, 24 }, /* index 19: 11 bits: 0100111011x */ | |
200 { /*-8*/ -39, /*8*/ -23 }, /* index 20: 11 bits: 0100111100x */ | |
201 { 25, 26 }, /* index 21: 11 bits: 0100111101x */ | |
202 { /*11*/ -20, 27 }, /* index 22: 12 bits: 01001110001x */ | |
203 { 28, 29 }, /* index 23: 12 bits: 01001110110x */ | |
204 { /*-10*/ -41, /*10*/ -21 }, /* index 24: 12 bits: 01001110111x */ | |
205 { 30, 31 }, /* index 25: 12 bits: 01001111010x */ | |
206 { 32, /*-9*/ -40 }, /* index 26: 12 bits: 01001111011x */ | |
207 { 33, /*-13*/ -44 }, /* index 27: 13 bits: 010011100011x */ | |
208 { /*13*/ -18, 34 }, /* index 28: 13 bits: 010011101100x */ | |
209 { 35, 36 }, /* index 29: 13 bits: 010011101101x */ | |
210 { 37, /*-12*/ -43 }, /* index 30: 13 bits: 010011110100x */ | |
211 { /*12*/ -19, 38 }, /* index 31: 13 bits: 010011110101x */ | |
212 { 39, /*-11*/ -42 }, /* index 32: 13 bits: 010011110110x */ | |
213 { 40, 41 }, /* index 33: 14 bits: 0100111000110x */ | |
214 { 42, 43 }, /* index 34: 14 bits: 0100111011001x */ | |
215 { 44, 45 }, /* index 35: 14 bits: 0100111011010x */ | |
216 { 46, /*-15*/ -46 }, /* index 36: 14 bits: 0100111011011x */ | |
217 { /*15*/ -16, 47 }, /* index 37: 14 bits: 0100111101000x */ | |
218 { /*-14*/ -45, /*14*/ -17 }, /* index 38: 14 bits: 0100111101011x */ | |
219 { 48, 49 }, /* index 39: 14 bits: 0100111101100x */ | |
220 { /*-21*/ -52, /*-20*/ -51 }, /* index 40: 15 bits: 01001110001100x */ | |
221 { /*18*/ -13, /*19*/ -12 }, /* index 41: 15 bits: 01001110001101x */ | |
222 { /*-19*/ -50, /*-18*/ -49 }, /* index 42: 15 bits: 01001110110010x */ | |
223 { 50, 51 }, /* index 43: 15 bits: 01001110110011x */ | |
224 { 52, 53 }, /* index 44: 15 bits: 01001110110100x */ | |
225 { 54, 55 }, /* index 45: 15 bits: 01001110110101x */ | |
226 { 56, /*-17*/ -48 }, /* index 46: 15 bits: 01001110110110x */ | |
227 { /*17*/ -14, 57 }, /* index 47: 15 bits: 01001111010001x */ | |
228 { 58, /*-16*/ -47 }, /* index 48: 15 bits: 01001111011000x */ | |
229 { /*16*/ -15, 59 }, /* index 49: 15 bits: 01001111011001x */ | |
230 { /*-26*/ -57, /*26*/ -5 }, /* index 50: 16 bits: 010011101100110x */ | |
231 { /*-28*/ -59, /*-27*/ -58 }, /* index 51: 16 bits: 010011101100111x */ | |
232 { /*29*/ -2, /*30*/ -1 }, /* index 52: 16 bits: 010011101101000x */ | |
233 { /*27*/ -4, /*28*/ -3 }, /* index 53: 16 bits: 010011101101001x */ | |
234 { /*-30*/ -61, /*-29*/ -60 }, /* index 54: 16 bits: 010011101101010x */ | |
235 { /*-25*/ -56, /*25*/ -6 }, /* index 55: 16 bits: 010011101101011x */ | |
236 { /*-24*/ -55, /*24*/ -7 }, /* index 56: 16 bits: 010011101101100x */ | |
237 { /*-23*/ -54, /*23*/ -8 }, /* index 57: 16 bits: 010011110100011x */ | |
238 { /*-22*/ -53, /*22*/ -9 }, /* index 58: 16 bits: 010011110110000x */ | |
239 { /*20*/ -11, /*21*/ -10 } /* index 59: 16 bits: 010011110110011x */ | |
240 }; | |
241 | |
242 static const int8_t f_huff_icc[][2] = { | |
243 { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ | |
244 { /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ | |
245 { /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ | |
246 { /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ | |
247 { /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ | |
248 { /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ | |
249 { /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ | |
250 { /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ | |
251 { /*5*/ -26, 9 }, /* index 8: 9 bits: 11111111x */ | |
252 { /*-4*/ -35, 10 }, /* index 9: 10 bits: 111111111x */ | |
253 { /*6*/ -25, 11 }, /* index 10: 11 bits: 1111111111x */ | |
254 { /*-5*/ -36, 12 }, /* index 11: 12 bits: 11111111111x */ | |
255 { /*7*/ -24, 13 }, /* index 12: 13 bits: 111111111111x */ | |
256 { /*-6*/ -37, /*-7*/ -38 } /* index 13: 14 bits: 1111111111111x */ | |
257 }; | |
258 | |
259 static const int8_t t_huff_icc[][2] = { | |
260 { /*0*/ -31, 1 }, /* index 0: 1 bits: x */ | |
261 { /*1*/ -30, 2 }, /* index 1: 2 bits: 1x */ | |
262 { /*-1*/ -32, 3 }, /* index 2: 3 bits: 11x */ | |
263 { /*2*/ -29, 4 }, /* index 3: 4 bits: 111x */ | |
264 { /*-2*/ -33, 5 }, /* index 4: 5 bits: 1111x */ | |
265 { /*3*/ -28, 6 }, /* index 5: 6 bits: 11111x */ | |
266 { /*-3*/ -34, 7 }, /* index 6: 7 bits: 111111x */ | |
267 { /*4*/ -27, 8 }, /* index 7: 8 bits: 1111111x */ | |
268 { /*-4*/ -35, 9 }, /* index 8: 9 bits: 11111111x */ | |
269 { /*5*/ -26, 10 }, /* index 9: 10 bits: 111111111x */ | |
270 { /*-5*/ -36, 11 }, /* index 10: 11 bits: 1111111111x */ | |
271 { /*6*/ -25, 12 }, /* index 11: 12 bits: 11111111111x */ | |
272 { /*-6*/ -37, 13 }, /* index 12: 13 bits: 111111111111x */ | |
273 { /*-7*/ -38, /*7*/ -24 } /* index 13: 14 bits: 1111111111111x */ | |
274 }; | |
275 | |
276 static const int8_t f_huff_ipd[][2] = { | |
277 { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ | |
278 { 2, 3 }, /* index 1: 2 bits: 0x */ | |
279 { /*1*/ -30, 4 }, /* index 2: 3 bits: 00x */ | |
280 { 5, 6 }, /* index 3: 3 bits: 01x */ | |
281 { /*4*/ -27, /*5*/ -26 }, /* index 4: 4 bits: 001x */ | |
282 { /*3*/ -28, /*6*/ -25 }, /* index 5: 4 bits: 010x */ | |
283 { /*2*/ -29, /*7*/ -24 } /* index 6: 4 bits: 011x */ | |
284 }; | |
285 | |
286 static const int8_t t_huff_ipd[][2] = { | |
287 { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ | |
288 { 2, 3 }, /* index 1: 2 bits: 0x */ | |
289 { 4, 5 }, /* index 2: 3 bits: 00x */ | |
290 { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ | |
291 { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ | |
292 { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ | |
293 { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ | |
294 }; | |
295 | |
296 static const int8_t f_huff_opd[][2] = { | |
297 { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ | |
298 { 2, 3 }, /* index 1: 2 bits: 0x */ | |
299 { /*7*/ -24, /*1*/ -30 }, /* index 2: 3 bits: 00x */ | |
300 { 4, 5 }, /* index 3: 3 bits: 01x */ | |
301 { /*3*/ -28, /*6*/ -25 }, /* index 4: 4 bits: 010x */ | |
302 { /*2*/ -29, 6 }, /* index 5: 4 bits: 011x */ | |
303 { /*5*/ -26, /*4*/ -27 } /* index 6: 5 bits: 0111x */ | |
304 }; | |
305 | |
306 static const int8_t t_huff_opd[][2] = { | |
307 { 1, /*0*/ -31 }, /* index 0: 1 bits: x */ | |
308 { 2, 3 }, /* index 1: 2 bits: 0x */ | |
309 { 4, 5 }, /* index 2: 3 bits: 00x */ | |
310 { /*1*/ -30, /*7*/ -24 }, /* index 3: 3 bits: 01x */ | |
311 { /*5*/ -26, 6 }, /* index 4: 4 bits: 000x */ | |
312 { /*2*/ -29, /*6*/ -25 }, /* index 5: 4 bits: 001x */ | |
313 { /*4*/ -27, /*3*/ -28 } /* index 6: 5 bits: 0001x */ | |
314 }; | |
315 | |
316 /* static function declarations */ | |
317 static uint16_t ps_extension(ps_info *ps, bitfile *ld, | |
318 const uint8_t ps_extension_id, | |
319 const uint16_t num_bits_left); | |
320 static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, | |
321 ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par); | |
322 static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff); | |
323 | |
324 | |
325 uint16_t ps_data(ps_info *ps, bitfile *ld) | |
326 { | |
327 uint8_t tmp, n; | |
328 uint16_t bits = (uint16_t)faad_get_processed_bits(ld); | |
329 | |
330 /* check for new PS header */ | |
331 if (faad_get1bit(ld | |
332 DEBUGVAR(1,1000,"ps_data(): enable_ps_header"))) | |
333 { | |
334 ps->use34hybrid_bands = 0; | |
335 | |
336 /* Inter-channel Intensity Difference (IID) parameters enabled */ | |
337 ps->enable_iid = (uint8_t)faad_get1bit(ld | |
338 DEBUGVAR(1,1001,"ps_data(): enable_iid")); | |
339 | |
340 if (ps->enable_iid) | |
341 { | |
342 ps->iid_mode = (uint8_t)faad_getbits(ld, 3 | |
343 DEBUGVAR(1,1002,"ps_data(): iid_mode")); | |
344 | |
345 ps->nr_iid_par = nr_iid_par_tab[ps->iid_mode]; | |
346 ps->nr_ipdopd_par = nr_ipdopd_par_tab[ps->iid_mode]; | |
347 | |
348 if (ps->iid_mode == 2 || ps->iid_mode == 5) | |
349 ps->use34hybrid_bands = 1; | |
350 | |
351 /* IPD freq res equal to IID freq res */ | |
352 ps->ipd_mode = ps->iid_mode; | |
353 } | |
354 | |
355 /* Inter-channel Coherence (ICC) parameters enabled */ | |
356 ps->enable_icc = (uint8_t)faad_get1bit(ld | |
357 DEBUGVAR(1,1003,"ps_data(): enable_icc")); | |
358 | |
359 if (ps->enable_icc) | |
360 { | |
361 ps->icc_mode = (uint8_t)faad_getbits(ld, 3 | |
362 DEBUGVAR(1,1004,"ps_data(): icc_mode")); | |
363 | |
364 ps->nr_icc_par = nr_icc_par_tab[ps->icc_mode]; | |
365 | |
366 if (ps->icc_mode == 2 || ps->icc_mode == 5) | |
367 ps->use34hybrid_bands = 1; | |
368 } | |
369 | |
370 /* PS extension layer enabled */ | |
371 ps->enable_ext = (uint8_t)faad_get1bit(ld | |
372 DEBUGVAR(1,1005,"ps_data(): enable_ext")); | |
373 } | |
374 | |
375 ps->frame_class = (uint8_t)faad_get1bit(ld | |
376 DEBUGVAR(1,1006,"ps_data(): frame_class")); | |
377 tmp = (uint8_t)faad_getbits(ld, 2 | |
378 DEBUGVAR(1,1007,"ps_data(): num_env_idx")); | |
379 | |
380 ps->num_env = num_env_tab[ps->frame_class][tmp]; | |
381 | |
382 if (ps->frame_class) | |
383 { | |
384 for (n = 1; n < ps->num_env+1; n++) | |
385 { | |
386 ps->border_position[n] = (uint8_t)faad_getbits(ld, 5 | |
387 DEBUGVAR(1,1008,"ps_data(): border_position")); | |
388 } | |
389 } | |
390 | |
391 if (ps->enable_iid) | |
392 { | |
393 for (n = 0; n < ps->num_env; n++) | |
394 { | |
395 ps->iid_dt[n] = (uint8_t)faad_get1bit(ld | |
396 DEBUGVAR(1,1009,"ps_data(): iid_dt")); | |
397 | |
398 /* iid_data */ | |
399 if (ps->iid_mode < 3) | |
400 { | |
401 huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_def, | |
402 f_huff_iid_def, ps->iid_index[n]); | |
403 } else { | |
404 huff_data(ld, ps->iid_dt[n], ps->nr_iid_par, t_huff_iid_fine, | |
405 f_huff_iid_fine, ps->iid_index[n]); | |
406 } | |
407 } | |
408 } | |
409 | |
410 if (ps->enable_icc) | |
411 { | |
412 for (n = 0; n < ps->num_env; n++) | |
413 { | |
414 ps->icc_dt[n] = (uint8_t)faad_get1bit(ld | |
415 DEBUGVAR(1,1010,"ps_data(): icc_dt")); | |
416 | |
417 /* icc_data */ | |
418 huff_data(ld, ps->icc_dt[n], ps->nr_icc_par, t_huff_icc, | |
419 f_huff_icc, ps->icc_index[n]); | |
420 } | |
421 } | |
422 | |
423 if (ps->enable_ext) | |
424 { | |
425 uint16_t num_bits_left; | |
426 uint16_t cnt = (uint16_t)faad_getbits(ld, 4 | |
427 DEBUGVAR(1,1011,"ps_data(): ps_extension_size")); | |
428 if (cnt == 15) | |
429 { | |
430 cnt += (uint16_t)faad_getbits(ld, 8 | |
431 DEBUGVAR(1,1012,"ps_data(): esc_count")); | |
432 } | |
433 | |
434 num_bits_left = 8 * cnt; | |
435 while (num_bits_left > 7) | |
436 { | |
437 uint8_t ps_extension_id = (uint8_t)faad_getbits(ld, 2 | |
438 DEBUGVAR(1,1013,"ps_data(): ps_extension_size")); | |
439 | |
440 num_bits_left -= 2; | |
441 num_bits_left -= ps_extension(ps, ld, ps_extension_id, num_bits_left); | |
442 } | |
443 | |
444 faad_getbits(ld, num_bits_left | |
445 DEBUGVAR(1,1014,"ps_data(): fill_bits")); | |
446 } | |
447 | |
448 bits = (uint16_t)faad_get_processed_bits(ld) - bits; | |
449 | |
450 ps->ps_data_available = 1; | |
451 | |
452 return bits; | |
453 } | |
454 | |
455 static uint16_t ps_extension(ps_info *ps, bitfile *ld, | |
456 const uint8_t ps_extension_id, | |
457 const uint16_t num_bits_left) | |
458 { | |
459 uint8_t n; | |
460 uint16_t bits = (uint16_t)faad_get_processed_bits(ld); | |
461 | |
462 if (ps_extension_id == 0) | |
463 { | |
464 ps->enable_ipdopd = (uint8_t)faad_get1bit(ld | |
465 DEBUGVAR(1,1015,"ps_extension(): enable_ipdopd")); | |
466 | |
467 if (ps->enable_ipdopd) | |
468 { | |
469 for (n = 0; n < ps->num_env; n++) | |
470 { | |
471 ps->ipd_dt[n] = (uint8_t)faad_get1bit(ld | |
472 DEBUGVAR(1,1016,"ps_extension(): ipd_dt")); | |
473 | |
474 /* ipd_data */ | |
475 huff_data(ld, ps->ipd_dt[n], ps->nr_ipdopd_par, t_huff_ipd, | |
476 f_huff_ipd, ps->ipd_index[n]); | |
477 | |
478 ps->opd_dt[n] = (uint8_t)faad_get1bit(ld | |
479 DEBUGVAR(1,1017,"ps_extension(): opd_dt")); | |
480 | |
481 /* opd_data */ | |
482 huff_data(ld, ps->opd_dt[n], ps->nr_ipdopd_par, t_huff_opd, | |
483 f_huff_opd, ps->opd_index[n]); | |
484 } | |
485 } | |
486 faad_get1bit(ld | |
487 DEBUGVAR(1,1018,"ps_extension(): reserved_ps")); | |
488 } | |
489 | |
490 /* return number of bits read */ | |
491 bits = (uint16_t)faad_get_processed_bits(ld) - bits; | |
492 | |
493 return bits; | |
494 } | |
495 | |
496 /* read huffman data coded in either the frequency or the time direction */ | |
497 static void huff_data(bitfile *ld, const uint8_t dt, const uint8_t nr_par, | |
498 ps_huff_tab t_huff, ps_huff_tab f_huff, int8_t *par) | |
499 { | |
500 uint8_t n; | |
501 | |
502 if (dt) | |
503 { | |
504 /* coded in time direction */ | |
505 for (n = 0; n < nr_par; n++) | |
506 { | |
507 par[n] = ps_huff_dec(ld, t_huff); | |
508 } | |
509 } else { | |
510 /* coded in frequency direction */ | |
511 par[0] = ps_huff_dec(ld, f_huff); | |
512 | |
513 for (n = 1; n < nr_par; n++) | |
514 { | |
515 par[n] = ps_huff_dec(ld, f_huff); | |
516 } | |
517 } | |
518 } | |
519 | |
520 /* binary search huffman decoding */ | |
521 static INLINE int8_t ps_huff_dec(bitfile *ld, ps_huff_tab t_huff) | |
522 { | |
523 uint8_t bit; | |
524 int16_t index = 0; | |
525 | |
526 while (index >= 0) | |
527 { | |
528 bit = (uint8_t)faad_get1bit(ld); | |
529 index = t_huff[index][bit]; | |
530 } | |
531 | |
532 return index + 31; | |
533 } | |
534 | |
535 #endif |