summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 07:25:07 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 07:25:07 +0000
commitcc850a231b6eb35f6a7513455f85fd51a299af71 (patch)
tree4a73324f0332390d84c3d83843444e68e833eff4 /decoder.h
parentAdding upstream version 1.6. (diff)
downloadlzip-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 'decoder.h')
-rw-r--r--decoder.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/decoder.h b/decoder.h
index 290ab97..e4444f1 100644
--- a/decoder.h
+++ b/decoder.h
@@ -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; }