Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/libsnes/bsnes/snes/chip/sdd1/decomp.hpp
2 views
1
struct Decomp {
2
struct IM { //input manager
3
Decomp &self;
4
void init(unsigned offset);
5
uint8 get_codeword(uint8 code_length);
6
IM(SDD1::Decomp &self) : self(self) {}
7
private:
8
unsigned offset;
9
unsigned bit_count;
10
};
11
12
struct GCD { //golomb-code decoder
13
Decomp &self;
14
static const uint8 run_count[256];
15
void get_run_count(uint8 code_number, uint8 &mps_count, bool &lps_index);
16
GCD(SDD1::Decomp &self) : self(self) {}
17
};
18
19
struct BG { //bits generator
20
Decomp &self;
21
void init();
22
uint8 get_bit(bool &end_of_run);
23
BG(SDD1::Decomp &self, uint8 code_number) : self(self), code_number(code_number) {}
24
private:
25
const uint8 code_number;
26
uint8 mps_count;
27
bool lps_index;
28
};
29
30
struct PEM { //probability estimation module
31
Decomp &self;
32
void init();
33
uint8 get_bit(uint8 context);
34
PEM(SDD1::Decomp &self) : self(self) {}
35
private:
36
struct State {
37
uint8 code_number;
38
uint8 next_if_mps;
39
uint8 next_if_lps;
40
};
41
static const State evolution_table[33];
42
struct ContextInfo {
43
uint8 status;
44
uint8 mps;
45
} context_info[32];
46
};
47
48
struct CM { //context model
49
Decomp &self;
50
void init(unsigned offset);
51
uint8 get_bit();
52
CM(SDD1::Decomp &self) : self(self) {}
53
private:
54
uint8 bitplanes_info;
55
uint8 context_bits_info;
56
uint8 bit_number;
57
uint8 current_bitplane;
58
uint16 previous_bitplane_bits[8];
59
};
60
61
struct OL { //output logic
62
Decomp &self;
63
void init(unsigned offset);
64
uint8 decompress();
65
OL(SDD1::Decomp &self) : self(self) {}
66
private:
67
uint8 bitplanes_info;
68
uint8 r0, r1, r2;
69
};
70
71
void init(unsigned offset);
72
uint8 read();
73
uint8 rom_read(unsigned offset);
74
Decomp();
75
76
IM im;
77
GCD gcd;
78
BG bg0, bg1, bg2, bg3, bg4, bg5, bg6, bg7;
79
PEM pem;
80
CM cm;
81
OL ol;
82
};
83
84