Files
wowdecomp/Engine/Source/Images/ImageWriter.cpp
T
SatyandClaude Opus 5.5 55d90d30ce Port ImageWriter; decompile Blizzard's libjpeg 6b
- libjpeg moved from ThirdParty/jpeg to Engine/Source/jpeg: stock 6b
  compression side plus Blizzard's changes (int boolean, error_flag
  instead of exit, source_pixels in jpeg_compress_struct, unscaled
  jpeg_add_quant_table, hook-pointer memory backend), all 140 functions
  OFFSET-tagged and verified
- jmemsrc.c: Blizzard's in-memory BGR(A) source (jinit_read_mem)
- ImageWriter: LDPC encoder, rect layout, block embedding, JPEG writer
  and the four API functions, verified against 12340
- THIRD_PARTY.md: libjpeg marked done

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-03 22:54:39 +02:00

1702 lines
71 KiB
C++

#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "Engine/Source/Images/ImageWriter.h"
#include "Engine/Source/jpeg/jpeglib.h"
#include "Engine/Source/jpeg/jmemnobs.h"
#include "Engine/Source/jpeg/jmemsrc.h"
// STATIC: 0x009EE118
static const int32_t s_luminanceTables[11][64] = {
{
20, 16, 25, 39, 50, 46, 62, 68,
16, 18, 23, 38, 38, 53, 65, 68,
25, 23, 31, 38, 53, 65, 68, 68,
39, 38, 38, 53, 65, 68, 68, 68,
50, 38, 53, 65, 68, 68, 68, 68,
46, 53, 65, 68, 68, 68, 68, 68,
62, 65, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68,
},
{
18, 14, 14, 21, 30, 35, 34, 39,
14, 16, 16, 19, 26, 24, 30, 39,
14, 16, 17, 21, 24, 34, 46, 62,
21, 19, 21, 26, 33, 48, 62, 65,
30, 26, 24, 33, 51, 65, 65, 65,
35, 24, 34, 48, 65, 65, 65, 65,
34, 30, 46, 62, 65, 65, 65, 65,
39, 39, 62, 65, 65, 65, 65, 65,
},
{
16, 11, 11, 16, 23, 27, 31, 30,
11, 12, 12, 15, 20, 23, 23, 30,
11, 12, 13, 16, 23, 26, 35, 47,
16, 15, 16, 23, 26, 37, 47, 64,
23, 20, 23, 26, 39, 51, 64, 64,
27, 23, 26, 37, 51, 64, 64, 64,
31, 23, 35, 47, 64, 64, 64, 64,
30, 30, 47, 64, 64, 64, 64, 64,
},
{
12, 8, 8, 12, 17, 21, 24, 23,
8, 9, 9, 11, 15, 19, 18, 23,
8, 9, 10, 12, 19, 20, 27, 36,
12, 11, 12, 21, 20, 28, 36, 53,
17, 15, 19, 20, 30, 39, 51, 59,
21, 19, 20, 28, 39, 51, 59, 59,
24, 18, 27, 36, 51, 59, 59, 59,
23, 23, 36, 53, 59, 59, 59, 59,
},
{
8, 6, 6, 8, 12, 14, 16, 17,
6, 6, 6, 8, 10, 13, 12, 15,
6, 6, 7, 8, 13, 14, 18, 24,
8, 8, 8, 14, 13, 19, 24, 35,
12, 10, 13, 13, 20, 26, 34, 39,
14, 13, 14, 19, 26, 34, 39, 39,
16, 12, 18, 24, 34, 39, 39, 39,
17, 15, 24, 35, 39, 39, 39, 39,
},
{
6, 4, 4, 6, 9, 11, 12, 16,
4, 5, 5, 6, 8, 10, 12, 12,
4, 5, 5, 6, 10, 12, 14, 19,
6, 6, 6, 11, 12, 15, 19, 28,
9, 8, 10, 12, 16, 20, 27, 31,
11, 10, 12, 15, 20, 27, 31, 31,
12, 12, 14, 19, 27, 31, 31, 31,
16, 12, 19, 28, 31, 31, 31, 31,
},
{
4, 3, 3, 4, 6, 7, 8, 10,
3, 3, 3, 4, 5, 6, 8, 10,
3, 3, 3, 4, 6, 9, 12, 12,
4, 4, 4, 7, 9, 12, 12, 17,
6, 5, 6, 9, 12, 13, 17, 20,
7, 6, 9, 12, 13, 17, 20, 20,
8, 8, 12, 12, 17, 20, 20, 20,
10, 10, 12, 17, 20, 20, 20, 20,
},
{
2, 2, 2, 2, 3, 4, 5, 6,
2, 2, 2, 2, 3, 4, 5, 6,
2, 2, 2, 2, 4, 5, 7, 9,
2, 2, 2, 4, 5, 7, 9, 12,
3, 3, 4, 5, 8, 10, 12, 12,
4, 4, 5, 7, 10, 12, 12, 12,
5, 5, 7, 9, 12, 12, 12, 12,
6, 6, 9, 12, 12, 12, 12, 12,
},
{
1, 1, 1, 1, 2, 2, 2, 3,
1, 1, 1, 1, 2, 2, 2, 3,
1, 1, 1, 1, 2, 3, 4, 5,
1, 1, 1, 2, 3, 4, 5, 7,
2, 2, 2, 3, 4, 5, 7, 8,
2, 2, 3, 4, 5, 7, 8, 8,
2, 2, 4, 5, 7, 8, 8, 8,
3, 3, 5, 7, 8, 8, 8, 8,
},
{
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
},
{
8, 5, 5, 8, 11, 13, 15, 17,
5, 6, 6, 7, 10, 12, 12, 15,
5, 6, 6, 8, 12, 13, 17, 23,
8, 7, 8, 13, 13, 18, 23, 34,
11, 10, 12, 13, 19, 25, 33, 38,
13, 12, 13, 18, 25, 33, 38, 38,
15, 12, 17, 23, 33, 38, 38, 38,
17, 15, 23, 34, 38, 38, 38, 38,
},
};
// STATIC: 0x009EEC18
static const int32_t s_chrominanceTables[11][64] = {
{
21, 25, 32, 38, 54, 68, 68, 68,
25, 28, 24, 38, 54, 68, 68, 68,
32, 24, 32, 43, 66, 68, 68, 68,
38, 38, 43, 53, 68, 68, 68, 68,
54, 54, 66, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68,
},
{
20, 19, 22, 27, 26, 33, 49, 62,
19, 25, 23, 22, 26, 33, 45, 56,
22, 23, 26, 29, 33, 39, 59, 65,
27, 22, 29, 36, 39, 51, 65, 65,
26, 26, 33, 39, 51, 62, 65, 65,
33, 33, 39, 51, 62, 65, 65, 65,
49, 45, 59, 65, 65, 65, 65, 65,
62, 56, 65, 65, 65, 65, 65, 65,
},
{
17, 15, 17, 21, 20, 26, 38, 48,
15, 19, 18, 17, 20, 26, 35, 43,
17, 18, 20, 22, 26, 30, 46, 53,
21, 17, 22, 28, 30, 39, 53, 64,
20, 20, 26, 30, 39, 48, 64, 64,
26, 26, 30, 39, 48, 63, 64, 64,
38, 35, 46, 53, 64, 64, 64, 64,
48, 43, 53, 64, 64, 64, 64, 64,
},
{
13, 11, 13, 16, 20, 20, 29, 37,
11, 14, 14, 14, 16, 20, 26, 32,
13, 14, 15, 17, 20, 23, 35, 40,
16, 14, 17, 21, 23, 30, 40, 50,
20, 16, 20, 23, 30, 37, 50, 59,
20, 20, 23, 30, 37, 48, 59, 59,
29, 26, 35, 40, 50, 59, 59, 59,
37, 32, 40, 50, 59, 59, 59, 59,
},
{
9, 8, 9, 11, 14, 17, 19, 24,
8, 10, 9, 11, 14, 13, 17, 22,
9, 9, 13, 14, 13, 15, 23, 26,
11, 11, 14, 14, 15, 20, 26, 33,
14, 14, 13, 15, 20, 24, 33, 39,
17, 13, 15, 20, 24, 32, 39, 39,
19, 17, 23, 26, 33, 39, 39, 39,
24, 22, 26, 33, 39, 39, 39, 39,
},
{
7, 7, 13, 24, 26, 31, 31, 31,
7, 12, 16, 21, 31, 31, 31, 31,
13, 16, 17, 31, 31, 31, 31, 31,
24, 21, 31, 31, 31, 31, 31, 31,
26, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31,
31, 31, 31, 31, 31, 31, 31, 31,
},
{
4, 5, 8, 15, 20, 20, 20, 20,
5, 7, 10, 14, 20, 20, 20, 20,
8, 10, 14, 20, 20, 20, 20, 20,
15, 14, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 20, 20, 20,
},
{
3, 3, 5, 9, 13, 15, 15, 15,
3, 4, 6, 11, 14, 12, 12, 12,
5, 6, 9, 14, 12, 12, 12, 12,
9, 11, 14, 12, 12, 12, 12, 12,
13, 14, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12,
15, 12, 12, 12, 12, 12, 12, 12,
},
{
1, 1, 2, 5, 7, 8, 8, 8,
1, 2, 3, 5, 8, 8, 8, 8,
2, 3, 4, 8, 8, 8, 8, 8,
5, 5, 8, 8, 8, 8, 8, 8,
7, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8,
8, 8, 8, 8, 8, 8, 8, 8,
},
{
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
},
{
8, 9, 16, 29, 32, 38, 38, 38,
9, 14, 20, 26, 38, 38, 38, 38,
16, 20, 21, 38, 38, 38, 38, 38,
29, 26, 38, 38, 38, 38, 38, 38,
32, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38,
38, 38, 38, 38, 38, 38, 38, 38,
},
};
// STATIC: 0x00AC1BA8
static const uint8_t s_sourceBits156[764] = {
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x05, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x10,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x20, 0x04, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x20, 0x00,
0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00,
0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x0A, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x40, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x08, 0x01, 0x00, 0x00,
0x00, 0x00, 0x82, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x60, 0x00, 0x00, 0x20, 0x00, 0x00,
0x40, 0x00, 0x00, 0x20, 0x00, 0x00, 0x80, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x08, 0x00, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x80, 0x02, 0x00, 0x80, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
0x00, 0x08, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x03, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x88, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x24, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x44, 0x00,
0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x41, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x20, 0x00, 0x20, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x03, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x00, 0x80, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00, 0x00, 0x08, 0x41, 0x00, 0x00, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x00,
0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x02, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x02, 0x0C, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x01, 0x02, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00,
0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x08, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x00, 0x44, 0x00, 0x10, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xC2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30,
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x04, 0x00, 0x40, 0x24, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x80, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10,
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x88, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
// STATIC: 0x00AC1EA8
static const uint8_t s_checkBits156[764] = {
0x01, 0x80, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x20, 0x00, 0x00, 0x40, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x10,
0x00, 0x08, 0x04, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x24, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x40, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x02,
0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x10, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x01, 0x40, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
0x00, 0x00, 0x00, 0x02, 0x00, 0x40, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x10, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x50,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x10, 0x80, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00,
0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x40, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00, 0x82, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x02, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x40, 0x00, 0x04,
0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00,
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x08, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x40, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02,
0x00, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00, 0x05,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x08, 0x00, 0x48, 0x00, 0x08, 0x00,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x40, 0x00, 0x00, 0x00, 0x04,
0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x10,
0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x00, 0x02, 0x10, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x01,
0x80, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x08, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x10, 0x80,
0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
};
// STATIC: 0x00AC21A8
static const uint8_t s_invCheckBits156[764] = {
0x63, 0x46, 0x2B, 0xC0, 0xFF, 0x69, 0xC0, 0x4E, 0xAF, 0x7A, 0x48, 0x63, 0x52, 0xD5, 0xFF, 0x3E,
0x26, 0x21, 0xB8, 0xEC, 0xD5, 0xC7, 0x08, 0x65, 0xBE, 0xB5, 0x8A, 0x78, 0x29, 0xF4, 0xB2, 0xEA,
0x0A, 0x2E, 0x24, 0x50, 0xC8, 0x6C, 0x8D, 0x10, 0xE0, 0xE4, 0x7C, 0x2F, 0x8E, 0xD4, 0xF7, 0x79,
0xE9, 0x8B, 0x66, 0xAD, 0x8C, 0x0C, 0x4B, 0xA8, 0xA3, 0xEA, 0xF8, 0x14, 0x5E, 0xD8, 0x4E, 0x85,
0x5C, 0xF1, 0x2A, 0x5D, 0x3B, 0x2D, 0xC5, 0x0C, 0x05, 0x3C, 0x42, 0x2C, 0x94, 0x63, 0x33, 0x90,
0x4B, 0xFD, 0xEE, 0xBA, 0x14, 0x99, 0xB0, 0x61, 0x74, 0xD0, 0x62, 0x51, 0x9B, 0xFC, 0xE9, 0xF3,
0xDA, 0x3F, 0xCE, 0xD0, 0x84, 0x39, 0xB7, 0xB6, 0x38, 0xE7, 0xD5, 0x04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x40, 0x8D, 0x53, 0xF7, 0xDB, 0x5B, 0xA3, 0xA4, 0xD0, 0x57, 0x40, 0x90, 0x1D, 0x6E, 0xDC, 0x49,
0x8F, 0x7C, 0xD3, 0xCF, 0xDB, 0x57, 0x70, 0x40, 0x67, 0xAA, 0xE5, 0x09, 0x40, 0x96, 0x54, 0xF8,
0x0A, 0xE4, 0x5B, 0x60, 0x7C, 0xF1, 0x1E, 0x43, 0x1C, 0xA6, 0x26, 0xC8, 0x28, 0x3B, 0xE1, 0xED,
0x54, 0x1B, 0x59, 0xBD, 0xF3, 0x10, 0x99, 0xF7, 0xD0, 0xCA, 0xA1, 0xD7, 0x22, 0x25, 0xC7, 0x12,
0xE4, 0x67, 0xDB, 0x5C, 0x81, 0x1A, 0xC8, 0x25, 0x1E, 0x94, 0x81, 0xC5, 0xC7, 0x90, 0x15, 0x70,
0xBC, 0x94, 0xC9, 0xD9, 0x48, 0xDB, 0xF5, 0xEA, 0x3B, 0x8C, 0x45, 0xE1, 0x11, 0x04, 0x4F, 0x04,
0xA7, 0x6F, 0x00, 0x08, 0x90, 0x48, 0x0B, 0xB5, 0x04, 0x00, 0x00, 0x00,
};
// STATIC: 0x00AC24A8
static const uint8_t s_sourceBits176[968] = {
0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x20,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00,
0x40, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00,
0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x20, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x03, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x08, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x20, 0x02, 0x00, 0x00, 0x20, 0x02, 0x40, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x01, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02,
0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x14, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0x00, 0x80, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x03, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x0A, 0x40, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40,
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x04, 0x10, 0x08, 0x80, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x02, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
0x00, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08,
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x04, 0x00,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x02, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x12, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x00, 0x09, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x40,
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x29, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x28, 0x00, 0x20, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x08, 0x00, 0x00, 0x00, 0x02, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x41, 0x02, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x40, 0x00,
0x00, 0x80, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x04, 0x02,
0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x02, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x10,
0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00,
0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x10, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x04, 0x01, 0x00, 0x00, 0x00, 0x00, 0x24, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x08, 0x00, 0x40, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x18, 0x00, 0x00, 0x00, 0x10,
0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00,
0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x10,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x80, 0x02, 0x00, 0x20, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,
0x06, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x40,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x50, 0x00, 0x00, 0x20, 0x20,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
};
// STATIC: 0x00AC2870
static const uint8_t s_checkBits176[968] = {
0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x80, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x20, 0x10, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x40, 0x00, 0x40, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x80, 0x02, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
0xA0, 0x00, 0x00, 0x00, 0x10, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x20, 0x00, 0x80, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x20, 0x40, 0x00, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x00, 0x01, 0x00, 0x08, 0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00, 0x20, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x10, 0x08, 0x20, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
0x20, 0x00, 0x20, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00,
0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02, 0x80, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x04, 0x20, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x10, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x01, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x14, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00,
0x18, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44,
0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x08, 0x00,
0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x20, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00,
0x00, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00,
0x00, 0x40, 0x00, 0x80, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40,
0x08, 0x00, 0x00, 0x02, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x04, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x24, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x03, 0x00, 0x00, 0x00,
0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x10, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x48, 0x08, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x80, 0x10,
0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x00, 0x02, 0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x08, 0x80, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0x00, 0x20, 0x00,
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
};
// STATIC: 0x00AC2C38
static const uint8_t s_invCheckBits176[968] = {
0x83, 0x4E, 0x66, 0x20, 0xB9, 0xD4, 0x95, 0x03, 0x21, 0x58, 0xE0, 0x5E, 0x32, 0xDB, 0x64, 0x76,
0xC6, 0x9F, 0xFE, 0xD6, 0x53, 0x75, 0x12, 0x08, 0xB9, 0x99, 0xFA, 0x85, 0x67, 0xD9, 0x9E, 0xED,
0x76, 0x80, 0x8E, 0x66, 0xF0, 0xE2, 0x41, 0x52, 0x26, 0x48, 0x57, 0xE6, 0x60, 0x07, 0x8C, 0x1B,
0x73, 0x1F, 0xFB, 0x49, 0xD0, 0xEA, 0x51, 0x22, 0x69, 0x22, 0x0C, 0xFA, 0x32, 0x4E, 0xD9, 0x1E,
0xEB, 0x9B, 0x0E, 0x14, 0xCE, 0x6D, 0xC5, 0x2B, 0x02, 0x5B, 0x20, 0xF4, 0xC3, 0x47, 0x4F, 0xB4,
0xDC, 0x3A, 0x7D, 0x17, 0x5F, 0x60, 0xAB, 0x48, 0x7C, 0x11, 0xBD, 0x38, 0x9E, 0xB4, 0xC4, 0x2E,
0xEB, 0xA0, 0xEC, 0x5A, 0xAA, 0xC2, 0x77, 0xAE, 0x25, 0xB5, 0x8B, 0xCE, 0xC1, 0x75, 0x11, 0x0D,
0x91, 0x1D, 0xB1, 0xA5, 0xCF, 0xDF, 0x3F, 0xEC, 0x3E, 0xD5, 0x37, 0xDA, 0xA0, 0xE3, 0x4F, 0x48,
0x8C, 0x5C, 0xD8, 0x08, 0x3A, 0xBD, 0x4E, 0x6C, 0xDD, 0x3A, 0x4E, 0xC2, 0x1E, 0x2B, 0x24, 0x22,
0xA7, 0xD4, 0xC4, 0x09, 0xF3, 0x58, 0xD6, 0x1C, 0x3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 0x52, 0x01, 0x90, 0x96, 0x6D, 0xBE, 0xE3, 0x73, 0x15, 0x5E, 0xA1, 0x27, 0x47, 0xAE, 0x41,
0xB7, 0x9D, 0x70, 0x5C, 0xA4, 0x7D, 0x0F, 0xF2, 0x21, 0xEB, 0x95, 0xBE, 0xFB, 0x42, 0x32, 0xD2,
0x09, 0x33, 0xC0, 0x80, 0x8B, 0x6A, 0x46, 0xC4, 0xAC, 0x22, 0x87, 0x77, 0x55, 0x26, 0x15, 0x09,
0xF3, 0xCD, 0x1D, 0xA5, 0x76, 0x87, 0xB6, 0xF4, 0x95, 0x0D, 0x00, 0x8F, 0x34, 0x81, 0x06, 0x81,
0x78, 0x38, 0x84, 0x92, 0x81, 0x1B, 0xFC, 0x2B, 0x7A, 0x4F, 0x51, 0x92, 0x69, 0x95, 0x9B, 0x10,
0x06, 0x4D, 0x8E, 0xB5, 0x90, 0x6E, 0x7E, 0x57,
};
// STATIC: 0x00AC3000
static float s_weights8x8[64] = {
0.5f, 1.5f, 0.75f, 1.25f, 0.25f, 1.75f, 0.5f, 1.5f,
1.5f, 0.25f, 1.75f, 0.5f, 1.5f, 0.75f, 1.25f, 0.5f,
0.75f, 1.5f, 0.5f, 1.5f, 0.25f, 1.75f, 0.75f, 1.25f,
1.25f, 0.5f, 1.5f, 0.25f, 1.75f, 0.5f, 1.5f, 0.5f,
0.5f, 1.5f, 0.75f, 1.25f, 0.25f, 1.75f, 0.5f, 1.5f,
1.5f, 0.25f, 1.75f, 0.5f, 1.5f, 0.75f, 1.25f, 0.5f,
0.75f, 1.5f, 0.5f, 1.5f, 0.25f, 1.75f, 0.75f, 1.25f,
1.25f, 0.5f, 1.5f, 0.25f, 1.75f, 0.5f, 1.5f, 0.5f,
};
// STATIC: 0x00AC3100
static float s_weights5x5[25] = {
0.5f, 1.5f, 0.75f, 1.25f, 0.5f, 1.5f, 0.25f, 1.75f,
0.5f, 1.5f, 0.75f, 1.25f, 0.5f, 1.5f, 1.0f, 1.25f,
0.5f, 1.5f, 0.75f, 0.25f, 0.5f, 1.5f, 0.75f, 1.25f,
1.75f,
};
// STATIC: 0x00AC3168
static float s_weights4x5[20] = {
0.5f, 1.5f, 0.75f, 1.25f, 1.5f, 0.25f, 1.75f, 0.5f,
0.75f, 1.25f, 0.5f, 1.5f, 1.25f, 0.5f, 1.5f, 0.75f,
0.5f, 1.5f, 0.75f, 1.25f,
};
// STATIC: 0x00AC31B8
static float s_weights4x4[16] = {
0.5f, 1.75f, 0.75f, 1.25f, 1.5f, 0.25f, 1.25f, 0.5f,
0.75f, 1.5f, 0.5f, 1.5f, 1.25f, 0.5f, 1.5f, 0.75f,
};
// STATIC: 0x009EDD40
static const char* const s_addonMessages[] = { nullptr };
// STATIC: 0x00AC3164
static uint32_t s_blockWidth = 8;
// STATIC: 0x00AC31F8
static uint32_t s_blockHeight = 8;
// STATIC: 0x00AC31FC
static uint32_t s_blockArea = 64;
// STATIC: 0x00AC3200
static float s_step = 1.5f;
// STATIC: 0x00AC3204
static int32_t s_reverseScan = 1;
// STATIC: 0x00B49A30
static IWRect s_rects[32];
// STATIC: 0x00B49B30
static uint32_t s_rectCount;
// STATIC: 0x00B49B38
static void* s_writerState[33];
// STATIC: 0x00B49BBC
static int32_t s_initialized;
// STATIC: 0x00B49BC0
static IWLdpcEncoder s_encoder;
// STATIC: 0x00B49C4C
static int32_t s_flags;
// STATIC: 0x00B49C50
static void* (*s_alloc)(size_t bytes);
// STATIC: 0x00B49C54
static void (*s_free)(void* ptr);
// STATIC: 0x00B49C58
static IWRect s_defaultRect;
// STATIC: 0x00B49C60
static float* s_weights;
// STATIC: 0x00B49C64
static void* s_scratch;
// STATIC: 0x00B49C68
static uint32_t s_scratchSize;
// VERIFY: 459c1ce4 auto
// OFFSET: 0x004A9C90
static void ImageWriterSetFlags(int32_t flags) {
s_flags = flags;
}
// VERIFY: ec531b1a auto
// OFFSET: 0x004A9CA0
static void IWFree(void* ptr) {
if (s_free) {
s_free(ptr);
}
}
// VERIFY: 843f199c auto
// OFFSET: 0x004A9CC0
static void* IWAlloc(size_t bytes) {
if (s_alloc) {
return s_alloc(bytes);
}
return nullptr;
}
// VERIFY: 06b6992e auto
// OFFSET: 0x008D1CB0
static void* IWDefaultAlloc(size_t bytes) {
return malloc(bytes);
}
// VERIFY: 3c67528e auto
// OFFSET: 0x004A9CE0
static void IWDefaultFree(void* ptr) {
free(ptr);
}
// VERIFY: ce4c2ae8 manual
// OFFSET: 0x004A9CF0
static void IWSetAllocator(void* (*allocFunc)(size_t bytes)) {
s_alloc = allocFunc;
jpeg_set_malloc(IWAlloc);
}
// VERIFY: 2a7e079b manual
// OFFSET: 0x004A9D10
static void IWSetDeallocator(void (*freeFunc)(void* ptr)) {
s_free = freeFunc;
jpeg_set_free(IWFree);
}
// VERIFY: 6bd490a9 auto
// OFFSET: 0x004AADC0
int32_t IWBitMatrix::ResetScratch() {
s_scratch = nullptr;
s_scratchSize = 0;
return 1;
}
// VERIFY: 76cc4352 auto
// OFFSET: 0x004AADE0
void IWBitMatrix::FreeScratch() {
if (s_scratch) {
IWFree(s_scratch);
s_scratch = nullptr;
}
s_scratchSize = 0;
}
// VERIFY: b445715a auto
// OFFSET: 0x004AAE10
IWBitMatrix::IWBitMatrix() {
this->m_columns = 0;
this->m_rows = 0;
this->m_name = nullptr;
this->m_data = nullptr;
this->m_byteSize = 0;
this->m_static = 0;
}
// VERIFY: f176d5b8 auto
// OFFSET: 0x004AAE30
IWBitMatrix::~IWBitMatrix() {
if (this->m_data && !this->m_static) {
IWFree(const_cast<uint8_t*>(this->m_data));
}
}
// VERIFY: 53d58839 auto
// OFFSET: 0x004AAE50
int32_t IWBitMatrix::Initialize(uint32_t size, const char* name, const uint8_t* data) {
if (this->m_name == name && this->m_data == data && this->m_rows == size && this->m_static) {
return 1;
}
if (this->m_name || this->m_data) {
return 0;
}
this->m_columns = size;
this->m_rows = size;
uint32_t byteSize = ((size * size + 31) >> 3) & 0x1FFFFFFC;
this->m_name = name;
this->m_byteSize = byteSize;
if (!data) {
return 0;
}
this->m_static = 1;
this->m_data = data;
if (s_scratch) {
if (s_scratchSize >= byteSize) {
return 1;
}
IWFree(s_scratch);
}
s_scratch = IWAlloc(byteSize);
if (!s_scratch) {
return 0;
}
s_scratchSize = this->m_byteSize;
return 1;
}
// VERIFY: 50cf74bf auto
// OFFSET: 0x004AAF00
IWEncoder::IWEncoder() {
this->m_data = nullptr;
this->m_dataSize = 0;
this->m_encoded = nullptr;
this->m_encodedCapacity = 0;
this->m_encodedSize = 0;
this->m_repeat = 1;
this->m_codeBits = 0;
this->m_sourceBitCount = 0;
this->m_checkBitCount = 0;
}
// VERIFY: 69c77d76 auto
// OFFSET: 0x004AAF30
IWEncoder::~IWEncoder() {
}
// VERIFY: ba2aa804 auto
// OFFSET: 0x004AAF40
void IWEncoder::Reset() {
if (this->m_encoded) {
IWFree(this->m_encoded);
this->m_encoded = nullptr;
}
}
// VERIFY: 24c0beb1 auto
// OFFSET: 0x004A9480
IWLdpcEncoder::IWLdpcEncoder() {
this->m_codeword = nullptr;
this->m_sourceBits = nullptr;
this->m_checkNodes = nullptr;
this->m_bitNodes = nullptr;
}
// VERIFY: c17a9396 auto
// OFFSET: 0x004A94D0
IWLdpcEncoder::~IWLdpcEncoder() {
}
// VERIFY: ec87f952 manual
// OFFSET: 0x004A9500
void IWLdpcEncoder::Reset() {
if (this->m_checkNodes) {
IWFree(this->m_checkNodes);
this->m_checkNodes = nullptr;
}
if (this->m_bitNodes) {
IWFree(this->m_bitNodes);
this->m_bitNodes = nullptr;
}
if (this->m_codeword) {
IWFree(this->m_codeword);
this->m_codeword = nullptr;
}
if (this->m_sourceBits) {
IWFree(this->m_sourceBits);
this->m_sourceBits = nullptr;
}
IWBitMatrix::FreeScratch();
IWEncoder::Reset();
}
// VERIFY: cc63dada auto
// OFFSET: 0x004A9580
uint32_t IWLdpcEncoder::GetEncodedSize(uint32_t size) {
uint32_t copies = this->m_repeat + 1;
return (copies * this->m_codeBits * ((copies * (this->m_codeBits + 16 * size) - 1) / (this->m_codeBits * copies)) + 7) >> 3;
}
// VERIFY: f3bf8994 manual
// OFFSET: 0x004A95C0
uint32_t IWLdpcEncoder::Encode(const uint8_t* data, uint32_t size) {
uint32_t sourceIndex = 0;
uint32_t outputBit = 0;
if (!data || !size) {
return 0;
}
this->m_dataSize = size;
this->m_data = data;
uint32_t bytes = this->GetEncodedSize(size);
if (!this->m_encoded || bytes != this->m_encodedCapacity) {
this->m_encodedCapacity = bytes;
this->m_encoded = static_cast<uint8_t*>(IWAlloc(bytes));
if (!this->m_encoded) {
return 0;
}
}
memset(this->m_encoded, 0, this->m_encodedCapacity);
uint32_t stride = this->m_codeBits * ((16 * this->m_dataSize + this->m_codeBits - 1) / this->m_codeBits);
this->m_encodedSize = 0;
uint32_t copies = this->m_repeat + 1;
while (sourceIndex < 8 * this->m_dataSize) {
for (uint32_t i = 0; i < this->m_sourceBitCount; i++, sourceIndex++) {
this->m_sourceBits[i] = sourceIndex < 8 * this->m_dataSize && (this->m_data[sourceIndex >> 3] & (1 << (sourceIndex & 7))) != 0;
}
for (uint32_t i = 0; i < this->m_sourceBitCount; i++) {
this->m_codeword[i] = 0;
for (uint32_t j = 0; j < this->m_sourceBitCount; j++) {
uint32_t bit = this->m_sourceBit.m_rows * i + j;
this->m_codeword[i] += (this->m_sourceBit.m_data[bit >> 3] >> (bit & 7)) & 1 & this->m_sourceBits[j];
}
this->m_codeword[i] &= 1;
}
for (uint32_t i = 0; i < this->m_checkBitCount; i++) {
uint8_t* check = &this->m_codeword[this->m_sourceBitCount + i];
*check = 0;
for (uint32_t j = 0; j < this->m_checkBitCount; j++) {
uint32_t bit = this->m_invCheckBit.m_rows * i + j;
*check += (this->m_invCheckBit.m_data[bit >> 3] >> (bit & 7)) & 1 & this->m_codeword[j];
}
*check &= 1;
}
for (uint32_t i = 0; i < this->m_sourceBitCount; i++) {
this->m_codeword[i] = this->m_sourceBits[i];
}
if (this->m_repeat * stride + outputBit > 8 * this->m_encodedCapacity) {
return 0;
}
for (uint32_t i = 0; i < this->m_codeBits; i++) {
uint32_t bit = outputBit;
for (uint32_t copy = copies; copy > 0; copy--) {
if (this->m_codeword[i] == 1) {
this->m_encoded[bit >> 3] |= 1 << (bit & 7);
} else {
this->m_encoded[bit >> 3] &= ~(1 << (bit & 7));
}
bit += stride;
}
outputBit++;
}
}
this->m_encodedSize = (this->m_repeat * stride + outputBit + 7) >> 3;
return this->m_encodedSize;
}
// VERIFY: 98704482 manual
// OFFSET: 0x004A98F0
int32_t IWLdpcEncoder::BuildGraph() {
this->m_checkNodes = static_cast<IWCheckNode*>(IWAlloc(sizeof(IWCheckNode) * this->m_checkNodeCount));
this->m_bitNodes = static_cast<IWBitNode*>(IWAlloc(sizeof(IWBitNode) * this->m_codeBits));
if (!this->m_checkNodes || !this->m_bitNodes) {
return 0;
}
int32_t ok;
if (this->m_sourceBitCount + this->m_checkBitCount == 156) {
ok = this->m_sourceBit.Initialize(this->m_sourceBitCount, "mtxSourceBit", s_sourceBits156) & 1;
ok &= this->m_checkBit.Initialize(this->m_checkBitCount, "mtxCheckBit", s_checkBits156);
ok &= this->m_invCheckBit.Initialize(this->m_checkBitCount, "mtxInvCheckBit", s_invCheckBits156);
} else if (this->m_sourceBitCount + this->m_checkBitCount == 176) {
ok = this->m_sourceBit.Initialize(this->m_sourceBitCount, "mtxSourceBit", s_sourceBits176) & 1;
ok &= this->m_checkBit.Initialize(this->m_checkBitCount, "mtxCheckBit", s_checkBits176);
ok &= this->m_invCheckBit.Initialize(this->m_checkBitCount, "mtxInvCheckBit", s_invCheckBits176);
} else {
ok = this->m_sourceBit.Initialize(this->m_sourceBitCount, "mtxSourceBit", nullptr) & 1;
ok &= this->m_checkBit.Initialize(this->m_checkBitCount, "mtxCheckBit", nullptr);
return (ok & this->m_invCheckBit.Initialize(this->m_checkBitCount, "mtxInvCheckBit", nullptr)) != 0;
}
if (!ok) {
return 0;
}
memset(this->m_checkNodes, 0, sizeof(IWCheckNode) * this->m_checkNodeCount);
memset(this->m_bitNodes, 0, sizeof(IWBitNode) * this->m_codeBits);
for (uint32_t i = 0; i < this->m_codeBits; i++) {
this->m_bitNodes[i].m_index = static_cast<uint16_t>(i);
}
for (uint32_t c = 0; c < this->m_checkNodeCount; c++) {
IWCheckNode* check = &this->m_checkNodes[c];
for (uint32_t b = 0; b < this->m_sourceBitCount; b++) {
uint32_t bit = this->m_sourceBit.m_rows * c + b;
if ((this->m_sourceBit.m_data[bit >> 3] >> (bit & 7)) & 1) {
IWBitNode* node = &this->m_bitNodes[b];
check->m_bits[check->m_bitCount++] = node;
node->m_checks[node->m_checkCount++] = check;
}
}
for (uint32_t b = this->m_sourceBitCount; b < this->m_sourceBitCount + this->m_checkBitCount; b++) {
uint32_t bit = this->m_checkBit.m_rows * c + b - this->m_sourceBitCount;
if ((this->m_checkBit.m_data[bit >> 3] >> (bit & 7)) & 1) {
IWBitNode* node = &this->m_bitNodes[b];
check->m_bits[check->m_bitCount++] = node;
node->m_checks[node->m_checkCount++] = check;
}
}
}
return 1;
}
// VERIFY: d8370961 auto
// OFFSET: 0x004A9C00
int32_t IWLdpcEncoder::Initialize(uint32_t codeBits, uint32_t repeat) {
if (codeBits & 1) {
return 0;
}
if (!IWBitMatrix::ResetScratch()) {
return 0;
}
this->m_encodedSize = 0;
this->m_codeBits = codeBits;
this->m_checkBitCount = codeBits >> 1;
this->m_sourceBitCount = codeBits >> 1;
this->m_checkNodeCount = codeBits >> 1;
this->m_columnWeight = 3;
this->m_rowWeight = 6;
if (!this->BuildGraph()) {
return 0;
}
this->m_codeword = static_cast<uint8_t*>(IWAlloc(this->m_codeBits));
if (!this->m_codeword) {
return 0;
}
this->m_sourceBits = static_cast<uint8_t*>(IWAlloc(this->m_sourceBitCount));
if (!this->m_sourceBits) {
return 0;
}
this->m_repeat = repeat;
return 1;
}
// VERIFY: 238227b5 manual
// OFFSET: 0x004AA1D0
static int32_t SelectWeights() {
switch (s_blockWidth) {
case 8:
if (s_blockHeight == 8) {
s_weights = s_weights8x8;
return 1;
}
break;
case 4:
if (s_blockHeight == 4) {
s_weights = s_weights4x4;
return 1;
}
if (s_blockHeight == 5) {
s_weights = s_weights4x5;
return 1;
}
break;
case 5:
s_weights = s_weights5x5;
if (s_blockHeight == 5) {
return 1;
}
break;
}
s_weights = nullptr;
return 1;
}
// VERIFY: 4c6ffd2d auto
// OFFSET: 0x004AA250
static int32_t SetBlockSize(uint32_t width, uint32_t height, float step) {
s_step = step;
s_blockWidth = width;
s_blockHeight = height;
s_blockArea = height * width;
return SelectWeights();
}
// VERIFY: 808c685c auto
// OFFSET: 0x004AA280
static float AdjustBlock(int32_t top, uint32_t width, uint8_t* pixels, uint32_t bytesPerPixel, float ratio, int32_t left) {
float error[3] = { 0.0f, 0.0f, 0.0f };
float sum = 0.0f;
s_reverseScan = s_reverseScan == 0;
if (s_reverseScan) {
for (int32_t y = top + s_blockHeight - 1; y >= top; y--) {
for (int32_t x = left + s_blockWidth - 1; x >= left; x--) {
uint8_t* pixel = pixels + (y * width + x) * bytesPerPixel;
for (int32_t i = 0; i < 3; i++) {
float weight = s_weights ? s_weights[(y - top) * s_blockWidth + (x - left)] : 1.0f;
int32_t color = pixel[i];
float value = color + (weight * color * ratio + error[i]);
int32_t rounded = static_cast<int32_t>(value + 0.5f);
error[i] = value - rounded;
if (rounded < 0) {
error[i] = rounded + error[i];
rounded = 0;
} else if (rounded > 255) {
error[i] = error[i] + (rounded - 255);
rounded = 255;
}
pixel[i] = static_cast<uint8_t>(rounded);
}
sum += pixel[2] * 0.299f + pixel[1] * 0.587f + pixel[0] * 0.114f;
}
}
} else {
for (int32_t y = top; y < static_cast<int32_t>(top + s_blockHeight); y++) {
for (int32_t x = left; x < static_cast<int32_t>(left + s_blockWidth); x++) {
uint8_t* pixel = pixels + (y * width + x) * bytesPerPixel;
for (int32_t i = 0; i < 3; i++) {
float weight = s_weights ? s_weights[(y - top) * s_blockWidth + (x - left)] : 1.0f;
int32_t color = pixel[i];
float value = color + (weight * color * ratio + error[i]);
int32_t rounded = static_cast<int32_t>(value + 0.5f);
error[i] = value - rounded;
if (rounded < 0) {
error[i] = rounded + error[i];
rounded = 0;
} else if (rounded > 255) {
error[i] = error[i] + (rounded - 255);
rounded = 255;
}
pixel[i] = static_cast<uint8_t>(rounded);
}
sum += pixel[2] * 0.299f + pixel[1] * 0.587f + pixel[0] * 0.114f;
}
}
}
return sum / s_blockArea;
}
// VERIFY: 39898f7b manual
// OFFSET: 0x004AA580
static int32_t ValidateRects(IWRect** rects, uint32_t* count, uint32_t byteCount, uint32_t width, uint32_t height, bool checkCapacity) {
s_defaultRect.x = static_cast<int16_t>(-static_cast<int32_t>(width >> 1));
s_defaultRect.width = static_cast<int16_t>(width);
s_defaultRect.y = static_cast<int16_t>(-static_cast<int32_t>(height >> 1));
s_defaultRect.height = static_cast<int16_t>(height);
if (!*rects || !*count) {
*rects = &s_defaultRect;
*count = 1;
if (checkCapacity && 8 * byteCount > (s_defaultRect.height / s_blockHeight) * (s_defaultRect.width / s_blockWidth)) {
return 0;
}
return 1;
}
for (uint32_t i = 0; i < *count; i++) {
IWRect* rect = &(*rects)[i];
if (rect->x < s_defaultRect.x || rect->x + rect->width > s_defaultRect.x + s_defaultRect.width || rect->y < s_defaultRect.y || rect->y + rect->height > s_defaultRect.y + s_defaultRect.height) {
return 0;
}
for (uint32_t j = i + 1; j < *count; j++) {
IWRect* other = &(*rects)[j];
int32_t overlapX = 0;
if (rect->x < other->x + other->width && other->x < rect->x + rect->width) {
overlapX = 1;
}
if (rect->y < other->y + other->height && other->y < rect->y + rect->height && overlapX) {
return 0;
}
}
if (checkCapacity && 8 * byteCount > (rect->width / s_blockWidth) * (rect->height / s_blockHeight)) {
return 0;
}
}
return 1;
}
// VERIFY: 135ac80e manual
// OFFSET: 0x004AA760
static int32_t EmbedBits(IWEmbedParams* params) {
if (!params) {
return 0;
}
if (params->m_width < 2 * s_blockWidth || params->m_height < 2 * s_blockHeight) {
return 0;
}
if (!ValidateRects(&params->m_rects, &params->m_rectCount, params->m_byteCount, params->m_width, params->m_height, true)) {
return 0;
}
const uint8_t* bits = params->m_bits;
uint32_t maxIterations = 0;
for (uint32_t r = 0; r < params->m_rectCount; r++) {
IWRect* rect = &params->m_rects[r];
uint32_t left = (params->m_width >> 1) + rect->x;
uint32_t right = left + rect->width;
uint32_t top = (params->m_height >> 1) + rect->y;
uint32_t bottom = top + rect->height;
uint32_t bitIndex = 0;
for (uint32_t x = left; x < right; x += s_blockWidth) {
for (uint32_t y = top; y < bottom; y += s_blockHeight) {
float invArea = 1.0f / s_blockArea;
float sum = 0.0f;
int32_t saturated = 0;
for (uint32_t py = y; py < y + s_blockHeight; py++) {
for (uint32_t px = x; px < x + s_blockWidth; px++) {
const uint8_t* pixel = params->m_pixels + (py * params->m_width + px) * params->m_bytesPerPixel;
if (255 - pixel[0] < s_step || 255 - pixel[1] < s_step || 255 - pixel[2] < s_step) {
saturated++;
}
sum += pixel[2] * 0.299f + pixel[0] * 0.114f + pixel[1] * 0.587f;
}
}
float mean = sum * invArea;
float target = mean;
if (bitIndex >> 3 < params->m_byteCount) {
if (bits[bitIndex >> 3] & (1 << (bitIndex & 7))) {
target = 0.5f * s_step + static_cast<int32_t>(mean / s_step) * s_step;
} else {
target = static_cast<int32_t>((0.5f * s_step + mean) / s_step) * s_step;
}
bitIndex++;
}
float difference = target - mean;
if (fabs(difference) <= 0.0000099999997f) {
continue;
}
float level = AdjustBlock(y, params->m_width, params->m_pixels, params->m_bytesPerPixel, difference / mean, x);
float invStep = 1.0f / s_step;
float error = fabs(invStep * level - invStep * target);
uint32_t iteration = 0;
while (error > 0.02f && iteration < 16) {
iteration++;
if (iteration > maxIterations) {
maxIterations = iteration;
}
level = AdjustBlock(y, params->m_width, params->m_pixels, params->m_bytesPerPixel, (target - level) / level, x);
error = fabs(invStep * level - invStep * target);
if (iteration == 8 && saturated > static_cast<int32_t>(s_blockHeight * s_blockWidth * 0.68f)) {
target -= s_step;
}
}
SelectWeights();
}
}
}
return 1;
}
// VERIFY: 9352c7fa manual
// OFFSET: 0x004A9D30
static int32_t WriteJpegFile(IWJpegParams* params) {
if (!params->m_pixels) {
return 0;
}
struct jpeg_error_mgr jerr;
struct jpeg_compress_struct cinfo;
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_compress(&cinfo);
if (cinfo.error_flag) {
return 0;
}
jerr.addon_message_table = s_addonMessages;
jerr.first_addon_message = 1000;
jerr.last_addon_message = 1012;
cinfo.in_color_space = JCS_RGB;
jpeg_set_defaults(&cinfo);
if (cinfo.error_flag) {
return 0;
}
int32_t luminance[64];
int32_t chrominance[64];
uint32_t quality = params->m_quality;
if (quality % 10) {
const int32_t* luminanceHigh = s_luminanceTables[quality / 10];
const int32_t* chrominanceHigh = s_chrominanceTables[quality / 10];
const int32_t* luminanceLow = s_luminanceTables[quality / 10 - 1];
const int32_t* chrominanceLow = s_chrominanceTables[quality / 10 - 1];
if (quality > 50 && quality < 60) {
luminanceLow = s_luminanceTables[10];
chrominanceLow = s_chrominanceTables[10];
}
float fraction = (quality % 10) * 0.1f;
for (int32_t i = 0; i < 64; i++) {
luminance[i] = luminanceLow[i] + static_cast<uint32_t>((luminanceHigh[i] - luminanceLow[i]) * fraction);
chrominance[i] = chrominanceLow[i] + static_cast<uint32_t>((chrominanceHigh[i] - chrominanceLow[i]) * fraction);
}
} else {
for (int32_t i = 0; i < 64; i++) {
luminance[i] = s_luminanceTables[quality / 10 - 1][i];
chrominance[i] = s_chrominanceTables[quality / 10 - 1][i];
}
}
jpeg_add_quant_table(&cinfo, 0, luminance, FALSE);
if (cinfo.error_flag) {
return 0;
}
jpeg_add_quant_table(&cinfo, 1, chrominance, FALSE);
if (cinfo.error_flag) {
return 0;
}
FILE* file = fopen(params->m_fileName, "wb");
if (!file) {
return 0;
}
cinfo.image_width = params->m_width;
cinfo.image_height = params->m_height;
cinfo.input_components = params->m_bytesPerPixel;
cinfo.source_pixels = params->m_pixels;
mem_source_ptr source = jinit_read_mem(&cinfo);
if (cinfo.error_flag) {
return 0;
}
source->input_file = nullptr;
cinfo.input_components = 3;
(*source->start_input)(&cinfo, source);
if (cinfo.error_flag) {
return 0;
}
jpeg_default_colorspace(&cinfo);
if (cinfo.error_flag) {
return 0;
}
if (params->m_subsample) {
cinfo.comp_info[0].h_samp_factor = 2;
cinfo.comp_info[0].v_samp_factor = 2;
} else {
cinfo.comp_info[0].h_samp_factor = 1;
cinfo.comp_info[0].v_samp_factor = 1;
}
cinfo.comp_info[1].h_samp_factor = 1;
cinfo.comp_info[1].v_samp_factor = 1;
cinfo.comp_info[2].h_samp_factor = 1;
cinfo.comp_info[2].v_samp_factor = 1;
jpeg_stdio_dest(&cinfo, file);
if (cinfo.error_flag) {
return 0;
}
jpeg_start_compress(&cinfo, TRUE);
if (cinfo.error_flag) {
return 0;
}
if (params->m_comment) {
jpeg_write_marker(&cinfo, JPEG_COM, reinterpret_cast<const JOCTET*>(params->m_comment), static_cast<uint32_t>(strlen(params->m_comment)));
if (cinfo.error_flag) {
return 0;
}
}
while (cinfo.next_scanline < cinfo.image_height) {
JDIMENSION rows = (*source->get_pixel_rows)(&cinfo, source);
jpeg_write_scanlines(&cinfo, source->buffer, rows);
if (cinfo.error_flag) {
return 0;
}
}
(*source->finish_input)(&cinfo, source);
jpeg_finish_compress(&cinfo);
if (cinfo.error_flag) {
return 0;
}
jpeg_destroy_compress(&cinfo);
if (cinfo.error_flag) {
return 0;
}
if (file != stdout) {
fclose(file);
}
return 1;
}
// VERIFY: 5d0e03e9 manual
// OFFSET: 0x004A8FE0
static int32_t ComputeLayout(uint32_t height, uint32_t width, uint32_t dataSize) {
if (width == 800 && height == 600) {
s_rects[0].x = -384;
s_rects[0].width = 384;
s_rects[0].y = -220;
s_rects[0].height = 220;
s_rects[1].x = 0;
s_rects[1].width = 300;
s_rects[1].y = -285;
s_rects[1].height = 285;
s_rects[2].x = -340;
s_rects[2].width = 340;
s_rects[2].y = 0;
s_rects[2].height = 250;
s_rects[3].x = 0;
s_rects[3].width = 340;
s_rects[3].y = 0;
s_rects[3].height = 250;
s_rectCount = 4;
return SetBlockSize(4, 5, 2.5f) != 0;
}
int32_t unit = static_cast<int32_t>((height * 0.23255813953488372 + 4.0) * 0.2);
int32_t rectHeight = unit * 5;
int32_t bits = static_cast<int32_t>(s_encoder.GetEncodedSize(dataSize) * 8);
int32_t columns = static_cast<int32_t>(static_cast<double>(bits) / unit) + 1;
int32_t rectWidth = columns * 4;
if (columns > static_cast<int32_t>(width)) {
return 0;
}
if (2 * rectWidth >= static_cast<int32_t>(width - 16)) {
int16_t x = static_cast<int16_t>(static_cast<int32_t>(rectWidth * -0.5f));
s_rects[0].x = x;
s_rects[0].width = static_cast<int16_t>(rectWidth);
s_rects[0].y = static_cast<int16_t>(static_cast<int32_t>(rectHeight * -1.55f));
s_rects[0].height = static_cast<int16_t>(rectHeight);
s_rects[1].x = x;
s_rects[1].width = static_cast<int16_t>(rectWidth);
s_rects[1].y = static_cast<int16_t>(static_cast<int32_t>(rectHeight * -0.5f));
s_rects[1].height = static_cast<int16_t>(rectHeight);
s_rects[2].x = x;
s_rects[2].width = static_cast<int16_t>(rectWidth);
s_rects[2].y = static_cast<int16_t>(static_cast<int32_t>(rectHeight * 0.55f));
s_rects[2].height = static_cast<int16_t>(rectHeight);
s_rectCount = 3;
return SetBlockSize(4, 5, 2.5f) != 0;
}
int32_t half = rectWidth >> 1;
s_rects[0].y = static_cast<int16_t>(-(rectHeight >> 1));
s_rects[0].x = static_cast<int16_t>(-half);
s_rects[0].width = static_cast<int16_t>(rectWidth);
s_rects[0].height = static_cast<int16_t>(rectHeight);
uint32_t count = 1;
s_rectCount = 1;
int32_t halfWidth = static_cast<int32_t>(width >> 1);
int32_t position = half;
if (half + rectWidth + 4 < halfWidth) {
do {
if (count > 30) {
break;
}
position += 4;
int16_t y = static_cast<int16_t>(static_cast<int32_t>(rectHeight * -0.5f));
s_rects[count].x = static_cast<int16_t>(position);
s_rects[count].width = static_cast<int16_t>(rectWidth);
s_rects[count].y = y;
s_rects[count].height = static_cast<int16_t>(rectHeight);
int32_t next = position + rectWidth;
s_rects[count + 1].x = static_cast<int16_t>(-next);
s_rects[count + 1].width = static_cast<int16_t>(rectWidth);
s_rects[count + 1].y = y;
s_rects[count + 1].height = static_cast<int16_t>(rectHeight);
count += 2;
position = next;
} while (position + rectWidth + 4 < halfWidth);
s_rectCount = count;
}
position = 0;
int32_t extent = rectWidth + 4;
if (extent < halfWidth) {
do {
if (count > 28) {
break;
}
extent += 4;
position += 4;
int16_t upper = static_cast<int16_t>(-4 - static_cast<int32_t>(rectHeight * 1.5f));
s_rects[count].x = static_cast<int16_t>(position);
s_rects[count].width = static_cast<int16_t>(rectWidth);
s_rects[count].y = upper;
s_rects[count].height = static_cast<int16_t>(rectHeight);
int16_t lower = static_cast<int16_t>(4 - static_cast<int32_t>(rectHeight * -0.5f));
s_rects[count + 1].x = static_cast<int16_t>(position);
s_rects[count + 1].width = static_cast<int16_t>(rectWidth);
s_rects[count + 1].y = lower;
s_rects[count + 1].height = static_cast<int16_t>(rectHeight);
extent += rectWidth;
position += rectWidth;
s_rects[count + 2].x = static_cast<int16_t>(-position);
s_rects[count + 2].width = static_cast<int16_t>(rectWidth);
s_rects[count + 2].y = upper;
s_rects[count + 2].height = static_cast<int16_t>(rectHeight);
s_rects[count + 3].x = static_cast<int16_t>(-position);
s_rects[count + 3].width = static_cast<int16_t>(rectWidth);
s_rects[count + 3].y = lower;
s_rects[count + 3].height = static_cast<int16_t>(rectHeight);
count += 4;
} while (extent < halfWidth);
s_rectCount = count;
}
return SetBlockSize(4, 5, 2.5f) != 0;
}
// VERIFY: 4789acb6 auto
// OFFSET: 0x004A8E80
int32_t ImageWriterInitialize(uint32_t dataSize, void* (*allocFunc)(size_t bytes), void (*freeFunc)(void* ptr), int32_t flags) {
if (dataSize > 128) {
return 0;
}
if (!allocFunc) {
allocFunc = IWDefaultAlloc;
}
if (!freeFunc) {
freeFunc = IWDefaultFree;
}
IWSetAllocator(allocFunc);
IWSetDeallocator(freeFunc);
ImageWriterSetFlags(flags);
if (!s_encoder.Initialize(dataSize * 2, 2)) {
return 0;
}
memset(s_writerState, 0, sizeof(s_writerState));
s_initialized = 1;
return 1;
}
// VERIFY: 9efe6ea5 auto
// OFFSET: 0x004A8F00
int32_t ImageWriterShutdown() {
if (s_writerState[0]) {
IWFree(s_writerState[0]);
}
memset(s_writerState, 0, sizeof(s_writerState));
s_encoder.Reset();
s_initialized = 0;
return 1;
}
// VERIFY: a3753407 auto
// OFFSET: 0x004A8F40
int32_t ImageWriterWriteJpeg(const char* fileName, const void* pixels, uint32_t width, uint32_t height, uint32_t bytesPerPixel, uint32_t quality) {
if (!s_initialized || !fileName || !pixels) {
return 0;
}
if (width < 8 || height < 8 || (bytesPerPixel != 3 && bytesPerPixel != 4)) {
return 0;
}
if (quality - 10 > 90) {
return 0;
}
IWJpegParams params;
params.m_bytesPerPixel = bytesPerPixel;
params.m_pixels = pixels;
params.m_fileName = fileName;
params.m_width = width;
params.m_height = height;
params.m_quality = quality;
params.m_subsample = 0;
params.m_comment = nullptr;
params.unk_0020 = 0;
return WriteJpegFile(&params) != 0;
}
// VERIFY: dfdf6b42 auto
// OFFSET: 0x004A93B0
int32_t ImageWriterEmbedData(const void* pixels, uint32_t width, uint32_t height, uint32_t bytesPerPixel, const uint8_t* data, uint32_t dataSize) {
if (!s_initialized || !pixels || !data) {
return 0;
}
if (width < 64 || height < 64 || (bytesPerPixel != 3 && bytesPerPixel != 4)) {
return 0;
}
if (!ComputeLayout(height, width, dataSize) || !s_encoder.Encode(data, dataSize)) {
return 0;
}
IWEmbedParams params;
params.m_bits = s_encoder.m_encoded;
params.m_pixels = static_cast<uint8_t*>(const_cast<void*>(pixels));
params.m_bytesPerPixel = bytesPerPixel;
params.m_width = width;
params.m_height = height;
params.m_byteCount = s_encoder.m_encodedSize;
params.m_rects = s_rects;
params.m_rectCount = s_rectCount;
return EmbedBits(&params) != 0;
}