@@ -35,7 +35,7 @@ void lzss_init(
35
35
}
36
36
37
37
decoder = new LZSSDecoder (
38
- [target_file ](const uint8_t c) {
38
+ [](const uint8_t c) {
39
39
fwrite (&c, 1 , 1 , target_file);
40
40
}
41
41
);
@@ -68,7 +68,7 @@ void lzss_decode() {
68
68
**************************************************************************************/
69
69
70
70
// get the number of bits the algorithm will try to get given the state
71
- int LZSSDecoder::bits_required (LZSSDecoder::FSM_STATES s) {
71
+ uint8_t LZSSDecoder::bits_required (LZSSDecoder::FSM_STATES s) {
72
72
switch (s) {
73
73
case FSM_0:
74
74
return 1 ;
@@ -78,18 +78,20 @@ int LZSSDecoder::bits_required(LZSSDecoder::FSM_STATES s) {
78
78
return EI;
79
79
case FSM_3:
80
80
return EJ;
81
+ default :
82
+ return 0 ;
81
83
}
82
84
}
83
85
84
86
LZSSDecoder::LZSSDecoder (std::function<int ()> getc_cbk, std::function<void(const uint8_t )> putc_cbk)
85
- : put_char_cbk(putc_cbk ), get_char_cbk(getc_cbk ), state(FSM_0 ), available( 0 ) {
87
+ : available( 0 ), state(FSM_0 ), put_char_cbk(putc_cbk ), get_char_cbk(getc_cbk ) {
86
88
for (int i = 0 ; i < N - F; i++) buffer[i] = ' ' ;
87
89
r = N - F;
88
90
}
89
91
90
92
91
93
LZSSDecoder::LZSSDecoder (std::function<void (const uint8_t )> putc_cbk)
92
- : put_char_cbk(putc_cbk ), state(FSM_0), available( 0 ) {
94
+ : available( 0 ), state(FSM_0), put_char_cbk(putc_cbk), get_char_cbk( nullptr ) {
93
95
for (int i = 0 ; i < N - F; i++) buffer[i] = ' ' ;
94
96
r = N - F;
95
97
}
@@ -141,6 +143,8 @@ LZSSDecoder::status LZSSDecoder::handle_state() {
141
143
142
144
break ;
143
145
}
146
+ case FSM_EOF:
147
+ break ;
144
148
}
145
149
}
146
150
@@ -162,7 +166,7 @@ LZSSDecoder::status LZSSDecoder::decompress(uint8_t* const buffer, uint32_t size
162
166
return res;
163
167
}
164
168
165
- int LZSSDecoder::getbit (int n) { // get n bits from buffer
169
+ int LZSSDecoder::getbit (uint8_t n) { // get n bits from buffer
166
170
int x=0 , c;
167
171
168
172
// if the local bit buffer doesn't have enough bit get them
0 commit comments