diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:47:56 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-07 07:47:56 +0000 |
commit | 1f98801df36334e9e0d80e3db19247a5c65c9bf4 (patch) | |
tree | 89834a124bab1d1fddc206946271a648ba4352d4 /encoder.h | |
parent | Adding upstream version 1.7. (diff) | |
download | lzip-1f98801df36334e9e0d80e3db19247a5c65c9bf4.tar.xz lzip-1f98801df36334e9e0d80e3db19247a5c65c9bf4.zip |
Adding upstream version 1.8.upstream/1.8
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'encoder.h')
-rw-r--r-- | encoder.h | 32 |
1 files changed, 14 insertions, 18 deletions
@@ -135,7 +135,11 @@ inline int price_matched( const Bit_model bm[], const int symbol, class Matchfinder { - enum { num_prev_positions4 = 1 << 20, + enum { // bytes to keep in buffer before dictionary + before_size = max_num_trials + 1, + // bytes to keep in buffer after pos + after_size = max_match_len, + num_prev_positions4 = 1 << 20, num_prev_positions3 = 1 << 18, num_prev_positions2 = 1 << 16, num_prev_positions = num_prev_positions4 + num_prev_positions3 + @@ -143,7 +147,6 @@ class Matchfinder long long partial_data_pos; int dictionary_size_; // bytes to keep in buffer before pos - const int after_size; // bytes to keep in buffer after pos int buffer_size; uint8_t * buffer; int pos; @@ -413,7 +416,7 @@ class LZ_encoder { State state; int dis; - int prev_index; + int prev_index; // index of prev trial in trials[] int price; // dual use var; cumulative price, match length int reps[num_rep_distances]; void update( const int d, const int p_i, const int pr ) throw() @@ -473,25 +476,18 @@ class LZ_encoder return price0( bm_rep0[state()] ) + price0( bm_len[state()][pos_state] ); } - int price_rep( const int rep, const int len, const State & state, + int price_rep( const int rep, const State & state, const int pos_state ) const throw() { - int price = rep_match_len_encoder.price( len, pos_state ); - if( rep == 0 ) - { - price += price0( bm_rep0[state()] ); - price += price1( bm_len[state()][pos_state] ); - } + if( rep == 0 ) return price0( bm_rep0[state()] ) + + price1( bm_len[state()][pos_state] ); + int price = price1( bm_rep0[state()] ); + if( rep == 1 ) + price += price0( bm_rep1[state()] ); else { - price += price1( bm_rep0[state()] ); - if( rep == 1 ) - price += price0( bm_rep1[state()] ); - else - { - price += price1( bm_rep1[state()] ); - price += price_bit( bm_rep2[state()], rep - 2 ); - } + price += price1( bm_rep1[state()] ); + price += price_bit( bm_rep2[state()], rep - 2 ); } return price; } |