FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/jpeg2000htdec.c
Date: 2024-04-20 14:10:07
Exec Total Coverage
Lines: 415 630 65.9%
Functions: 24 32 75.0%
Branches: 165 292 56.5%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2022 Caleb Etemesi <etemesicaleb@gmail.com>
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 /*
22 * Copyright 2019 - 2021, Osamu Watanabe
23 *
24 * Redistribution and use in source and binary forms, with or without modification,
25 * are permitted provided that the following conditions are met:
26 *
27 * 1. Redistributions of source code must retain the above copyright notice, this
28 * list of conditions and the following disclaimer.
29 *
30 * 2. Redistributions in binary form must reproduce the above copyright notice,
31 * this list of conditions and the following disclaimer in the documentation
32 * and/or other materials provided with the distribution.
33 *
34 * 3. Neither the name of the copyright holder nor the names of its contributors
35 * may be used to endorse or promote products derived from this software without
36 * specific prior written permission.
37 *
38 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND
39 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
40 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
42 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
43 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
44 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
45 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
47 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 */
49
50 #include <stdint.h>
51 #include "libavutil/attributes.h"
52 #include "libavutil/common.h"
53 #include "libavutil/avassert.h"
54 #include "libavutil/mem.h"
55 #include "jpeg2000htdec.h"
56 #include "jpeg2000.h"
57 #include "jpeg2000dec.h"
58
59 #define J2K_Q1 0
60 #define J2K_Q2 1
61
62 #define HT_SHIFT_SIGMA 0
63 #define HT_SHIFT_SCAN 4
64 #define HT_SHIFT_REF 3
65 #define HT_SHIFT_REF_IND 2
66
67 /* See Rec. ITU-T T.800, Table 2 */
68 const static uint8_t mel_e[13] = { 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5 };
69
70 static const uint16_t dec_cxt_vlc_table1[1024];
71 static const uint16_t dec_cxt_vlc_table0[1024];
72
73 typedef struct StateVars {
74 int32_t pos;
75 uint32_t bits;
76 uint32_t tmp;
77 uint32_t last;
78 uint8_t bits_left;
79 uint64_t bit_buf;
80 } StateVars;
81
82 typedef struct MelDecoderState {
83 uint8_t k;
84 uint8_t run;
85 uint8_t one;
86 } MelDecoderState;
87
88 /**
89 * Given a precomputed c, checks whether n % d == 0. c is precomputed from d
90 * using precompute_c().
91 */
92 av_always_inline
93 15680 static uint32_t is_divisible(uint32_t n, uint64_t c)
94 {
95 15680 return n * c <= c - 1;
96 }
97
98 /**
99 * Precompute the number c used by is_divisible().
100 */
101 av_always_inline
102 10 static uint64_t precompute_c(uint32_t d)
103 {
104 10 return 1 + (0xffffffffffffffffull / d);
105 }
106
107 30 static void jpeg2000_init_zero(StateVars *s)
108 {
109 30 s->bits_left = 0;
110 30 s->bit_buf = 0;
111 30 s->tmp = 0;
112 30 s->bits = 0;
113 30 s->pos = 0;
114 30 s->last = 0;
115 30 }
116
117 10 static void jpeg2000_init_mel(StateVars *s, uint32_t Pcup)
118 {
119 10 jpeg2000_init_zero(s);
120 10 s->pos = Pcup;
121 10 }
122
123 static void jpeg2000_init_mag_ref(StateVars *s, uint32_t Lref)
124 {
125 s->pos = Lref - 2;
126 s->bits = 0;
127 s->last = 0xFF;
128 s->tmp = 0;
129 s->bits_left = 0;
130 s->bit_buf = 0;
131 }
132
133 10 static void jpeg2000_init_mel_decoder(MelDecoderState *mel_state)
134 {
135 10 mel_state->k = 0;
136 10 mel_state->run = 0;
137 10 mel_state->one = 0;
138 10 }
139
140 /**
141 * Refill the buffer backwards in little endian while skipping over stuffing
142 * bits. Stuffing bits are those that appear in the position of any byte whose
143 * LSBs are all 1's if the last consumed byte was larger than 0x8F.
144 */
145 6143 static int jpeg2000_bitbuf_refill_backwards(StateVars *buffer, const uint8_t *array)
146 {
147 6143 uint64_t tmp = 0;
148 6143 int32_t position = buffer->pos - 4;
149 6143 uint32_t new_bits = 32;
150
151
2/2
✓ Branch 0 taken 5343 times.
✓ Branch 1 taken 800 times.
6143 if (buffer->bits_left >= 32)
152 5343 return 0; // enough data, no need to pull in more bits
153
154 /**
155 * Unstuff bits. Load a temporary byte, which precedes the position we
156 * currently at, to ensure that we can also un-stuff if the stuffed bit is
157 * the bottom most bits.
158 */
159
160
2/2
✓ Branch 0 taken 3969 times.
✓ Branch 1 taken 800 times.
4769 for(int i = FFMAX(0, position + 1); i <= buffer->pos + 1; i++)
161 3969 tmp = 256*tmp + array[i];
162
163
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if ((tmp & 0x7FFF000000) > 0x7F8F000000) {
164 tmp &= 0x7FFFFFFFFF;
165 new_bits--;
166 }
167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 800 times.
800 if ((tmp & 0x007FFF0000) > 0x007F8F0000) {
168 tmp = (tmp & 0x007FFFFFFF) + ((tmp & 0xFF00000000) >> 1);
169 new_bits--;
170 }
171
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 797 times.
800 if ((tmp & 0x00007FFF00) > 0x00007F8F00) {
172 3 tmp = (tmp & 0x00007FFFFF) + ((tmp & 0xFFFF000000) >> 1);
173 3 new_bits--;
174 }
175
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 797 times.
800 if ((tmp & 0x0000007FFF) > 0x0000007F8F) {
176 3 tmp = (tmp & 0x0000007FFF) + ((tmp & 0xFFFFFF0000) >> 1);
177 3 new_bits--;
178 }
179
180 800 tmp >>= 8; // Remove temporary byte loaded
181
182 /* Add bits to the MSB of the bit buffer */
183 800 buffer->bit_buf |= tmp << buffer->bits_left;
184 800 buffer->bits_left += new_bits;
185 800 buffer->pos = FFMAX(0, position);
186 800 return 0;
187 }
188
189 /**
190 * Refill the bit-buffer reading new bits going forward
191 * in the stream while skipping over stuffed bits.
192 */
193 1191 static void jpeg2000_bitbuf_refill_forward(StateVars *buffer, const uint8_t *array,
194 uint32_t length)
195 {
196
2/2
✓ Branch 0 taken 4762 times.
✓ Branch 1 taken 1191 times.
5953 while (buffer->bits_left < 32) {
197 4762 buffer->tmp = 0xFF;
198
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 4757 times.
4762 buffer->bits = (buffer->last == 0xFF) ? 7 : 8;
199
2/2
✓ Branch 0 taken 4748 times.
✓ Branch 1 taken 14 times.
4762 if (buffer->pos <= length) {
200 4748 buffer->tmp = array[buffer->pos];
201 4748 buffer->pos += 1;
202 4748 buffer->last = buffer->tmp;
203 }
204 4762 buffer->bit_buf |= ((uint64_t) buffer->tmp) << buffer->bits_left;
205 4762 buffer->bits_left += buffer->bits;
206 }
207 1191 }
208
209 /**
210 * Drops bits from lower bits in the bit buffer. buf contains the bit buffers.
211 * nbits is the number of bits to remove.
212 */
213 av_always_inline
214 18441 static void jpeg2000_bitbuf_drop_bits_lsb(StateVars *buf, uint8_t nbits)
215 {
216 av_assert2(buf->bits_left >= nbits); // cannot read more bits than available
217 18441 buf->bit_buf >>= nbits;
218 18441 buf->bits_left -= nbits;
219 18441 }
220
221 /**
222 * Get bits from the bit buffer reading them from the least significant bits
223 * moving to the most significant bits. In case there are fewer bits, refill
224 * from buf moving backwards.
225 */
226 av_always_inline
227 1548 static uint64_t jpeg2000_bitbuf_get_bits_lsb(StateVars *bit_stream, uint8_t nbits,
228 const uint8_t *buf)
229 {
230 uint64_t bits;
231 1548 uint64_t mask = (1ull << nbits) - 1;
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1548 times.
1548 if (bit_stream->bits_left < nbits)
233 jpeg2000_bitbuf_refill_backwards(bit_stream, buf);
234 1548 bits = bit_stream->bit_buf & mask;
235 1548 jpeg2000_bitbuf_drop_bits_lsb(bit_stream, nbits);
236 1548 return bits;
237 }
238
239 /**
240 * Get bits from the bit buffer reading them from the least significant bits
241 * moving to the most significant bits. In case there are fewer bits, refill from
242 * buf moving forward.
243 */
244 av_always_inline
245 10869 static uint64_t jpeg2000_bitbuf_get_bits_lsb_forward(StateVars *bit_stream,
246 uint8_t nbits, const uint8_t *buf,
247 uint32_t length)
248 {
249 uint64_t bits;
250 10869 uint64_t mask = (1ull << nbits) - 1;
251
252
2/2
✓ Branch 0 taken 1181 times.
✓ Branch 1 taken 9688 times.
10869 if (bit_stream->bits_left <= nbits)
253 1181 jpeg2000_bitbuf_refill_forward(bit_stream, buf, length);
254 10869 bits = bit_stream->bit_buf & mask;
255 10869 jpeg2000_bitbuf_drop_bits_lsb(bit_stream, nbits);
256 10869 return bits;
257 }
258
259 /**
260 * Look ahead bit buffer without discarding bits.
261 */
262 av_always_inline
263 1929 static uint64_t jpeg2000_bitbuf_peek_bits_lsb(StateVars *stream, uint8_t nbits)
264 {
265 1929 uint64_t mask = (1ull << nbits) - 1;
266 1929 return stream->bit_buf & mask;
267 }
268
269 10 static void jpeg2000_init_vlc(StateVars *s, uint32_t Lcup, uint32_t Pcup,
270 const uint8_t *Dcup)
271 {
272 10 s->bits_left = 0;
273 10 s->bit_buf = 0;
274 10 s->pos = Lcup - 2 - Pcup;
275 10 s->last = Dcup[Lcup - 2];
276 10 s->tmp = (s->last) >> 4;
277
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 s->bits = ((s->tmp & 7) < 7) ? 4 : 3;
278
279 10 jpeg2000_bitbuf_refill_backwards(s, Dcup + Pcup);
280 10 jpeg2000_bitbuf_drop_bits_lsb(s, 4);
281 10 }
282
283 /**
284 * Decode prefix codes for VLC segment. See Rec. ITU-T T.814, 7.3.5.
285 */
286 av_always_inline
287 4085 static int jpeg2000_decode_ctx_vlc(const Jpeg2000DecoderContext *s,
288 StateVars *vlc_stream, const uint16_t *table,
289 const uint8_t *Dcup, uint8_t *sig_pat,
290 uint8_t *res_off, uint8_t *emb_pat_k,
291 uint8_t *emb_pat_1, uint8_t pos,
292 uint32_t Pcup, uint16_t context)
293 {
294 uint32_t value;
295 uint8_t len;
296 uint64_t index;
297 uint64_t code_word;
298
299 4085 jpeg2000_bitbuf_refill_backwards(vlc_stream, Dcup + Pcup);
300
301 4085 code_word = vlc_stream->bit_buf & 0x7f;
302 4085 index = code_word + (context << 7);
303
304
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4085 times.
4085 av_assert0(index < 1024); // The CxtVLC table has 1024 entries.
305
306 4085 value = table[index];
307
308 4085 len = (value & 0x000F) >> 1;
309
310 4085 res_off[pos] = (uint8_t) (value & 1);
311 4085 sig_pat[pos] = (uint8_t) ((value & 0x00F0) >> 4);
312 4085 emb_pat_k[pos] = (uint8_t) ((value & 0x0F00) >> 8);
313 4085 emb_pat_1[pos] = (uint8_t) ((value & 0xF000) >> 12);
314
315 4085 jpeg2000_bitbuf_drop_bits_lsb(vlc_stream, len);
316 4085 return 0;
317 }
318
319 /**
320 * Decode variable length u-vlc prefix. See decodeUPrefix procedure at Rec.
321 * ITU-T T.814, 7.3.6.
322 */
323 av_always_inline
324 1548 static uint8_t vlc_decode_u_prefix(StateVars *vlc_stream, const uint8_t *refill_array)
325 {
326 static const uint8_t return_value[8] = { 5, 1, 2, 1, 3, 1, 2, 1 };
327 static const uint8_t drop_bits[8] = { 3, 1, 2, 1, 3, 1, 2, 1 };
328
329 uint8_t bits;
330
331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1548 times.
1548 if (vlc_stream->bits_left < 3)
332 jpeg2000_bitbuf_refill_backwards(vlc_stream, refill_array);
333
334 1548 bits = jpeg2000_bitbuf_peek_bits_lsb(vlc_stream, 3);
335
336 1548 jpeg2000_bitbuf_drop_bits_lsb(vlc_stream, drop_bits[bits]);
337 1548 return return_value[bits];
338 }
339
340 /**
341 * Decode variable length u-vlc suffix. See decodeUSuffix procedure at Rec.
342 * ITU-T T.814, 7.3.6.
343 */
344 av_always_inline
345 1548 static uint8_t vlc_decode_u_suffix(StateVars *vlc_stream, uint8_t suffix,
346 const uint8_t *refill_array)
347 {
348 static const int mask[] = { 1, 31 };
349 static const int drop_bits[] = { 1, 5 };
350
351 uint8_t bits;
352 1548 int cond = suffix != 3;
353
2/2
✓ Branch 0 taken 1167 times.
✓ Branch 1 taken 381 times.
1548 if (suffix < 3)
354 1167 return 0;
355
356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
381 if (vlc_stream->bits_left < 5)
357 jpeg2000_bitbuf_refill_backwards(vlc_stream, refill_array);
358
359 381 bits = jpeg2000_bitbuf_peek_bits_lsb(vlc_stream, 5);
360
361 381 jpeg2000_bitbuf_drop_bits_lsb(vlc_stream, drop_bits[cond]);
362 381 return bits & mask[cond];
363 }
364
365 /**
366 * Decode u-vlc extension values. See decodeUExtension procedure at Rec. ITU-T
367 * T.814, 7.3.6.
368 */
369 av_always_inline
370 1548 static uint8_t vlc_decode_u_extension(StateVars *vlc_stream, uint8_t suffix,
371 const uint8_t *refill_array)
372 {
373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1548 times.
1548 return jpeg2000_bitbuf_get_bits_lsb(vlc_stream, 4 * (suffix >= 28), refill_array);
374 }
375
376 /**
377 * Magnitude and Sign decode procedures. See decodeMagSgnValue procedure at Rec.
378 * ITU-T T.814, 7.3.8.
379 */
380 av_always_inline
381 16384 static int32_t jpeg2000_decode_mag_sgn(StateVars *mag_sgn_stream, int32_t m_n,
382 int32_t i_n, const uint8_t *buf, uint32_t length)
383 {
384 16384 int32_t val = 0;
385
2/2
✓ Branch 0 taken 10869 times.
✓ Branch 1 taken 5515 times.
16384 if (m_n > 0) {
386 10869 val = jpeg2000_bitbuf_get_bits_lsb_forward(mag_sgn_stream,m_n,buf,length);
387 10869 val += (i_n << m_n);
388 }
389 16384 return val;
390 }
391
392 av_always_inline
393 4096 static void recover_mag_sgn(StateVars *mag_sgn, uint8_t pos, uint16_t q, int32_t m_n[2],
394 int32_t known_1[2], const uint8_t emb_pat_1[2],
395 int32_t v[2][4], int32_t m[2][4], uint8_t *E,
396 uint32_t *mu_n, const uint8_t *Dcup, uint32_t Pcup,
397 uint32_t pLSB)
398 {
399
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 4096 times.
20480 for (int i = 0; i < 4; i++) {
400 16384 int32_t n = 4 * q + i;
401 16384 m_n[pos] = m[pos][i];
402 16384 known_1[pos] = (emb_pat_1[pos] >> i) & 1;
403 16384 v[pos][i] = jpeg2000_decode_mag_sgn(mag_sgn, m_n[pos], known_1[pos], Dcup, Pcup);
404
405
2/2
✓ Branch 0 taken 10869 times.
✓ Branch 1 taken 5515 times.
16384 if (m_n[pos] != 0) {
406 10869 E[n] = 32 - ff_clz(v[pos][i] | 1);
407 10869 mu_n[n] = (v[pos][i] >> 1) + 1;
408 10869 mu_n[n] <<= pLSB;
409 10869 mu_n[n] |= ((uint32_t) (v[pos][i] & 1)) << 31; // sign bit.
410 }
411 }
412 4096 }
413
414 109 static int jpeg2000_import_bit(StateVars *stream, const uint8_t *array, uint32_t length)
415 {
416 109 int cond = stream->pos <= length;
417 109 int pos = FFMIN(stream->pos, length);
418
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 90 times.
109 if (stream->bits == 0) {
419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19 times.
19 stream->bits = (stream->tmp == 0xFF) ? 7 : 8;
420 19 stream->pos += cond;
421
1/2
✓ Branch 0 taken 19 times.
✗ Branch 1 not taken.
19 stream->tmp = cond ? array[pos] : 0xFF;
422 }
423 109 stream->bits -= 1;
424 109 return (stream->tmp >> stream->bits) & 1;
425 }
426
427 static int jpeg2000_peek_bit(StateVars *stream, const uint8_t *array, uint32_t length)
428 {
429 if (stream->bits == 0) {
430 int cond = stream->pos <= length;
431 int pos = FFMIN(stream->pos, length);
432 stream->bits = (stream->tmp == 0xFF) ? 7 : 8;
433 stream->pos += cond;
434 stream->tmp = cond ? array[pos] : 0xFF;
435 }
436 return (stream->tmp >> stream->bits) & 1;
437 }
438
439 109 static int jpeg2000_decode_mel_sym(MelDecoderState *mel_state,
440 StateVars *mel_stream,
441 const uint8_t *Dcup,
442 uint32_t Lcup)
443 {
444
445
2/4
✓ Branch 0 taken 109 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
109 if (mel_state->run == 0 && mel_state->one == 0) {
446 uint8_t eval;
447 uint8_t bit;
448
449 109 eval = mel_e[mel_state->k];
450 109 bit = jpeg2000_import_bit(mel_stream, Dcup, Lcup);
451
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 96 times.
109 if (bit == 1) {
452 13 mel_state->run = 1 << eval;
453 13 mel_state->k = FFMIN(12, mel_state->k + 1);
454 } else {
455 96 mel_state->run = 0;
456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96 times.
96 while (eval > 0) {
457 bit = jpeg2000_import_bit(mel_stream, Dcup, Lcup);
458 mel_state->run = (2 * (mel_state->run)) + bit;
459 eval -= 1;
460 }
461
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 84 times.
96 mel_state->k = FFMAX(0, mel_state->k - 1);
462 96 mel_state->one = 1;
463 }
464 }
465
2/2
✓ Branch 0 taken 13 times.
✓ Branch 1 taken 96 times.
109 if (mel_state->run > 0) {
466 13 mel_state->run -= 1;
467 13 return 0;
468 } else {
469 96 mel_state->one = 0;
470 96 return 1;
471 }
472 }
473
474 /**
475 * Magref decoding procedures.
476 */
477 av_always_inline
478 static int jpeg2000_import_magref_bit(StateVars *stream, const uint8_t *array,
479 uint32_t length)
480 {
481 return jpeg2000_bitbuf_get_bits_lsb(stream, 1, array);
482 }
483
484 /**
485 * Signal EMB decode.
486 */
487 4096 static int jpeg2000_decode_sig_emb(const Jpeg2000DecoderContext *s, MelDecoderState *mel_state,
488 StateVars *mel_stream, StateVars *vlc_stream,
489 const uint16_t *vlc_table, const uint8_t *Dcup,
490 uint8_t *sig_pat, uint8_t *res_off, uint8_t *emb_pat_k,
491 uint8_t *emb_pat_1, uint8_t pos, uint16_t context,
492 uint32_t Lcup, uint32_t Pcup)
493 {
494
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 3993 times.
4096 if (context == 0) {
495 uint8_t sym;
496 103 sym = jpeg2000_decode_mel_sym(mel_state, mel_stream, Dcup, Lcup);
497
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 92 times.
103 if (sym == 0) {
498 11 sig_pat[pos] = 0;
499 11 res_off[pos] = 0;
500 11 emb_pat_k[pos] = 0;
501 11 emb_pat_1[pos] = 0;
502 11 return 0;
503 }
504 }
505 4085 return jpeg2000_decode_ctx_vlc(s, vlc_stream, vlc_table, Dcup, sig_pat,
506 res_off, emb_pat_k, emb_pat_1, pos, Pcup,
507 context);
508 }
509
510 av_always_inline
511 static int jpeg2000_get_state(int x1, int x2, int width, int shift_by,
512 const uint8_t *block_states)
513 {
514 return (block_states[(x1 + 1) * (width + 2) + (x2 + 1)] >> shift_by) & 1;
515 }
516
517 av_always_inline
518 16384 static void jpeg2000_modify_state(int x1, int x2, int width,
519 int value, uint8_t *block_states)
520 {
521 16384 block_states[(x1 + 1) * (width + 2) + (x2 + 1)] |= value;
522 16384 }
523
524 av_always_inline
525 10 static int jpeg2000_decode_ht_cleanup_segment(const Jpeg2000DecoderContext *s,
526 Jpeg2000Cblk *cblk, Jpeg2000T1Context *t1,
527 MelDecoderState *mel_state,
528 StateVars *mel_stream, StateVars *vlc_stream,
529 StateVars *mag_sgn_stream, const uint8_t *Dcup,
530 uint32_t Lcup, uint32_t Pcup, uint8_t pLSB,
531 int width, int height, int32_t *sample_buf,
532 uint8_t *block_states)
533 {
534 10 uint16_t q = 0; // Represents current quad position
535 uint16_t q1, q2;
536 uint16_t context1, context2;
537 10 uint16_t context = 0;
538
539 10 uint8_t sig_pat[2] = { 0 }; // significance pattern
540 10 uint8_t res_off[2] = { 0 }; // residual offset
541 10 uint8_t emb_pat_k[2] = { 0 }; // exponent Max Bound pattern K
542 10 uint8_t emb_pat_1[2] = { 0 }; // exponent Max Bound pattern 1
543 10 uint8_t gamma[2] = { 0 };
544
545 10 uint8_t E_n[2] = { 0 };
546 10 uint8_t E_ne[2] = { 0 };
547 10 uint8_t E_nw[2] = { 0 };
548 10 uint8_t E_nf[2] = { 0 };
549
550 10 uint8_t max_e[2] = { 0 };
551 10 uint8_t u_pfx[2] = { 0 };
552 10 uint8_t u_sfx[2] = { 0 };
553 10 uint8_t u_ext[2] = { 0 };
554
555 10 int32_t u[2] = { 0 };
556 10 int32_t U[2] = { 0 }; // exponent bound
557 10 int32_t m_n[2] = { 0 };
558 10 int32_t known_1[2] = { 0 };
559
560 10 int32_t m[2][4] = { 0 };
561 10 int32_t v[2][4] = { 0 };
562
563 10 uint8_t kappa[2] = { 1, 1 };
564
565 10 int ret = 0;
566
567 int sp;
568
569 uint64_t c;
570
571 uint8_t *sigma, *sigma_n, *E;
572 uint32_t *mu, *mu_n;
573
574 10 const uint8_t *vlc_buf = Dcup + Pcup;
575
576 /*
577 * Bound on the precision needed to process the codeblock. The number of
578 * decoded bit planes is equal to at most cblk->zbp + 2 since S_blk = P if
579 * there are no placeholder passes or HT Sets and P = cblk->zbp. See Rec.
580 * ITU-T T.814, 7.6.
581 */
582 10 int maxbp = cblk->zbp + 2;
583
584 /* convert to raster-scan */
585 10 const uint16_t is_border_x = width % 2;
586 10 const uint16_t is_border_y = height % 2;
587
588 10 const uint16_t quad_width = ff_jpeg2000_ceildivpow2(width, 1);
589 10 const uint16_t quad_height = ff_jpeg2000_ceildivpow2(height, 1);
590
591 10 size_t buf_size = 4 * quad_width * quad_height;
592
593 /* do we have enough precision, assuming a 32-bit decoding path */
594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (maxbp >= 32)
595 return AVERROR_INVALIDDATA;
596
597 10 sigma_n = av_calloc(buf_size, sizeof(uint8_t));
598 10 E = av_calloc(buf_size, sizeof(uint8_t));
599 10 mu_n = av_calloc(buf_size, sizeof(uint32_t));
600
601
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
10 if (!sigma_n || !E || !mu_n) {
602 ret = AVERROR(ENOMEM);
603 goto free;
604 }
605
606 10 sigma = sigma_n;
607 10 mu = mu_n;
608
609
2/2
✓ Branch 0 taken 88 times.
✓ Branch 1 taken 10 times.
98 while (q < quad_width - 1) {
610 88 q1 = q;
611 88 q2 = q1 + 1;
612
613
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
88 if ((ret = jpeg2000_decode_sig_emb(s, mel_state, mel_stream, vlc_stream,
614 dec_cxt_vlc_table0, Dcup, sig_pat, res_off,
615 emb_pat_k, emb_pat_1, J2K_Q1, context, Lcup,
616 Pcup)) < 0)
617 goto free;
618
619
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 88 times.
440 for (int i = 0; i < 4; i++)
620 352 sigma_n[4 * q1 + i] = (sig_pat[J2K_Q1] >> i) & 1;
621
622 /* calculate context */
623 88 context = sigma_n[4 * q1]; // f
624 88 context |= sigma_n[4 * q1 + 1]; // sf
625 88 context += sigma_n[4 * q1 + 2] << 1; // w << 1
626 88 context += sigma_n[4 * q1 + 3] << 2;
627
628
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 88 times.
88 if ((ret = jpeg2000_decode_sig_emb(s, mel_state, mel_stream, vlc_stream,
629 dec_cxt_vlc_table0, Dcup, sig_pat, res_off,
630 emb_pat_k, emb_pat_1, J2K_Q2, context, Lcup,
631 Pcup)) < 0)
632 goto free;
633
634
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 88 times.
440 for (int i = 0; i < 4; i++)
635 352 sigma_n[4 * q2 + i] = (sig_pat[J2K_Q2] >> i) & 1;
636
637 /* calculate context for the next quad */
638 88 context = sigma_n[4 * q2]; // f
639 88 context |= sigma_n[4 * q2 + 1]; // sf
640 88 context += sigma_n[4 * q2 + 2] << 1; // w << 1
641 88 context += sigma_n[4 * q2 + 3] << 2; // sw << 2
642
643 88 u[0] = 0;
644 88 u[1] = 0;
645
646 88 jpeg2000_bitbuf_refill_backwards(vlc_stream, vlc_buf);
647
648
4/4
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 10 times.
88 if (res_off[J2K_Q1] == 1 && res_off[J2K_Q2] == 1) {
649
650
2/2
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 2 times.
12 if (jpeg2000_decode_mel_sym(mel_state, mel_stream, Dcup, Lcup) == 1) {
651
652 4 u_pfx[J2K_Q1] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
653 4 u_pfx[J2K_Q2] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
654
655 4 u_sfx[J2K_Q1] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q1], vlc_buf);
656 4 u_sfx[J2K_Q2] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q2], vlc_buf);
657
658 4 u_ext[J2K_Q1] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q1], vlc_buf);
659 4 u_ext[J2K_Q2] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q2], vlc_buf);
660
661 4 u[J2K_Q1] = 2 + u_pfx[J2K_Q1] + u_sfx[J2K_Q1] + (u_ext[J2K_Q1] * 4);
662 4 u[J2K_Q2] = 2 + u_pfx[J2K_Q2] + u_sfx[J2K_Q2] + (u_ext[J2K_Q2] * 4);
663
664 } else {
665 2 u_pfx[J2K_Q1] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
666
667
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if (u_pfx[J2K_Q1] > 2) {
668 u[J2K_Q2] = jpeg2000_bitbuf_get_bits_lsb(vlc_stream, 1, vlc_buf) + 1;
669 u_sfx[J2K_Q1] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q1], vlc_buf);
670 u_ext[J2K_Q1] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q1], vlc_buf);
671 } else {
672 2 u_pfx[J2K_Q2] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
673 2 u_sfx[J2K_Q1] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q1], vlc_buf);
674 2 u_sfx[J2K_Q2] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q2], vlc_buf);
675 2 u_ext[J2K_Q1] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q1], vlc_buf);
676 2 u_ext[J2K_Q2] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q2], vlc_buf);
677 2 u[J2K_Q2] = u_pfx[J2K_Q2] + u_sfx[J2K_Q2] + (u_ext[J2K_Q2] * 4);
678 }
679 /* See Rec. ITU-T T.814, 7.3.6(3) */
680 2 u[J2K_Q1] = u_pfx[J2K_Q1] + u_sfx[J2K_Q1] + (u_ext[J2K_Q1] * 4);
681 }
682
683
4/4
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 21 times.
✓ Branch 3 taken 51 times.
82 } else if (res_off[J2K_Q1] == 1 || res_off[J2K_Q2] == 1) {
684 31 uint8_t pos = res_off[J2K_Q1] == 1 ? 0 : 1;
685 31 u_pfx[pos] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
686 31 u_sfx[pos] = vlc_decode_u_suffix(vlc_stream, u_pfx[pos], vlc_buf);
687 31 u_ext[pos] = vlc_decode_u_extension(vlc_stream, u_sfx[pos], vlc_buf);
688 31 u[pos] = u_pfx[pos] + u_sfx[pos] + (u_ext[pos] * 4);
689 }
690 88 U[J2K_Q1] = kappa[J2K_Q1] + u[J2K_Q1];
691 88 U[J2K_Q2] = kappa[J2K_Q2] + u[J2K_Q2];
692
2/4
✓ Branch 0 taken 88 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 88 times.
88 if (U[J2K_Q1] > maxbp || U[J2K_Q2] > maxbp) {
693 ret = AVERROR_INVALIDDATA;
694 goto free;
695 }
696
697
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 88 times.
440 for (int i = 0; i < 4; i++) {
698 352 m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - ((emb_pat_k[J2K_Q1] >> i) & 1);
699 352 m[J2K_Q2][i] = sigma_n[4 * q2 + i] * U[J2K_Q2] - ((emb_pat_k[J2K_Q2] >> i) & 1);
700 }
701
702 88 recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, emb_pat_1, v, m,
703 E, mu_n, Dcup, Pcup, pLSB);
704
705 88 recover_mag_sgn(mag_sgn_stream, J2K_Q2, q2, m_n, known_1, emb_pat_1, v, m,
706 E, mu_n, Dcup, Pcup, pLSB);
707
708 88 q += 2; // Move to the next quad pair
709 }
710
711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (quad_width % 2 == 1) {
712 q1 = q;
713
714 if ((ret = jpeg2000_decode_sig_emb(s, mel_state, mel_stream, vlc_stream,
715 dec_cxt_vlc_table0, Dcup, sig_pat, res_off,
716 emb_pat_k, emb_pat_1, J2K_Q1, context, Lcup,
717 Pcup)) < 0)
718 goto free;
719
720 for (int i = 0; i < 4; i++)
721 sigma_n[4 * q1 + i] = (sig_pat[J2K_Q1] >> i) & 1;
722
723 u[J2K_Q1] = 0;
724
725 if (res_off[J2K_Q1] == 1) {
726 u_pfx[J2K_Q1] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
727 u_sfx[J2K_Q1] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q1], vlc_buf);
728 u_ext[J2K_Q1] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q1], vlc_buf);
729 u[J2K_Q1] = u_pfx[J2K_Q1] + u_sfx[J2K_Q1] + (u_ext[J2K_Q1] * 4);
730 }
731
732 U[J2K_Q1] = kappa[J2K_Q1] + u[J2K_Q1];
733 if (U[J2K_Q1] > maxbp) {
734 ret = AVERROR_INVALIDDATA;
735 goto free;
736 }
737
738 for (int i = 0; i < 4; i++)
739 m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - ((emb_pat_k[J2K_Q1] >> i) & 1);
740
741 recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, emb_pat_1, v, m,
742 E, mu_n, Dcup, Pcup, pLSB);
743
744 q++; // move to next quad pair
745 }
746
747 /**
748 * Initial line pair end. As an optimization, we can replace modulo
749 * operations with checking if a number is divisible , since that's the only
750 * thing we need. This is paired with is_divisible. Credits to Daniel Lemire
751 * blog post [1].
752 *
753 * [1]
754 * https://lemire.me/blog/2019/02/08/faster-remainders-when-the-divisor-is-a-constant-beating-compilers-and-libdivide/
755 *
756 * It's UB on zero, but the spec doesn't allow a quad being zero, so we
757 * error out early in case that's the case.
758 */
759 10 c = precompute_c(quad_width);
760
761
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 10 times.
176 for (int row = 1; row < quad_height; row++) {
762
3/4
✓ Branch 0 taken 1960 times.
✓ Branch 1 taken 166 times.
✓ Branch 2 taken 1960 times.
✗ Branch 3 not taken.
2126 while ((q - (row * quad_width)) < quad_width - 1 && q < (quad_height * quad_width)) {
763 1960 q1 = q;
764 1960 q2 = q + 1;
765 1960 context1 = sigma_n[4 * (q1 - quad_width) + 1];
766 1960 context1 += sigma_n[4 * (q1 - quad_width) + 3] << 2; // ne
767
768
2/2
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 166 times.
1960 if (!is_divisible(q1, c)) {
769 1794 context1 |= sigma_n[4 * (q1 - quad_width) - 1]; // nw
770 1794 context1 += (sigma_n[4 * q1 - 1] | sigma_n[4 * q1 - 2]) << 1; // sw | q
771 }
772
1/2
✓ Branch 1 taken 1960 times.
✗ Branch 2 not taken.
1960 if (!is_divisible(q1 + 1, c))
773 1960 context1 |= sigma_n[4 * (q1 - quad_width) + 5] << 2;
774
775
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1960 times.
1960 if ((ret = jpeg2000_decode_sig_emb(s, mel_state, mel_stream, vlc_stream,
776 dec_cxt_vlc_table1, Dcup, sig_pat, res_off,
777 emb_pat_k, emb_pat_1, J2K_Q1, context1, Lcup,
778 Pcup))
779 < 0)
780 goto free;
781
782
2/2
✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 1960 times.
9800 for (int i = 0; i < 4; i++)
783 7840 sigma_n[4 * q1 + i] = (sig_pat[J2K_Q1] >> i) & 1;
784
785 1960 context2 = sigma_n[4 * (q2 - quad_width) + 1];
786 1960 context2 += sigma_n[4 * (q2 - quad_width) + 3] << 2;
787
788
1/2
✓ Branch 1 taken 1960 times.
✗ Branch 2 not taken.
1960 if (!is_divisible(q2, c)) {
789 1960 context2 |= sigma_n[4 * (q2 - quad_width) - 1];
790 1960 context2 += (sigma_n[4 * q2 - 1] | sigma_n[4 * q2 - 2]) << 1;
791 }
792
2/2
✓ Branch 1 taken 1794 times.
✓ Branch 2 taken 166 times.
1960 if (!is_divisible(q2 + 1, c))
793 1794 context2 |= sigma_n[4 * (q2 - quad_width) + 5] << 2;
794
795
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 1960 times.
1960 if ((ret = jpeg2000_decode_sig_emb(s, mel_state, mel_stream, vlc_stream,
796 dec_cxt_vlc_table1, Dcup, sig_pat, res_off,
797 emb_pat_k, emb_pat_1, J2K_Q2, context2, Lcup,
798 Pcup))
799 < 0)
800 goto free;
801
802
2/2
✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 1960 times.
9800 for (int i = 0; i < 4; i++)
803 7840 sigma_n[4 * q2 + i] = (sig_pat[J2K_Q2] >> i) & 1;
804
805 1960 u[J2K_Q1] = 0;
806 1960 u[J2K_Q2] = 0;
807
808 1960 jpeg2000_bitbuf_refill_backwards(vlc_stream, vlc_buf);
809
810
4/4
✓ Branch 0 taken 743 times.
✓ Branch 1 taken 1217 times.
✓ Branch 2 taken 461 times.
✓ Branch 3 taken 282 times.
1960 if (res_off[J2K_Q1] == 1 && res_off[J2K_Q2] == 1) {
811 461 u_pfx[J2K_Q1] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
812 461 u_pfx[J2K_Q2] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
813
814 461 u_sfx[J2K_Q1] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q1], vlc_buf);
815 461 u_sfx[J2K_Q2] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q2], vlc_buf);
816
817 461 u_ext[J2K_Q1] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q1], vlc_buf);
818 461 u_ext[J2K_Q2] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q2], vlc_buf);
819
820 461 u[J2K_Q1] = u_pfx[J2K_Q1] + u_sfx[J2K_Q1] + (u_ext[J2K_Q1] << 2);
821 461 u[J2K_Q2] = u_pfx[J2K_Q2] + u_sfx[J2K_Q2] + (u_ext[J2K_Q2] << 2);
822
823
4/4
✓ Branch 0 taken 1217 times.
✓ Branch 1 taken 282 times.
✓ Branch 2 taken 301 times.
✓ Branch 3 taken 916 times.
1499 } else if (res_off[J2K_Q1] == 1 || res_off[J2K_Q2] == 1) {
824 583 uint8_t pos = res_off[J2K_Q1] == 1 ? 0 : 1;
825
826 583 u_pfx[pos] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
827 583 u_sfx[pos] = vlc_decode_u_suffix(vlc_stream, u_pfx[pos], vlc_buf);
828 583 u_ext[pos] = vlc_decode_u_extension(vlc_stream, u_sfx[pos], vlc_buf);
829
830 583 u[pos] = u_pfx[pos] + u_sfx[pos] + (u_ext[pos] << 2);
831 }
832 1960 sp = sig_pat[J2K_Q1];
833
834 1960 gamma[J2K_Q1] = 1;
835
836
10/10
✓ Branch 0 taken 1859 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 1788 times.
✓ Branch 3 taken 71 times.
✓ Branch 4 taken 1713 times.
✓ Branch 5 taken 75 times.
✓ Branch 6 taken 1631 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 72 times.
✓ Branch 9 taken 1559 times.
1960 if (sp == 0 || sp == 1 || sp == 2 || sp == 4 || sp == 8)
837 401 gamma[J2K_Q1] = 0;
838
839 1960 sp = sig_pat[J2K_Q2];
840
841 1960 gamma[J2K_Q2] = 1;
842
843
10/10
✓ Branch 0 taken 1861 times.
✓ Branch 1 taken 99 times.
✓ Branch 2 taken 1782 times.
✓ Branch 3 taken 79 times.
✓ Branch 4 taken 1707 times.
✓ Branch 5 taken 75 times.
✓ Branch 6 taken 1630 times.
✓ Branch 7 taken 77 times.
✓ Branch 8 taken 79 times.
✓ Branch 9 taken 1551 times.
1960 if (sp == 0 || sp == 1 || sp == 2 || sp == 4 || sp == 8)
844 409 gamma[J2K_Q2] = 0;
845
846 1960 E_n[J2K_Q1] = E[4 * (q1 - quad_width) + 1];
847 1960 E_n[J2K_Q2] = E[4 * (q2 - quad_width) + 1];
848
849 1960 E_ne[J2K_Q1] = E[4 * (q1 - quad_width) + 3];
850 1960 E_ne[J2K_Q2] = E[4 * (q2 - quad_width) + 3];
851
852
2/2
✓ Branch 1 taken 1950 times.
✓ Branch 2 taken 10 times.
1960 E_nw[J2K_Q1] = (!is_divisible(q1, c)) * E[FFMAX((4 * (q1 - quad_width) - 1), 0)];
853
1/2
✓ Branch 1 taken 1960 times.
✗ Branch 2 not taken.
1960 E_nw[J2K_Q2] = (!is_divisible(q2, c)) * E[FFMAX((4 * (q2 - quad_width) - 1), 0)];
854
855 1960 E_nf[J2K_Q1] = (!is_divisible(q1 + 1, c)) * E[4 * (q1 - quad_width) + 5];
856 1960 E_nf[J2K_Q2] = (!is_divisible(q2 + 1, c)) * E[4 * (q2 - quad_width) + 5];
857
858 1960 max_e[J2K_Q1] = FFMAX(E_nw[J2K_Q1], FFMAX3(E_n[J2K_Q1], E_ne[J2K_Q1], E_nf[J2K_Q1]));
859 1960 max_e[J2K_Q2] = FFMAX(E_nw[J2K_Q2], FFMAX3(E_n[J2K_Q2], E_ne[J2K_Q2], E_nf[J2K_Q2]));
860
861 1960 kappa[J2K_Q1] = FFMAX(1, gamma[J2K_Q1] * (max_e[J2K_Q1] - 1));
862 1960 kappa[J2K_Q2] = FFMAX(1, gamma[J2K_Q2] * (max_e[J2K_Q2] - 1));
863
864 1960 U[J2K_Q1] = kappa[J2K_Q1] + u[J2K_Q1];
865 1960 U[J2K_Q2] = kappa[J2K_Q2] + u[J2K_Q2];
866
2/4
✓ Branch 0 taken 1960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1960 times.
1960 if (U[J2K_Q1] > maxbp || U[J2K_Q2] > maxbp) {
867 ret = AVERROR_INVALIDDATA;
868 goto free;
869 }
870
871
2/2
✓ Branch 0 taken 7840 times.
✓ Branch 1 taken 1960 times.
9800 for (int i = 0; i < 4; i++) {
872 7840 m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - ((emb_pat_k[J2K_Q1] >> i) & 1);
873 7840 m[J2K_Q2][i] = sigma_n[4 * q2 + i] * U[J2K_Q2] - ((emb_pat_k[J2K_Q2] >> i) & 1);
874 }
875 1960 recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, emb_pat_1, v, m,
876 E, mu_n, Dcup, Pcup, pLSB);
877
878 1960 recover_mag_sgn(mag_sgn_stream, J2K_Q2, q2, m_n, known_1, emb_pat_1, v, m,
879 E, mu_n, Dcup, Pcup, pLSB);
880
881 1960 q += 2; // Move to the next quad pair
882 }
883
884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 166 times.
166 if (quad_width % 2 == 1) {
885 q1 = q;
886
887 /* calculate context for current quad */
888 context1 = sigma_n[4 * (q1 - quad_width) + 1];
889 context1 += (sigma_n[4 * (q1 - quad_width) + 3] << 2);
890
891 if (!is_divisible(q1, c)) {
892 context1 |= sigma_n[4 * (q1 - quad_width) - 1];
893 context1 += (sigma_n[4 * q1 - 1] | sigma_n[4 * q1 - 2]) << 1;
894 }
895 if (!is_divisible(q1 + 1, c))
896 context1 |= sigma_n[4 * (q1 - quad_width) + 5] << 2;
897
898 if ((ret = jpeg2000_decode_sig_emb(s, mel_state, mel_stream, vlc_stream,
899 dec_cxt_vlc_table1, Dcup, sig_pat, res_off,
900 emb_pat_k, emb_pat_1, J2K_Q1, context1, Lcup,
901 Pcup)) < 0)
902 goto free;
903
904 for (int i = 0; i < 4; i++)
905 sigma_n[4 * q1 + i] = (sig_pat[J2K_Q1] >> i) & 1;
906
907 u[J2K_Q1] = 0;
908
909 /* Recover mag_sgn value */
910 if (res_off[J2K_Q1] == 1) {
911 u_pfx[J2K_Q1] = vlc_decode_u_prefix(vlc_stream, vlc_buf);
912 u_sfx[J2K_Q1] = vlc_decode_u_suffix(vlc_stream, u_pfx[J2K_Q1], vlc_buf);
913 u_ext[J2K_Q1] = vlc_decode_u_extension(vlc_stream, u_sfx[J2K_Q1], vlc_buf);
914
915 u[J2K_Q1] = u_pfx[J2K_Q1] + u_sfx[J2K_Q1] + (u_ext[J2K_Q1] << 2);
916 }
917
918 sp = sig_pat[J2K_Q1];
919
920 gamma[J2K_Q1] = 1;
921
922 if (sp == 0 || sp == 1 || sp == 2 || sp == 4 || sp == 8)
923 gamma[J2K_Q1] = 0;
924
925 E_n[J2K_Q1] = E[4 * (q1 - quad_width) + 1];
926
927 E_ne[J2K_Q1] = E[4 * (q1 - quad_width) + 3];
928
929 E_nw[J2K_Q1] = (!is_divisible(q1, c)) * E[FFMAX((4 * (q1 - quad_width) - 1), 0)];
930
931 E_nf[J2K_Q1] = (!is_divisible(q1 + 1, c)) * E[4 * (q1 - quad_width) + 5];
932
933 max_e[J2K_Q1] = FFMAX(E_nw[J2K_Q1], FFMAX3(E_n[J2K_Q1], E_ne[J2K_Q1], E_nf[J2K_Q1]));
934
935 kappa[J2K_Q1] = FFMAX(1, gamma[J2K_Q1] * (max_e[J2K_Q1] - 1));
936
937 U[J2K_Q1] = kappa[J2K_Q1] + u[J2K_Q1];
938 if (U[J2K_Q1] > maxbp) {
939 ret = AVERROR_INVALIDDATA;
940 goto free;
941 }
942
943 for (int i = 0; i < 4; i++)
944 m[J2K_Q1][i] = sigma_n[4 * q1 + i] * U[J2K_Q1] - ((emb_pat_k[J2K_Q1] >> i) & 1);
945
946 recover_mag_sgn(mag_sgn_stream, J2K_Q1, q1, m_n, known_1, emb_pat_1, v, m,
947 E, mu_n, Dcup, Pcup, pLSB);
948 q += 1;
949 }
950 }
951
952 // convert to raster-scan
953
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 10 times.
186 for (int y = 0; y < quad_height; y++) {
954
2/2
✓ Branch 0 taken 4096 times.
✓ Branch 1 taken 176 times.
4272 for (int x = 0; x < quad_width; x++) {
955 int j1, j2;
956 int x1, x2 , x3;
957
958 4096 j1 = 2 * y;
959 4096 j2 = 2 * x;
960
961 4096 sample_buf[j2 + (j1 * width)] = (int32_t)*mu;
962 4096 jpeg2000_modify_state(j1, j2, width, *sigma, block_states);
963 4096 sigma += 1;
964 4096 mu += 1;
965
966
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 3920 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
4096 x1 = y != quad_height - 1 || is_border_y == 0;
967 4096 sample_buf[j2 + ((j1 + 1) * width)] = ((int32_t)*mu) * x1;
968 4096 jpeg2000_modify_state(j1 + 1, j2, width, (*sigma) * x1, block_states);
969 4096 sigma += 1;
970 4096 mu += 1;
971
972
3/4
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 3920 times.
✓ Branch 2 taken 176 times.
✗ Branch 3 not taken.
4096 x2 = x != quad_width - 1 || is_border_x == 0;
973 4096 sample_buf[(j2 + 1) + (j1 * width)] = ((int32_t)*mu) * x2;
974 4096 jpeg2000_modify_state(j1, j2 + 1, width, (*sigma) * x2, block_states);
975 4096 sigma += 1;
976 4096 mu += 1;
977
978 4096 x3 = x1 | x2;
979 4096 sample_buf[(j2 + 1) + (j1 + 1) * width] = ((int32_t)*mu) * x3;
980 4096 jpeg2000_modify_state(j1 + 1, j2 + 1, width, (*sigma) * x3, block_states);
981 4096 sigma += 1;
982 4096 mu += 1;
983 }
984 }
985 10 ret = 1;
986 10 free:
987 10 av_freep(&sigma_n);
988 10 av_freep(&E);
989 10 av_freep(&mu_n);
990 10 return ret;
991 }
992
993 static void jpeg2000_calc_mbr(uint8_t *mbr, const uint16_t i, const uint16_t j,
994 const uint32_t mbr_info, uint8_t causal_cond,
995 uint8_t *block_states, int width)
996 {
997 int local_mbr = 0;
998
999 local_mbr |= jpeg2000_get_state(i - 1, j - 1, width, HT_SHIFT_SIGMA, block_states);
1000 local_mbr |= jpeg2000_get_state(i - 1, j + 0, width, HT_SHIFT_SIGMA, block_states);
1001 local_mbr |= jpeg2000_get_state(i - 1, j + 1, width, HT_SHIFT_SIGMA, block_states);
1002
1003 local_mbr |= jpeg2000_get_state(i + 0, j - 1, width, HT_SHIFT_SIGMA, block_states);
1004 local_mbr |= jpeg2000_get_state(i + 0, j + 1, width, HT_SHIFT_SIGMA, block_states);
1005
1006 local_mbr |= jpeg2000_get_state(i + 1, j - 1, width, HT_SHIFT_SIGMA, block_states) * causal_cond;
1007 local_mbr |= jpeg2000_get_state(i + 1, j + 0, width, HT_SHIFT_SIGMA, block_states) * causal_cond;
1008 local_mbr |= jpeg2000_get_state(i + 1, j + 1, width, HT_SHIFT_SIGMA, block_states) * causal_cond;
1009
1010 local_mbr |= jpeg2000_get_state(i - 1, j - 1, width, HT_SHIFT_REF, block_states) *
1011 jpeg2000_get_state(i - 1, j - 1, width, HT_SHIFT_SCAN, block_states);
1012 local_mbr |= jpeg2000_get_state(i - 1, j + 0, width, HT_SHIFT_REF, block_states) *
1013 jpeg2000_get_state(i - 1, j - 1, width, HT_SHIFT_SCAN, block_states);
1014 local_mbr |= jpeg2000_get_state(i - 1, j + 1, width, HT_SHIFT_REF, block_states) *
1015 jpeg2000_get_state(i - 1, j + 1, width, HT_SHIFT_SCAN, block_states);
1016
1017 local_mbr |= jpeg2000_get_state(i + 0, j - 1, width, HT_SHIFT_REF, block_states) *
1018 jpeg2000_get_state(i + 0, j - 1, width, HT_SHIFT_SCAN, block_states);
1019 local_mbr |= jpeg2000_get_state(i + 0, j + 1, width, HT_SHIFT_REF, block_states) *
1020 jpeg2000_get_state(i + 0, j + 1, width, HT_SHIFT_SCAN, block_states);
1021
1022 local_mbr |= jpeg2000_get_state(i + 1, j - 1, width, HT_SHIFT_REF, block_states) *
1023 jpeg2000_get_state(i + 1, j - 1, width, HT_SHIFT_SCAN, block_states) * causal_cond;
1024 local_mbr |= jpeg2000_get_state(i + 1, j + 0, width, HT_SHIFT_REF, block_states) *
1025 jpeg2000_get_state(i + 1, j + 0, width, HT_SHIFT_SCAN, block_states) * causal_cond;
1026 local_mbr |= jpeg2000_get_state(i + 1, j + 1, width, HT_SHIFT_REF, block_states) *
1027 jpeg2000_get_state(i + 1, j + 1, width, HT_SHIFT_SCAN, block_states) * causal_cond;
1028
1029 *mbr |= local_mbr;
1030 }
1031
1032 static void jpeg2000_process_stripes_block(StateVars *sig_prop, int i_s, int j_s,
1033 int width, int height, int stride, int pLSB,
1034 int32_t *sample_buf, uint8_t *block_states,
1035 uint8_t *magref_segment, uint32_t magref_length)
1036 {
1037 for (int j = j_s; j < j_s + width; j++) {
1038 uint32_t mbr_info = 0;
1039 for (int i = i_s; i < i_s + height; i++) {
1040 int modify_state, cond;
1041 uint8_t bit;
1042 uint8_t causal_cond = i != (i_s + height - 1);
1043 int32_t *sp = &sample_buf[j + (i * (stride - 2))];
1044 uint8_t mbr = 0;
1045
1046 if (jpeg2000_get_state(i, j, stride - 2, HT_SHIFT_SIGMA, block_states) == 0)
1047 jpeg2000_calc_mbr(&mbr, i, j, mbr_info & 0x1EF, causal_cond, block_states, stride - 2);
1048 mbr_info >>= 3;
1049 cond = mbr != 0;
1050 bit = jpeg2000_peek_bit(sig_prop, magref_segment, magref_length);
1051 *sp |= (bit * cond) << pLSB;
1052 sig_prop->bits -= cond;
1053 modify_state = (((1 << HT_SHIFT_REF_IND) | (1 << HT_SHIFT_REF)) * cond) | 1 << HT_SHIFT_SCAN;
1054 jpeg2000_modify_state(i, j, stride - 2, modify_state, block_states);
1055 }
1056 }
1057 }
1058
1059 /**
1060 * See procedure decodeSigPropMag at Rec. ITU-T T.814, 7.4.
1061 */
1062 av_noinline
1063 static void jpeg2000_decode_sigprop_segment(Jpeg2000Cblk *cblk, uint16_t width,
1064 uint16_t height, uint8_t *magref_segment,
1065 uint32_t magref_length, uint8_t pLSB,
1066 int32_t *sample_buf, uint8_t *block_states)
1067 {
1068 StateVars sp_dec;
1069
1070 const uint16_t num_v_stripe = height / 4;
1071 const uint16_t num_h_stripe = width / 4;
1072 int b_width = 4;
1073 int b_height = 4;
1074 int stride = width + 2;
1075
1076 int last_width;
1077 uint16_t i = 0, j = 0;
1078
1079 jpeg2000_init_zero(&sp_dec);
1080
1081 for (int n1 = 0; n1 < num_v_stripe; n1++) {
1082 j = 0;
1083 for (int n2 = 0; n2 < num_h_stripe; n2++) {
1084 jpeg2000_process_stripes_block(&sp_dec, i, j, b_width, b_height, stride,
1085 pLSB, sample_buf, block_states, magref_segment,
1086 magref_length);
1087 j += 4;
1088 }
1089 last_width = width % 4;
1090 if (last_width)
1091 jpeg2000_process_stripes_block(&sp_dec, i, j, last_width, b_height, stride,
1092 pLSB, sample_buf, block_states, magref_segment,
1093 magref_length);
1094 i += 4;
1095 }
1096
1097 /* Decode remaining height stripes */
1098 b_height = height % 4;
1099 j = 0;
1100 for (int n2 = 0; n2 < num_h_stripe; n2++) {
1101 jpeg2000_process_stripes_block(&sp_dec, i, j, b_width, b_height, stride,
1102 pLSB, sample_buf, block_states, magref_segment,
1103 magref_length);
1104 j += 4;
1105 }
1106 last_width = width % 4;
1107 if (last_width)
1108 jpeg2000_process_stripes_block(&sp_dec, i, j, last_width, b_height, stride,
1109 pLSB, sample_buf, block_states, magref_segment,
1110 magref_length);
1111 }
1112
1113 /**
1114 * See procedure decodeSigPropMag at Rec. ITU-T T.814, 7.5.
1115 */
1116 static int
1117 jpeg2000_decode_magref_segment( uint16_t width, uint16_t block_height,
1118 uint8_t *magref_segment,uint32_t magref_length,
1119 uint8_t pLSB, int32_t *sample_buf, uint8_t *block_states)
1120 {
1121
1122 StateVars mag_ref = { 0 };
1123 const uint16_t num_v_stripe = block_height / 4;
1124 uint16_t height = 4;
1125 uint16_t i_start = 0;
1126 int32_t *sp;
1127
1128 jpeg2000_init_mag_ref(&mag_ref, magref_length);
1129
1130 for (int n1 = 0; n1 < num_v_stripe; n1++) {
1131 for (int j = 0; j < width; j++) {
1132 for (int i = i_start; i < i_start + height; i++) {
1133 /**
1134 * We move column wise, going from one quad to another. See
1135 * Rec. ITU-T T.814, Figure 7.
1136 */
1137 sp = &sample_buf[j + i * width];
1138 if (jpeg2000_get_state(i, j, width, HT_SHIFT_SIGMA, block_states) != 0) {
1139 jpeg2000_modify_state(i, j, width, 1 << HT_SHIFT_REF_IND, block_states);
1140 *sp |= jpeg2000_import_magref_bit(&mag_ref, magref_segment, magref_length) << pLSB;
1141 }
1142 }
1143 }
1144 i_start += 4;
1145 }
1146 height = block_height % 4;
1147 for (int j = 0; j < width; j++) {
1148 for (int i = i_start; i < i_start + height; i++) {
1149 sp = &sample_buf[j + i * width];
1150 if (jpeg2000_get_state(i, j, width, HT_SHIFT_SIGMA, block_states) != 0) {
1151 jpeg2000_modify_state(i, j, width, 1 << HT_SHIFT_REF_IND, block_states);
1152 *sp |= jpeg2000_import_magref_bit(&mag_ref, magref_segment, magref_length) << pLSB;
1153 }
1154 }
1155 }
1156 return 1;
1157 }
1158
1159
1160 int
1161 10 ff_jpeg2000_decode_htj2k(const Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *codsty, Jpeg2000T1Context *t1, Jpeg2000Cblk *cblk,
1162 int width, int height, int magp, uint8_t roi_shift)
1163 {
1164 10 uint8_t p0 = 0; // Number of placeholder passes
1165 uint32_t Lcup; // Length of HT cleanup segment
1166 uint32_t Lref; // Length of Refinement segment
1167 uint32_t Scup; // HT cleanup segment suffix length
1168 uint32_t Pcup; // HT cleanup segment prefix length
1169
1170 uint8_t S_blk; // Number of skipped magnitude bitplanes
1171 uint8_t pLSB;
1172
1173 uint8_t *Dcup; // Byte of an HT cleanup segment
1174 uint8_t *Dref; // Byte of an HT refinement segment
1175
1176 int z_blk; // Number of ht coding pass
1177
1178 uint8_t empty_passes;
1179
1180 StateVars mag_sgn; // Magnitude and Sign
1181 StateVars mel; // Adaptive run-length coding
1182 StateVars vlc; // Variable Length coding
1183 StateVars sig_prop; // Significance propagation
1184
1185 MelDecoderState mel_state;
1186
1187 int ret;
1188
1189 /* Temporary buffers */
1190 10 int32_t *sample_buf = NULL;
1191 10 uint8_t *block_states = NULL;
1192
1193 int32_t n, val; // Post-processing
1194
1195 10 int32_t M_b = magp;
1196
1197 /* codeblock size as constrained by Rec. ITU-T T.800, Table A.18 */
1198
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 av_assert0(width <= 1024U && height <= 1024U);
1199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 av_assert0(width * height <= 4096);
1200
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 av_assert0(width * height > 0);
1201
1202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (roi_shift)
1203 avpriv_report_missing_feature(s->avctx, "ROI shift");
1204
1205 10 memset(t1->data, 0, t1->stride * height * sizeof(*t1->data));
1206 10 memset(t1->flags, 0, t1->stride * (height + 2) * sizeof(*t1->flags));
1207
1208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (cblk->npasses == 0)
1209 return 0;
1210
1211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (cblk->npasses > 3)
1212 p0 = 0;
1213
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 else if (cblk->length == 0)
1214 p0 = 1;
1215
1216 10 empty_passes = p0 * 3;
1217 10 z_blk = cblk->npasses - empty_passes;
1218
1219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (z_blk <= 0)
1220 return 0; // No passes within this set, continue
1221
1222 10 Lcup = cblk->pass_lengths[0];
1223 10 Lref = cblk->pass_lengths[1];
1224
1225
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (Lcup < 2) {
1226 av_log(s->avctx, AV_LOG_ERROR,
1227 "Cleanup pass length must be at least 2 bytes in length\n");
1228 return AVERROR_INVALIDDATA;
1229 }
1230 10 Dcup = cblk->data;
1231 10 Dref = cblk->data + Lcup; // Dref comes after the refinement segment
1232 10 S_blk = p0 + cblk->zbp;
1233 10 pLSB = 30 - S_blk;
1234
1235 10 Scup = (Dcup[Lcup - 1] << 4) + (Dcup[Lcup - 2] & 0x0F);
1236
1237
3/6
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 10 times.
10 if (Scup < 2 || Scup > Lcup || Scup > 4079) {
1238 av_log(s->avctx, AV_LOG_ERROR, "Cleanup pass suffix length is invalid %d\n",
1239 Scup);
1240 ret = AVERROR_INVALIDDATA;
1241 goto free;
1242 }
1243 10 Pcup = Lcup - Scup;
1244
1245 /* modDcup shall be done before the creation of vlc instance. */
1246 10 Dcup[Lcup - 1] = 0xFF;
1247 10 Dcup[Lcup - 2] |= 0x0F;
1248
1249 /* Magnitude and refinement */
1250 10 jpeg2000_init_zero(&mag_sgn);
1251 10 jpeg2000_bitbuf_refill_forward(&mag_sgn, Dcup, Pcup);
1252
1253 /* Significance propagation */
1254 10 jpeg2000_init_zero(&sig_prop);
1255
1256 /* Adaptive run length */
1257 10 jpeg2000_init_mel(&mel, Pcup);
1258
1259 /* Variable Length coding */
1260 10 jpeg2000_init_vlc(&vlc, Lcup, Pcup, Dcup);
1261
1262 10 jpeg2000_init_mel_decoder(&mel_state);
1263
1264 10 sample_buf = av_calloc((width + 4) * (height + 4), sizeof(int32_t));
1265 10 block_states = av_calloc((width + 4) * (height + 4), sizeof(uint8_t));
1266
1267
2/4
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 10 times.
10 if (!sample_buf || !block_states) {
1268 ret = AVERROR(ENOMEM);
1269 goto free;
1270 }
1271
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 10 times.
10 if ((ret = jpeg2000_decode_ht_cleanup_segment(s, cblk, t1, &mel_state, &mel, &vlc,
1272 &mag_sgn, Dcup, Lcup, Pcup, pLSB, width,
1273 height, sample_buf, block_states)) < 0) {
1274 av_log(s->avctx, AV_LOG_ERROR, "Bad HT cleanup segment\n");
1275 goto free;
1276 }
1277
1278
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (cblk->npasses > 1)
1279 jpeg2000_decode_sigprop_segment(cblk, width, height, Dref, Lref,
1280 pLSB - 1, sample_buf, block_states);
1281
1282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (cblk->npasses > 2) {
1283
1284 if (Lref < 2){
1285 av_log(s->avctx,AV_LOG_ERROR,"Invalid magnitude refinement length\n");
1286 ret = AVERROR_INVALIDDATA;
1287 goto free;
1288 }
1289 if ((ret = jpeg2000_decode_magref_segment(width, height, Dref, Lref,
1290 pLSB - 1, sample_buf, block_states)) < 0)
1291 goto free;
1292 }
1293
1294 10 pLSB = 31 - M_b;
1295
1296 /* Reconstruct the sample values */
1297
2/2
✓ Branch 0 taken 352 times.
✓ Branch 1 taken 10 times.
362 for (int y = 0; y < height; y++) {
1298
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 352 times.
16736 for (int x = 0; x < width; x++) {
1299 16384 n = x + (y * t1->stride);
1300 16384 val = sample_buf[x + (y * width)];
1301 /* Convert sign-magnitude to two's complement. */
1302
2/2
✓ Branch 0 taken 4032 times.
✓ Branch 1 taken 12352 times.
16384 val = val >> 31 ? 0x80000000 - val : val;
1303 16384 val >>= (pLSB - 1);
1304 16384 t1->data[n] = val;
1305 }
1306 }
1307 10 free:
1308 10 av_freep(&sample_buf);
1309 10 av_freep(&block_states);
1310 10 return ret;
1311 }
1312
1313 /**
1314 * CtxVLC tables (see Rec. ITU-T T.800, Annex C) as found at
1315 * https://github.com/osamu620/OpenHTJ2K (author: Osamu Watanabe)
1316 */
1317 static const uint16_t dec_cxt_vlc_table1[1024] = {
1318 0x0016, 0x006A, 0x0046, 0x00DD, 0x0086, 0x888B, 0x0026, 0x444D, 0x0016, 0x00AA, 0x0046, 0x88AD, 0x0086,
1319 0x003A, 0x0026, 0x00DE, 0x0016, 0x00CA, 0x0046, 0x009D, 0x0086, 0x005A, 0x0026, 0x222D, 0x0016, 0x009A,
1320 0x0046, 0x007D, 0x0086, 0x01FD, 0x0026, 0x007E, 0x0016, 0x006A, 0x0046, 0x88CD, 0x0086, 0x888B, 0x0026,
1321 0x111D, 0x0016, 0x00AA, 0x0046, 0x005D, 0x0086, 0x003A, 0x0026, 0x00EE, 0x0016, 0x00CA, 0x0046, 0x00BD,
1322 0x0086, 0x005A, 0x0026, 0x11FF, 0x0016, 0x009A, 0x0046, 0x003D, 0x0086, 0x04ED, 0x0026, 0x2AAF, 0x0016,
1323 0x006A, 0x0046, 0x00DD, 0x0086, 0x888B, 0x0026, 0x444D, 0x0016, 0x00AA, 0x0046, 0x88AD, 0x0086, 0x003A,
1324 0x0026, 0x44EF, 0x0016, 0x00CA, 0x0046, 0x009D, 0x0086, 0x005A, 0x0026, 0x222D, 0x0016, 0x009A, 0x0046,
1325 0x007D, 0x0086, 0x01FD, 0x0026, 0x00BE, 0x0016, 0x006A, 0x0046, 0x88CD, 0x0086, 0x888B, 0x0026, 0x111D,
1326 0x0016, 0x00AA, 0x0046, 0x005D, 0x0086, 0x003A, 0x0026, 0x4CCF, 0x0016, 0x00CA, 0x0046, 0x00BD, 0x0086,
1327 0x005A, 0x0026, 0x00FE, 0x0016, 0x009A, 0x0046, 0x003D, 0x0086, 0x04ED, 0x0026, 0x006F, 0x0002, 0x0088,
1328 0x0002, 0x005C, 0x0002, 0x0018, 0x0002, 0x00DE, 0x0002, 0x0028, 0x0002, 0x009C, 0x0002, 0x004A, 0x0002,
1329 0x007E, 0x0002, 0x0088, 0x0002, 0x00CC, 0x0002, 0x0018, 0x0002, 0x888F, 0x0002, 0x0028, 0x0002, 0x00FE,
1330 0x0002, 0x003A, 0x0002, 0x222F, 0x0002, 0x0088, 0x0002, 0x04FD, 0x0002, 0x0018, 0x0002, 0x00BE, 0x0002,
1331 0x0028, 0x0002, 0x00BF, 0x0002, 0x004A, 0x0002, 0x006E, 0x0002, 0x0088, 0x0002, 0x00AC, 0x0002, 0x0018,
1332 0x0002, 0x444F, 0x0002, 0x0028, 0x0002, 0x00EE, 0x0002, 0x003A, 0x0002, 0x113F, 0x0002, 0x0088, 0x0002,
1333 0x005C, 0x0002, 0x0018, 0x0002, 0x00CF, 0x0002, 0x0028, 0x0002, 0x009C, 0x0002, 0x004A, 0x0002, 0x006F,
1334 0x0002, 0x0088, 0x0002, 0x00CC, 0x0002, 0x0018, 0x0002, 0x009F, 0x0002, 0x0028, 0x0002, 0x00EF, 0x0002,
1335 0x003A, 0x0002, 0x233F, 0x0002, 0x0088, 0x0002, 0x04FD, 0x0002, 0x0018, 0x0002, 0x00AF, 0x0002, 0x0028,
1336 0x0002, 0x44FF, 0x0002, 0x004A, 0x0002, 0x005F, 0x0002, 0x0088, 0x0002, 0x00AC, 0x0002, 0x0018, 0x0002,
1337 0x007F, 0x0002, 0x0028, 0x0002, 0x00DF, 0x0002, 0x003A, 0x0002, 0x111F, 0x0002, 0x0028, 0x0002, 0x005C,
1338 0x0002, 0x008A, 0x0002, 0x00BF, 0x0002, 0x0018, 0x0002, 0x00FE, 0x0002, 0x00CC, 0x0002, 0x007E, 0x0002,
1339 0x0028, 0x0002, 0x8FFF, 0x0002, 0x004A, 0x0002, 0x007F, 0x0002, 0x0018, 0x0002, 0x00DF, 0x0002, 0x00AC,
1340 0x0002, 0x133F, 0x0002, 0x0028, 0x0002, 0x222D, 0x0002, 0x008A, 0x0002, 0x00BE, 0x0002, 0x0018, 0x0002,
1341 0x44EF, 0x0002, 0x2AAD, 0x0002, 0x006E, 0x0002, 0x0028, 0x0002, 0x15FF, 0x0002, 0x004A, 0x0002, 0x009E,
1342 0x0002, 0x0018, 0x0002, 0x00CF, 0x0002, 0x003C, 0x0002, 0x223F, 0x0002, 0x0028, 0x0002, 0x005C, 0x0002,
1343 0x008A, 0x0002, 0x2BBF, 0x0002, 0x0018, 0x0002, 0x04EF, 0x0002, 0x00CC, 0x0002, 0x006F, 0x0002, 0x0028,
1344 0x0002, 0x27FF, 0x0002, 0x004A, 0x0002, 0x009F, 0x0002, 0x0018, 0x0002, 0x00DE, 0x0002, 0x00AC, 0x0002,
1345 0x444F, 0x0002, 0x0028, 0x0002, 0x222D, 0x0002, 0x008A, 0x0002, 0x8AAF, 0x0002, 0x0018, 0x0002, 0x00EE,
1346 0x0002, 0x2AAD, 0x0002, 0x005F, 0x0002, 0x0028, 0x0002, 0x44FF, 0x0002, 0x004A, 0x0002, 0x888F, 0x0002,
1347 0x0018, 0x0002, 0xAAAF, 0x0002, 0x003C, 0x0002, 0x111F, 0x0004, 0x8FFD, 0x0028, 0x005C, 0x0004, 0x00BC,
1348 0x008A, 0x66FF, 0x0004, 0x00CD, 0x0018, 0x111D, 0x0004, 0x009C, 0x003A, 0x8AAF, 0x0004, 0x00FC, 0x0028,
1349 0x133D, 0x0004, 0x00AC, 0x004A, 0x3BBF, 0x0004, 0x2BBD, 0x0018, 0x5FFF, 0x0004, 0x006C, 0x157D, 0x455F,
1350 0x0004, 0x2FFD, 0x0028, 0x222D, 0x0004, 0x22AD, 0x008A, 0x44EF, 0x0004, 0x00CC, 0x0018, 0x4FFF, 0x0004,
1351 0x007C, 0x003A, 0x447F, 0x0004, 0x04DD, 0x0028, 0x233D, 0x0004, 0x009D, 0x004A, 0x00DE, 0x0004, 0x88BD,
1352 0x0018, 0xAFFF, 0x0004, 0x115D, 0x1FFD, 0x444F, 0x0004, 0x8FFD, 0x0028, 0x005C, 0x0004, 0x00BC, 0x008A,
1353 0x8CEF, 0x0004, 0x00CD, 0x0018, 0x111D, 0x0004, 0x009C, 0x003A, 0x888F, 0x0004, 0x00FC, 0x0028, 0x133D,
1354 0x0004, 0x00AC, 0x004A, 0x44DF, 0x0004, 0x2BBD, 0x0018, 0x8AFF, 0x0004, 0x006C, 0x157D, 0x006F, 0x0004,
1355 0x2FFD, 0x0028, 0x222D, 0x0004, 0x22AD, 0x008A, 0x00EE, 0x0004, 0x00CC, 0x0018, 0x2EEF, 0x0004, 0x007C,
1356 0x003A, 0x277F, 0x0004, 0x04DD, 0x0028, 0x233D, 0x0004, 0x009D, 0x004A, 0x1BBF, 0x0004, 0x88BD, 0x0018,
1357 0x37FF, 0x0004, 0x115D, 0x1FFD, 0x333F, 0x0002, 0x0088, 0x0002, 0x02ED, 0x0002, 0x00CA, 0x0002, 0x4CCF,
1358 0x0002, 0x0048, 0x0002, 0x23FF, 0x0002, 0x001A, 0x0002, 0x888F, 0x0002, 0x0088, 0x0002, 0x006C, 0x0002,
1359 0x002A, 0x0002, 0x00AF, 0x0002, 0x0048, 0x0002, 0x22EF, 0x0002, 0x00AC, 0x0002, 0x005F, 0x0002, 0x0088,
1360 0x0002, 0x444D, 0x0002, 0x00CA, 0x0002, 0xCCCF, 0x0002, 0x0048, 0x0002, 0x00FE, 0x0002, 0x001A, 0x0002,
1361 0x006F, 0x0002, 0x0088, 0x0002, 0x005C, 0x0002, 0x002A, 0x0002, 0x009F, 0x0002, 0x0048, 0x0002, 0x00DF,
1362 0x0002, 0x03FD, 0x0002, 0x222F, 0x0002, 0x0088, 0x0002, 0x02ED, 0x0002, 0x00CA, 0x0002, 0x8CCF, 0x0002,
1363 0x0048, 0x0002, 0x11FF, 0x0002, 0x001A, 0x0002, 0x007E, 0x0002, 0x0088, 0x0002, 0x006C, 0x0002, 0x002A,
1364 0x0002, 0x007F, 0x0002, 0x0048, 0x0002, 0x00EE, 0x0002, 0x00AC, 0x0002, 0x003E, 0x0002, 0x0088, 0x0002,
1365 0x444D, 0x0002, 0x00CA, 0x0002, 0x00BE, 0x0002, 0x0048, 0x0002, 0x00BF, 0x0002, 0x001A, 0x0002, 0x003F,
1366 0x0002, 0x0088, 0x0002, 0x005C, 0x0002, 0x002A, 0x0002, 0x009E, 0x0002, 0x0048, 0x0002, 0x00DE, 0x0002,
1367 0x03FD, 0x0002, 0x111F, 0x0004, 0x8AED, 0x0048, 0x888D, 0x0004, 0x00DC, 0x00CA, 0x3FFF, 0x0004, 0xCFFD,
1368 0x002A, 0x003D, 0x0004, 0x00BC, 0x005A, 0x8DDF, 0x0004, 0x8FFD, 0x0048, 0x006C, 0x0004, 0x027D, 0x008A,
1369 0x99FF, 0x0004, 0x00EC, 0x00FA, 0x003C, 0x0004, 0x00AC, 0x001A, 0x009F, 0x0004, 0x2FFD, 0x0048, 0x007C,
1370 0x0004, 0x44CD, 0x00CA, 0x67FF, 0x0004, 0x1FFD, 0x002A, 0x444D, 0x0004, 0x00AD, 0x005A, 0x8CCF, 0x0004,
1371 0x4FFD, 0x0048, 0x445D, 0x0004, 0x01BD, 0x008A, 0x4EEF, 0x0004, 0x45DD, 0x00FA, 0x111D, 0x0004, 0x009C,
1372 0x001A, 0x222F, 0x0004, 0x8AED, 0x0048, 0x888D, 0x0004, 0x00DC, 0x00CA, 0xAFFF, 0x0004, 0xCFFD, 0x002A,
1373 0x003D, 0x0004, 0x00BC, 0x005A, 0x11BF, 0x0004, 0x8FFD, 0x0048, 0x006C, 0x0004, 0x027D, 0x008A, 0x22EF,
1374 0x0004, 0x00EC, 0x00FA, 0x003C, 0x0004, 0x00AC, 0x001A, 0x227F, 0x0004, 0x2FFD, 0x0048, 0x007C, 0x0004,
1375 0x44CD, 0x00CA, 0x5DFF, 0x0004, 0x1FFD, 0x002A, 0x444D, 0x0004, 0x00AD, 0x005A, 0x006F, 0x0004, 0x4FFD,
1376 0x0048, 0x445D, 0x0004, 0x01BD, 0x008A, 0x11DF, 0x0004, 0x45DD, 0x00FA, 0x111D, 0x0004, 0x009C, 0x001A,
1377 0x155F, 0x0006, 0x00FC, 0x0018, 0x111D, 0x0048, 0x888D, 0x00AA, 0x4DDF, 0x0006, 0x2AAD, 0x005A, 0x67FF,
1378 0x0028, 0x223D, 0x00BC, 0xAAAF, 0x0006, 0x00EC, 0x0018, 0x5FFF, 0x0048, 0x006C, 0x008A, 0xCCCF, 0x0006,
1379 0x009D, 0x00CA, 0x44EF, 0x0028, 0x003C, 0x8FFD, 0x137F, 0x0006, 0x8EED, 0x0018, 0x1FFF, 0x0048, 0x007C,
1380 0x00AA, 0x4CCF, 0x0006, 0x227D, 0x005A, 0x1DDF, 0x0028, 0x444D, 0x4FFD, 0x155F, 0x0006, 0x00DC, 0x0018,
1381 0x2EEF, 0x0048, 0x445D, 0x008A, 0x22BF, 0x0006, 0x009C, 0x00CA, 0x8CDF, 0x0028, 0x222D, 0x2FFD, 0x226F,
1382 0x0006, 0x00FC, 0x0018, 0x111D, 0x0048, 0x888D, 0x00AA, 0x1BBF, 0x0006, 0x2AAD, 0x005A, 0x33FF, 0x0028,
1383 0x223D, 0x00BC, 0x8AAF, 0x0006, 0x00EC, 0x0018, 0x9BFF, 0x0048, 0x006C, 0x008A, 0x8ABF, 0x0006, 0x009D,
1384 0x00CA, 0x4EEF, 0x0028, 0x003C, 0x8FFD, 0x466F, 0x0006, 0x8EED, 0x0018, 0xCFFF, 0x0048, 0x007C, 0x00AA,
1385 0x8CCF, 0x0006, 0x227D, 0x005A, 0xAEEF, 0x0028, 0x444D, 0x4FFD, 0x477F, 0x0006, 0x00DC, 0x0018, 0xAFFF,
1386 0x0048, 0x445D, 0x008A, 0x2BBF, 0x0006, 0x009C, 0x00CA, 0x44DF, 0x0028, 0x222D, 0x2FFD, 0x133F, 0x00F6,
1387 0xAFFD, 0x1FFB, 0x003C, 0x0008, 0x23BD, 0x007A, 0x11DF, 0x00F6, 0x45DD, 0x2FFB, 0x4EEF, 0x00DA, 0x177D,
1388 0xCFFD, 0x377F, 0x00F6, 0x3FFD, 0x8FFB, 0x111D, 0x0008, 0x009C, 0x005A, 0x1BBF, 0x00F6, 0x00CD, 0x00BA,
1389 0x8DDF, 0x4FFB, 0x006C, 0x9BFD, 0x455F, 0x00F6, 0x67FD, 0x1FFB, 0x002C, 0x0008, 0x00AC, 0x007A, 0x009F,
1390 0x00F6, 0x00AD, 0x2FFB, 0x7FFF, 0x00DA, 0x004C, 0x5FFD, 0x477F, 0x00F6, 0x00EC, 0x8FFB, 0x001C, 0x0008,
1391 0x008C, 0x005A, 0x888F, 0x00F6, 0x00CC, 0x00BA, 0x2EEF, 0x4FFB, 0x115D, 0x8AED, 0x113F, 0x00F6, 0xAFFD,
1392 0x1FFB, 0x003C, 0x0008, 0x23BD, 0x007A, 0x1DDF, 0x00F6, 0x45DD, 0x2FFB, 0xBFFF, 0x00DA, 0x177D, 0xCFFD,
1393 0x447F, 0x00F6, 0x3FFD, 0x8FFB, 0x111D, 0x0008, 0x009C, 0x005A, 0x277F, 0x00F6, 0x00CD, 0x00BA, 0x22EF,
1394 0x4FFB, 0x006C, 0x9BFD, 0x444F, 0x00F6, 0x67FD, 0x1FFB, 0x002C, 0x0008, 0x00AC, 0x007A, 0x11BF, 0x00F6,
1395 0x00AD, 0x2FFB, 0xFFFF, 0x00DA, 0x004C, 0x5FFD, 0x233F, 0x00F6, 0x00EC, 0x8FFB, 0x001C, 0x0008, 0x008C,
1396 0x005A, 0x006F, 0x00F6, 0x00CC, 0x00BA, 0x8BBF, 0x4FFB, 0x115D, 0x8AED, 0x222F};
1397
1398 static const uint16_t dec_cxt_vlc_table0[1024] = {
1399 0x0026, 0x00AA, 0x0046, 0x006C, 0x0086, 0x8AED, 0x0018, 0x8DDF, 0x0026, 0x01BD, 0x0046, 0x5FFF, 0x0086,
1400 0x027D, 0x005A, 0x155F, 0x0026, 0x003A, 0x0046, 0x444D, 0x0086, 0x4CCD, 0x0018, 0xCCCF, 0x0026, 0x2EFD,
1401 0x0046, 0x99FF, 0x0086, 0x009C, 0x00CA, 0x133F, 0x0026, 0x00AA, 0x0046, 0x445D, 0x0086, 0x8CCD, 0x0018,
1402 0x11DF, 0x0026, 0x4FFD, 0x0046, 0xCFFF, 0x0086, 0x009D, 0x005A, 0x007E, 0x0026, 0x003A, 0x0046, 0x1FFF,
1403 0x0086, 0x88AD, 0x0018, 0x00BE, 0x0026, 0x8FFD, 0x0046, 0x4EEF, 0x0086, 0x888D, 0x00CA, 0x111F, 0x0026,
1404 0x00AA, 0x0046, 0x006C, 0x0086, 0x8AED, 0x0018, 0x45DF, 0x0026, 0x01BD, 0x0046, 0x22EF, 0x0086, 0x027D,
1405 0x005A, 0x227F, 0x0026, 0x003A, 0x0046, 0x444D, 0x0086, 0x4CCD, 0x0018, 0x11BF, 0x0026, 0x2EFD, 0x0046,
1406 0x00FE, 0x0086, 0x009C, 0x00CA, 0x223F, 0x0026, 0x00AA, 0x0046, 0x445D, 0x0086, 0x8CCD, 0x0018, 0x00DE,
1407 0x0026, 0x4FFD, 0x0046, 0xABFF, 0x0086, 0x009D, 0x005A, 0x006F, 0x0026, 0x003A, 0x0046, 0x6EFF, 0x0086,
1408 0x88AD, 0x0018, 0x2AAF, 0x0026, 0x8FFD, 0x0046, 0x00EE, 0x0086, 0x888D, 0x00CA, 0x222F, 0x0004, 0x00CA,
1409 0x0088, 0x027D, 0x0004, 0x4CCD, 0x0028, 0x00FE, 0x0004, 0x2AFD, 0x0048, 0x005C, 0x0004, 0x009D, 0x0018,
1410 0x00DE, 0x0004, 0x01BD, 0x0088, 0x006C, 0x0004, 0x88AD, 0x0028, 0x11DF, 0x0004, 0x8AED, 0x0048, 0x003C,
1411 0x0004, 0x888D, 0x0018, 0x111F, 0x0004, 0x00CA, 0x0088, 0x006D, 0x0004, 0x88CD, 0x0028, 0x88FF, 0x0004,
1412 0x8BFD, 0x0048, 0x444D, 0x0004, 0x009C, 0x0018, 0x00BE, 0x0004, 0x4EFD, 0x0088, 0x445D, 0x0004, 0x00AC,
1413 0x0028, 0x00EE, 0x0004, 0x45DD, 0x0048, 0x222D, 0x0004, 0x003D, 0x0018, 0x007E, 0x0004, 0x00CA, 0x0088,
1414 0x027D, 0x0004, 0x4CCD, 0x0028, 0x1FFF, 0x0004, 0x2AFD, 0x0048, 0x005C, 0x0004, 0x009D, 0x0018, 0x11BF,
1415 0x0004, 0x01BD, 0x0088, 0x006C, 0x0004, 0x88AD, 0x0028, 0x22EF, 0x0004, 0x8AED, 0x0048, 0x003C, 0x0004,
1416 0x888D, 0x0018, 0x227F, 0x0004, 0x00CA, 0x0088, 0x006D, 0x0004, 0x88CD, 0x0028, 0x4EEF, 0x0004, 0x8BFD,
1417 0x0048, 0x444D, 0x0004, 0x009C, 0x0018, 0x2AAF, 0x0004, 0x4EFD, 0x0088, 0x445D, 0x0004, 0x00AC, 0x0028,
1418 0x8DDF, 0x0004, 0x45DD, 0x0048, 0x222D, 0x0004, 0x003D, 0x0018, 0x155F, 0x0004, 0x005A, 0x0088, 0x006C,
1419 0x0004, 0x88DD, 0x0028, 0x23FF, 0x0004, 0x11FD, 0x0048, 0x444D, 0x0004, 0x00AD, 0x0018, 0x00BE, 0x0004,
1420 0x137D, 0x0088, 0x155D, 0x0004, 0x00CC, 0x0028, 0x00DE, 0x0004, 0x02ED, 0x0048, 0x111D, 0x0004, 0x009D,
1421 0x0018, 0x007E, 0x0004, 0x005A, 0x0088, 0x455D, 0x0004, 0x44CD, 0x0028, 0x00EE, 0x0004, 0x1FFD, 0x0048,
1422 0x003C, 0x0004, 0x00AC, 0x0018, 0x555F, 0x0004, 0x47FD, 0x0088, 0x113D, 0x0004, 0x02BD, 0x0028, 0x477F,
1423 0x0004, 0x4CDD, 0x0048, 0x8FFF, 0x0004, 0x009C, 0x0018, 0x222F, 0x0004, 0x005A, 0x0088, 0x006C, 0x0004,
1424 0x88DD, 0x0028, 0x00FE, 0x0004, 0x11FD, 0x0048, 0x444D, 0x0004, 0x00AD, 0x0018, 0x888F, 0x0004, 0x137D,
1425 0x0088, 0x155D, 0x0004, 0x00CC, 0x0028, 0x8CCF, 0x0004, 0x02ED, 0x0048, 0x111D, 0x0004, 0x009D, 0x0018,
1426 0x006F, 0x0004, 0x005A, 0x0088, 0x455D, 0x0004, 0x44CD, 0x0028, 0x1DDF, 0x0004, 0x1FFD, 0x0048, 0x003C,
1427 0x0004, 0x00AC, 0x0018, 0x227F, 0x0004, 0x47FD, 0x0088, 0x113D, 0x0004, 0x02BD, 0x0028, 0x22BF, 0x0004,
1428 0x4CDD, 0x0048, 0x22EF, 0x0004, 0x009C, 0x0018, 0x233F, 0x0006, 0x4DDD, 0x4FFB, 0xCFFF, 0x0018, 0x113D,
1429 0x005A, 0x888F, 0x0006, 0x23BD, 0x008A, 0x00EE, 0x002A, 0x155D, 0xAAFD, 0x277F, 0x0006, 0x44CD, 0x8FFB,
1430 0x44EF, 0x0018, 0x467D, 0x004A, 0x2AAF, 0x0006, 0x00AC, 0x555B, 0x99DF, 0x1FFB, 0x003C, 0x5FFD, 0x266F,
1431 0x0006, 0x1DDD, 0x4FFB, 0x6EFF, 0x0018, 0x177D, 0x005A, 0x1BBF, 0x0006, 0x88AD, 0x008A, 0x5DDF, 0x002A,
1432 0x444D, 0x2FFD, 0x667F, 0x0006, 0x00CC, 0x8FFB, 0x2EEF, 0x0018, 0x455D, 0x004A, 0x119F, 0x0006, 0x009C,
1433 0x555B, 0x8CCF, 0x1FFB, 0x111D, 0x8CED, 0x006E, 0x0006, 0x4DDD, 0x4FFB, 0x3FFF, 0x0018, 0x113D, 0x005A,
1434 0x11BF, 0x0006, 0x23BD, 0x008A, 0x8DDF, 0x002A, 0x155D, 0xAAFD, 0x222F, 0x0006, 0x44CD, 0x8FFB, 0x00FE,
1435 0x0018, 0x467D, 0x004A, 0x899F, 0x0006, 0x00AC, 0x555B, 0x00DE, 0x1FFB, 0x003C, 0x5FFD, 0x446F, 0x0006,
1436 0x1DDD, 0x4FFB, 0x9BFF, 0x0018, 0x177D, 0x005A, 0x00BE, 0x0006, 0x88AD, 0x008A, 0xCDDF, 0x002A, 0x444D,
1437 0x2FFD, 0x007E, 0x0006, 0x00CC, 0x8FFB, 0x4EEF, 0x0018, 0x455D, 0x004A, 0x377F, 0x0006, 0x009C, 0x555B,
1438 0x8BBF, 0x1FFB, 0x111D, 0x8CED, 0x233F, 0x0004, 0x00AA, 0x0088, 0x047D, 0x0004, 0x01DD, 0x0028, 0x11DF,
1439 0x0004, 0x27FD, 0x0048, 0x005C, 0x0004, 0x8AAD, 0x0018, 0x2BBF, 0x0004, 0x009C, 0x0088, 0x006C, 0x0004,
1440 0x00CC, 0x0028, 0x00EE, 0x0004, 0x8CED, 0x0048, 0x222D, 0x0004, 0x888D, 0x0018, 0x007E, 0x0004, 0x00AA,
1441 0x0088, 0x006D, 0x0004, 0x88CD, 0x0028, 0x00FE, 0x0004, 0x19FD, 0x0048, 0x003C, 0x0004, 0x2AAD, 0x0018,
1442 0xAAAF, 0x0004, 0x8BFD, 0x0088, 0x005D, 0x0004, 0x00BD, 0x0028, 0x4CCF, 0x0004, 0x44ED, 0x0048, 0x4FFF,
1443 0x0004, 0x223D, 0x0018, 0x111F, 0x0004, 0x00AA, 0x0088, 0x047D, 0x0004, 0x01DD, 0x0028, 0x99FF, 0x0004,
1444 0x27FD, 0x0048, 0x005C, 0x0004, 0x8AAD, 0x0018, 0x00BE, 0x0004, 0x009C, 0x0088, 0x006C, 0x0004, 0x00CC,
1445 0x0028, 0x00DE, 0x0004, 0x8CED, 0x0048, 0x222D, 0x0004, 0x888D, 0x0018, 0x444F, 0x0004, 0x00AA, 0x0088,
1446 0x006D, 0x0004, 0x88CD, 0x0028, 0x2EEF, 0x0004, 0x19FD, 0x0048, 0x003C, 0x0004, 0x2AAD, 0x0018, 0x447F,
1447 0x0004, 0x8BFD, 0x0088, 0x005D, 0x0004, 0x00BD, 0x0028, 0x009F, 0x0004, 0x44ED, 0x0048, 0x67FF, 0x0004,
1448 0x223D, 0x0018, 0x133F, 0x0006, 0x00CC, 0x008A, 0x9DFF, 0x2FFB, 0x467D, 0x1FFD, 0x99BF, 0x0006, 0x2AAD,
1449 0x002A, 0x66EF, 0x4FFB, 0x005C, 0x2EED, 0x377F, 0x0006, 0x89BD, 0x004A, 0x00FE, 0x8FFB, 0x006C, 0x67FD,
1450 0x889F, 0x0006, 0x888D, 0x001A, 0x5DDF, 0x00AA, 0x222D, 0x89DD, 0x444F, 0x0006, 0x2BBD, 0x008A, 0xCFFF,
1451 0x2FFB, 0x226D, 0x009C, 0x00BE, 0x0006, 0xAAAD, 0x002A, 0x1DDF, 0x4FFB, 0x003C, 0x4DDD, 0x466F, 0x0006,
1452 0x8AAD, 0x004A, 0xAEEF, 0x8FFB, 0x445D, 0x8EED, 0x177F, 0x0006, 0x233D, 0x001A, 0x4CCF, 0x00AA, 0xAFFF,
1453 0x88CD, 0x133F, 0x0006, 0x00CC, 0x008A, 0x77FF, 0x2FFB, 0x467D, 0x1FFD, 0x3BBF, 0x0006, 0x2AAD, 0x002A,
1454 0x00EE, 0x4FFB, 0x005C, 0x2EED, 0x007E, 0x0006, 0x89BD, 0x004A, 0x4EEF, 0x8FFB, 0x006C, 0x67FD, 0x667F,
1455 0x0006, 0x888D, 0x001A, 0x00DE, 0x00AA, 0x222D, 0x89DD, 0x333F, 0x0006, 0x2BBD, 0x008A, 0x57FF, 0x2FFB,
1456 0x226D, 0x009C, 0x199F, 0x0006, 0xAAAD, 0x002A, 0x99DF, 0x4FFB, 0x003C, 0x4DDD, 0x155F, 0x0006, 0x8AAD,
1457 0x004A, 0xCEEF, 0x8FFB, 0x445D, 0x8EED, 0x277F, 0x0006, 0x233D, 0x001A, 0x1BBF, 0x00AA, 0x3FFF, 0x88CD,
1458 0x111F, 0x0006, 0x45DD, 0x2FFB, 0x111D, 0x0018, 0x467D, 0x8FFD, 0xCCCF, 0x0006, 0x19BD, 0x004A, 0x22EF,
1459 0x002A, 0x222D, 0x3FFD, 0x888F, 0x0006, 0x00CC, 0x008A, 0x00FE, 0x0018, 0x115D, 0xCFFD, 0x8AAF, 0x0006,
1460 0x00AC, 0x003A, 0x8CDF, 0x1FFB, 0x133D, 0x66FD, 0x466F, 0x0006, 0x8CCD, 0x2FFB, 0x5FFF, 0x0018, 0x006C,
1461 0x4FFD, 0xABBF, 0x0006, 0x22AD, 0x004A, 0x00EE, 0x002A, 0x233D, 0xAEFD, 0x377F, 0x0006, 0x2BBD, 0x008A,
1462 0x55DF, 0x0018, 0x005C, 0x177D, 0x119F, 0x0006, 0x009C, 0x003A, 0x4CCF, 0x1FFB, 0x333D, 0x8EED, 0x444F,
1463 0x0006, 0x45DD, 0x2FFB, 0x111D, 0x0018, 0x467D, 0x8FFD, 0x99BF, 0x0006, 0x19BD, 0x004A, 0x2EEF, 0x002A,
1464 0x222D, 0x3FFD, 0x667F, 0x0006, 0x00CC, 0x008A, 0x4EEF, 0x0018, 0x115D, 0xCFFD, 0x899F, 0x0006, 0x00AC,
1465 0x003A, 0x00DE, 0x1FFB, 0x133D, 0x66FD, 0x226F, 0x0006, 0x8CCD, 0x2FFB, 0x9BFF, 0x0018, 0x006C, 0x4FFD,
1466 0x00BE, 0x0006, 0x22AD, 0x004A, 0x1DDF, 0x002A, 0x233D, 0xAEFD, 0x007E, 0x0006, 0x2BBD, 0x008A, 0xCEEF,
1467 0x0018, 0x005C, 0x177D, 0x277F, 0x0006, 0x009C, 0x003A, 0x8BBF, 0x1FFB, 0x333D, 0x8EED, 0x455F, 0x1FF9,
1468 0x1DDD, 0xAFFB, 0x00DE, 0x8FF9, 0x001C, 0xFFFB, 0x477F, 0x4FF9, 0x177D, 0x3FFB, 0x3BBF, 0x2FF9, 0xAEEF,
1469 0x8EED, 0x444F, 0x1FF9, 0x22AD, 0x000A, 0x8BBF, 0x8FF9, 0x00FE, 0xCFFD, 0x007E, 0x4FF9, 0x115D, 0x5FFB,
1470 0x577F, 0x2FF9, 0x8DDF, 0x2EED, 0x333F, 0x1FF9, 0x2BBD, 0xAFFB, 0x88CF, 0x8FF9, 0xBFFF, 0xFFFB, 0x377F,
1471 0x4FF9, 0x006D, 0x3FFB, 0x00BE, 0x2FF9, 0x66EF, 0x9FFD, 0x133F, 0x1FF9, 0x009D, 0x000A, 0xABBF, 0x8FF9,
1472 0xDFFF, 0x6FFD, 0x006E, 0x4FF9, 0x002C, 0x5FFB, 0x888F, 0x2FF9, 0xCDDF, 0x4DDD, 0x222F, 0x1FF9, 0x1DDD,
1473 0xAFFB, 0x4CCF, 0x8FF9, 0x001C, 0xFFFB, 0x277F, 0x4FF9, 0x177D, 0x3FFB, 0x99BF, 0x2FF9, 0xCEEF, 0x8EED,
1474 0x004E, 0x1FF9, 0x22AD, 0x000A, 0x00AE, 0x8FF9, 0x7FFF, 0xCFFD, 0x005E, 0x4FF9, 0x115D, 0x5FFB, 0x009E,
1475 0x2FF9, 0x5DDF, 0x2EED, 0x003E, 0x1FF9, 0x2BBD, 0xAFFB, 0x00CE, 0x8FF9, 0xEFFF, 0xFFFB, 0x667F, 0x4FF9,
1476 0x006D, 0x3FFB, 0x8AAF, 0x2FF9, 0x00EE, 0x9FFD, 0x233F, 0x1FF9, 0x009D, 0x000A, 0x1BBF, 0x8FF9, 0x4EEF,
1477 0x6FFD, 0x455F, 0x4FF9, 0x002C, 0x5FFB, 0x008E, 0x2FF9, 0x99DF, 0x4DDD, 0x111F};
1478