FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/jpeg2000htdec.c
Date: 2023-06-04 16:45:34
Exec Total Coverage
Lines: 413 607 68.0%
Functions: 24 32 75.0%
Branches: 159 274 58.0%

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