summaryrefslogtreecommitdiffstats
path: root/encoder.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 09:32:10 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 09:32:10 +0000
commit48f82c742fbb20fd624a466f0f3dcbc9a9679768 (patch)
tree694e61fe55b10051d97cd89a73cd70de544d85c5 /encoder.cc
parentAdding debian version 1.13~rc2-1. (diff)
downloadlzip-48f82c742fbb20fd624a466f0f3dcbc9a9679768.tar.xz
lzip-48f82c742fbb20fd624a466f0f3dcbc9a9679768.zip
Merging upstream version 1.13.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'encoder.cc')
-rw-r--r--encoder.cc33
1 files changed, 11 insertions, 22 deletions
diff --git a/encoder.cc b/encoder.cc
index 67e9d95..56820b5 100644
--- a/encoder.cc
+++ b/encoder.cc
@@ -84,6 +84,7 @@ Matchfinder_base::Matchfinder_base( const int before, const int dict_size,
stream_pos( 0 ),
at_stream_end( false )
{
+ for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1;
const int buffer_size_limit =
( dict_size * dict_factor ) + before_size + after_size;
buffer_size = std::max( 65536, dict_size );
@@ -103,7 +104,6 @@ Matchfinder_base::Matchfinder_base( const int before, const int dict_size,
else dictionary_size_ = dict_size;
pos_limit = buffer_size;
if( !at_stream_end ) pos_limit -= after_size;
- for( int i = 0; i < num_prev_positions; ++i ) prev_positions[i] = -1;
pos_array_size = pos_array_factor * dictionary_size_;
pos_array = new( std::nothrow ) int32_t[pos_array_size];
if( !pos_array )
@@ -124,17 +124,7 @@ void Matchfinder_base::reset()
}
-bool Matchfinder::dec_pos( const int ahead ) throw()
- {
- if( ahead < 0 || pos < ahead ) return false;
- pos -= ahead;
- cyclic_pos -= ahead;
- if( cyclic_pos < 0 ) cyclic_pos += dictionary_size_;
- return true;
- }
-
-
-int Matchfinder::longest_match_len( int * const distances ) throw()
+int Matchfinder::longest_match_len( int * const distances )
{
int len_limit = match_len_limit_;
if( len_limit > available_bytes() )
@@ -264,7 +254,7 @@ void Len_encoder::encode( Range_encoder & range_encoder, int symbol,
// End Of Stream mark => (dis == 0xFFFFFFFFU, len == min_match_len)
void LZ_encoder_base::full_flush( const long long data_position,
- const State & state )
+ const State state )
{
const int pos_state = data_position & pos_state_mask;
range_encoder.encode_bit( bm_match[state()][pos_state], 1 );
@@ -281,7 +271,7 @@ void LZ_encoder_base::full_flush( const long long data_position,
}
-void LZ_encoder::fill_align_prices() throw()
+void LZ_encoder::fill_align_prices()
{
for( int i = 0; i < dis_align_size; ++i )
align_prices[i] = price_symbol_reversed( bm_align, i, dis_align_bits );
@@ -289,7 +279,7 @@ void LZ_encoder::fill_align_prices() throw()
}
-void LZ_encoder::fill_distance_prices() throw()
+void LZ_encoder::fill_distance_prices()
{
for( int dis = start_dis_model; dis < modeled_distances; ++dis )
{
@@ -327,7 +317,7 @@ void LZ_encoder::fill_distance_prices() throw()
// trials[0]..trials[retval-1] contain the steps to encode.
// ( trials[0].dis == -1 && trials[0].price == 1 ) means literal.
int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
- const State & state )
+ const State state )
{
int main_len;
if( longest_match_found > 0 ) // from previous call
@@ -381,7 +371,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
const int rep_match_price = match_price + price1( bm_rep[state()] );
if( match_byte == cur_byte )
- trials[1].update( 0, 0, rep_match_price + price_rep_len1( state, pos_state ) );
+ trials[1].update( 0, 0, rep_match_price + price_rep_len1( pos_state, state ) );
if( main_len < min_match_len )
{
@@ -411,11 +401,10 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
for( int rep = 0; rep < num_rep_distances; ++rep )
{
- const int price = rep_match_price +
- price_rep( rep, state, pos_state );
+ const int price = rep_match_price + price_rep( rep, pos_state, state );
for( int len = min_match_len; len <= replens[rep]; ++len )
trials[len].update( rep, 0, price +
- rep_match_len_encoder.price( len, pos_state ) );
+ rep_match_len_encoder.price( len, pos_state ) );
}
}
@@ -480,7 +469,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
if( match_byte == cur_byte && next_trial.dis != 0 )
next_trial.update( 0, cur, rep_match_price +
- price_rep_len1( cur_trial.state, pos_state ) );
+ price_rep_len1( pos_state, cur_trial.state ) );
const int len_limit = std::min( std::min( max_num_trials - 1 - cur,
matchfinder.available_bytes() ), matchfinder.match_len_limit() );
@@ -495,7 +484,7 @@ int LZ_encoder::sequence_optimizer( const int reps[num_rep_distances],
if( len >= min_match_len )
{
const int price = rep_match_price +
- price_rep( rep, cur_trial.state, pos_state );
+ price_rep( rep, pos_state, cur_trial.state );
while( num_trials < cur + len )
trials[++num_trials].price = infinite_price;
for( ; len >= min_match_len; --len )