diff options
Diffstat (limited to 'decoder.cc')
-rw-r--r-- | decoder.cc | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -1,4 +1,4 @@ -/* Lziprecover - Data recovery tool for lzipped files +/* Lziprecover - Data recovery tool for lzip files Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz. This program is free software: you can redistribute it and/or modify @@ -104,10 +104,10 @@ bool Range_decoder::read_block() void LZ_decoder::flush_data() { - const int size = pos - stream_pos; - if( size > 0 ) + if( pos > stream_pos ) { - crc32.update( crc_, buffer + stream_pos, size ); + const int size = pos - stream_pos; + crc32.update_buf( crc_, buffer + stream_pos, size ); if( outfd >= 0 ) { const unsigned long long sp = stream_position(); @@ -207,7 +207,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 @@ -222,11 +221,16 @@ 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 { |