diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:23:45 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:23:45 +0000 |
commit | 2f1db1facab89cd2eda64441f9b730a3831f5746 (patch) | |
tree | 85afd6f51fae791905b39e7ec5e6d7aa6c79227d /encoder.cc | |
parent | Adding debian version 1.6~pre2-1. (diff) | |
download | lzip-2f1db1facab89cd2eda64441f9b730a3831f5746.tar.xz lzip-2f1db1facab89cd2eda64441f9b730a3831f5746.zip |
Merging upstream version 1.6~pre3.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'encoder.cc')
-rw-r--r-- | encoder.cc | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -47,6 +47,7 @@ Matchfinder::Matchfinder( const int dict_size, const int len_limit, const int ides ) : partial_data_pos( 0 ), + after_size( max_match_len ), pos( 0 ), cyclic_pos( 0 ), stream_pos( 0 ), @@ -55,8 +56,7 @@ Matchfinder::Matchfinder( const int dict_size, const int len_limit, prev_positions( new int32_t[num_prev_positions] ), at_stream_end( false ) { - const int buffer_size_limit = ( 2 * dict_size ) + - max_num_trials + max_match_len; + const int buffer_size_limit = ( 2 * dict_size ) + max_num_trials + after_size; buffer_size = std::max( 65536, dict_size ); buffer = (uint8_t *)std::malloc( buffer_size ); if( !buffer ) throw std::bad_alloc(); @@ -72,7 +72,7 @@ Matchfinder::Matchfinder( const int dict_size, const int len_limit, dictionary_size_ = std::max( min_dictionary_size, stream_pos ); else dictionary_size_ = dict_size; pos_limit = buffer_size; - if( !at_stream_end ) pos_limit -= max_match_len; + if( !at_stream_end ) pos_limit -= after_size; prev_pos_tree = new int32_t[2*dictionary_size_]; for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1; } @@ -96,6 +96,7 @@ bool Matchfinder::move_pos() throw() if( ++cyclic_pos >= dictionary_size_ ) cyclic_pos = 0; if( ++pos >= pos_limit ) { + if( pos > stream_pos ) { pos = stream_pos; return false; } if( !at_stream_end ) { const int offset = pos - dictionary_size_ - max_num_trials; @@ -110,7 +111,6 @@ bool Matchfinder::move_pos() throw() if( prev_pos_tree[i] >= 0 ) prev_pos_tree[i] -= offset; return read_block(); } - else if( pos > stream_pos ) { pos = stream_pos; return false; } } return true; } @@ -456,7 +456,7 @@ int LZ_encoder::best_pair_sequence( const int reps[num_rep_distances], // End Of Stream mark => (dis == 0xFFFFFFFF, len == min_match_len) -void LZ_encoder::flush( const State & state ) +void LZ_encoder::full_flush( const State & state ) { const int pos_state = ( matchfinder.data_position() ) & pos_state_mask; range_encoder.encode_bit( bm_match[state()][pos_state], 1 ); @@ -515,7 +515,7 @@ bool LZ_encoder::encode_member( const long long member_size ) while( true ) { - if( matchfinder.finished() ) { flush( state ); return true; } + if( matchfinder.finished() ) { full_flush( state ); return true; } if( fill_counter <= 0 ) { fill_distance_prices(); fill_counter = 512; } int ahead = best_pair_sequence( rep_distances, state ); @@ -580,7 +580,7 @@ bool LZ_encoder::encode_member( const long long member_size ) if( range_encoder.member_position() >= member_size_limit ) { if( !matchfinder.dec_pos( ahead ) ) return false; - flush( state ); + full_flush( state ); return true; } if( ahead <= 0 ) break; |