void lz_expand(struct data_in_s *data_in, struct data_out_s *data_out)
{
unsigned int pos;
- unsigned int offset;
+ unsigned int wordoffset;
unsigned int i;
unsigned char byte;
- unsigned int num;
+ unsigned int wordlen;
unsigned char buf[1024];
pos = 1;
while (1) {
while (1) {
+ /* Compressed/uncompressed? */
if (get_next_bit(data_in) == 0)
break;
+ /* Uncompressed byte */
byte = get_next_bits(data_in, 8);
write_byte(byte, data_out);
+
+ /* Save byte in buffer, to be reused later */
buf[pos] = byte;
pos = (pos + 1) & 0x3ff;
}
- offset = get_next_bits(data_in, 0x0a);
- if(offset == 0)
+ /* offset for start of dictionary word */
+ wordoffset = get_next_bits(data_in, 0x0a);
+ if(wordoffset == 0)
return;
- num = get_next_bits(data_in, 0x04) + 1;
- for (i = 0; i <= num; i++) {
- byte = buf[(offset + i) & 0x3ff];
+ /* length of dictionary word used */
+ wordlen = get_next_bits(data_in, 0x04) + 1;
+ for (i = 0; i <= wordlen ; i++) {
+ /* lookup dictionary byte */
+ byte = buf[(wordoffset + i) & 0x3ff];
write_byte(byte, data_out);
+ /* Save byte in buffer, to be reused later */
buf[pos] = byte;
pos = (pos + 1) & 0x3ff;
}