summaryrefslogtreecommitdiffstats
path: root/decoder.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--decoder.cc28
1 files changed, 14 insertions, 14 deletions
diff --git a/decoder.cc b/decoder.cc
index b23daa2..06d334b 100644
--- a/decoder.cc
+++ b/decoder.cc
@@ -51,9 +51,9 @@ void Pretty_print::operator()( const char * const msg ) const
}
-// Returns the number of bytes really read.
-// If (returned value < size) and (errno == 0), means EOF was reached.
-//
+/* Returns the number of bytes really read.
+ If (returned value < size) and (errno == 0), means EOF was reached.
+*/
int readblock( const int fd, uint8_t * const buf, const int size )
{
int rest = size;
@@ -70,9 +70,9 @@ int readblock( const int fd, uint8_t * const buf, const int size )
}
-// Returns the number of bytes really written.
-// If (returned value < size), it is always an error.
-//
+/* Returns the number of bytes really written.
+ If (returned value < size), it is always an error.
+*/
int writeblock( const int fd, const uint8_t * const buf, const int size )
{
int rest = size;
@@ -104,9 +104,9 @@ bool Range_decoder::read_block()
void LZ_decoder::flush_data()
{
- const int size = pos - stream_pos;
- if( size > 0 )
+ if( pos > stream_pos )
{
+ const int size = pos - stream_pos;
crc32.update_buf( crc_, buffer + stream_pos, size );
if( outfd >= 0 &&
writeblock( outfd, buffer + stream_pos, size ) != size )
@@ -187,8 +187,8 @@ bool LZ_decoder::verify_trailer( const Pretty_print & pp ) const
}
-// Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF,
-// 3 = trailer error, 4 = unknown marker found.
+/* Return value: 0 = OK, 1 = decoder error, 2 = unexpected EOF,
+ 3 = trailer error, 4 = unknown marker found. */
int LZ_decoder::decode_member( const Pretty_print & pp )
{
Bit_model bm_literal[1<<literal_context_bits][0x300];
@@ -198,7 +198,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp )
Bit_model bm_rep1[State::states];
Bit_model bm_rep2[State::states];
Bit_model bm_len[State::states][pos_states];
- Bit_model bm_dis_slot[max_dis_states][1<<dis_slot_bits];
+ Bit_model bm_dis_slot[len_states][1<<dis_slot_bits];
Bit_model bm_dis[modeled_distances-end_dis_model];
Bit_model bm_align[dis_align_size];
Len_model match_len_model;
@@ -231,9 +231,9 @@ int LZ_decoder::decode_member( const Pretty_print & pp )
else
{
int len;
- if( rdec.decode_bit( bm_rep[state()] ) == 1 ) // 2nd bit
+ if( rdec.decode_bit( bm_rep[state()] ) != 0 ) // 2nd bit
{
- if( rdec.decode_bit( bm_rep0[state()] ) == 1 ) // 3rd bit
+ if( rdec.decode_bit( bm_rep0[state()] ) != 0 ) // 3rd bit
{
unsigned distance;
if( rdec.decode_bit( bm_rep1[state()] ) == 0 ) // 4th bit
@@ -261,7 +261,7 @@ int LZ_decoder::decode_member( const Pretty_print & pp )
{
const unsigned rep0_saved = rep0;
len = min_match_len + rdec.decode_len( match_len_model, pos_state );
- const int dis_slot = rdec.decode_tree6( bm_dis_slot[get_dis_state(len)] );
+ const int dis_slot = rdec.decode_tree6( bm_dis_slot[get_len_state(len)] );
if( dis_slot < start_dis_model ) rep0 = dis_slot;
else
{