diff options
Diffstat (limited to 'decoder.cc')
-rw-r--r-- | decoder.cc | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -107,7 +107,7 @@ void LZ_decoder::flush_data() const int size = pos - stream_pos; if( size > 0 ) { - crc32.update( crc_, buffer + stream_pos, size ); + crc32.update_buf( crc_, buffer + stream_pos, size ); if( outfd >= 0 && writeblock( outfd, buffer + stream_pos, size ) != size ) throw Error( "Write error" ); @@ -203,7 +203,6 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) Bit_model bm_align[dis_align_size]; Len_model match_len_model; Len_model rep_len_model; - unsigned rep0 = 0; // rep[0-3] latest four distances unsigned rep1 = 0; // used for efficient coding of unsigned rep2 = 0; // repeated distances @@ -218,23 +217,23 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) { const uint8_t prev_byte = get_prev_byte(); if( state.is_char() ) + { + state.set_char1(); put_byte( rdec.decode_tree( bm_literal[get_lit_state(prev_byte)], 8 ) ); + } else + { + state.set_char2(); put_byte( rdec.decode_matched( bm_literal[get_lit_state(prev_byte)], get_byte( rep0 ) ) ); - state.set_char(); + } } else { int len; if( rdec.decode_bit( bm_rep[state()] ) == 1 ) // 2nd bit { - if( rdec.decode_bit( bm_rep0[state()] ) == 0 ) // 3rd bit - { - if( rdec.decode_bit( bm_len[state()][pos_state] ) == 0 ) // 4th bit - { state.set_short_rep(); put_byte( get_byte( rep0 ) ); continue; } - } - else + if( rdec.decode_bit( bm_rep0[state()] ) == 1 ) // 3rd bit { unsigned distance; if( rdec.decode_bit( bm_rep1[state()] ) == 0 ) // 4th bit @@ -250,8 +249,13 @@ int LZ_decoder::decode_member( const Pretty_print & pp ) rep1 = rep0; rep0 = distance; } - len = min_match_len + rdec.decode_len( rep_len_model, pos_state ); + else + { + if( rdec.decode_bit( bm_len[state()][pos_state] ) == 0 ) // 4th bit + { state.set_short_rep(); put_byte( get_byte( rep0 ) ); continue; } + } state.set_rep(); + len = min_match_len + rdec.decode_len( rep_len_model, pos_state ); } else { |