diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:25:07 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:25:07 +0000 |
commit | cc850a231b6eb35f6a7513455f85fd51a299af71 (patch) | |
tree | 4a73324f0332390d84c3d83843444e68e833eff4 /decoder.h | |
parent | Adding upstream version 1.6. (diff) | |
download | lzip-cc850a231b6eb35f6a7513455f85fd51a299af71.tar.xz lzip-cc850a231b6eb35f6a7513455f85fd51a299af71.zip |
Adding upstream version 1.7.upstream/1.7
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | decoder.h | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -21,7 +21,7 @@ class Input_buffer uint8_t * const buffer; int pos; int stream_pos; // when reached, a new block must be read - const int ides_; + const int ides_; // input file descriptor bool at_stream_end; bool read_block(); @@ -196,11 +196,11 @@ class Literal_decoder { return ( prev_byte >> ( 8 - literal_context_bits ) ); } public: - uint8_t decode( Range_decoder & range_decoder, const int prev_byte ) + uint8_t decode( Range_decoder & range_decoder, const uint8_t prev_byte ) { return range_decoder.decode_tree( bm_literal[state(prev_byte)], 8 ); } uint8_t decode_matched( Range_decoder & range_decoder, - const int prev_byte, const int match_byte ) + const uint8_t prev_byte, const uint8_t match_byte ) { return range_decoder.decode_matched( bm_literal[state(prev_byte)], match_byte ); } }; @@ -215,7 +215,7 @@ class LZ_decoder int pos; int stream_pos; // first byte not yet written to file uint32_t crc_; - const int odes_; + const int odes_; // output file descriptor Bit_model bm_match[State::states][pos_states]; Bit_model bm_rep[State::states]; @@ -249,7 +249,7 @@ class LZ_decoder { int i = pos - distance - 1; if( i < 0 ) i += buffer_size; - if( len < buffer_size - std::max( pos, i ) && len <= distance ) + if( len < buffer_size - std::max( pos, i ) && len <= std::abs( pos - i ) ) { std::memcpy( buffer + pos, buffer + i, len ); pos += len; @@ -278,7 +278,8 @@ public: crc_( 0xFFFFFFFF ), odes_( odes ), range_decoder( sizeof header, ibuf ), - literal_decoder() {} + literal_decoder() + { buffer[buffer_size-1] = 0; } // prev_byte of first_byte ~LZ_decoder() { delete[] buffer; } |