summaryrefslogtreecommitdiffstats
path: root/encoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'encoder.h')
-rw-r--r--encoder.h25
1 files changed, 15 insertions, 10 deletions
diff --git a/encoder.h b/encoder.h
index eecdae4..6d9036d 100644
--- a/encoder.h
+++ b/encoder.h
@@ -383,7 +383,9 @@ class Len_encoder
pps[len] = tmp + price0( choice2 ) +
price_symbol( bm_mid[pos_state], len - len_low_symbols, len_mid_bits );
for( ; len < len_symbols; ++len )
- pps[len] = tmp + price1( choice2 ) +
+ // using 4 slots per value makes "price" faster
+ prices[3][len] = prices[2][len] = prices[1][len] = prices[0][len] =
+ tmp + price1( choice2 ) +
price_symbol( bm_high, len - len_low_symbols - len_mid_symbols, len_high_bits );
counters[pos_state] = len_symbols;
}
@@ -407,7 +409,7 @@ class Literal_encoder
{
Bit_model bm_literal[1<<literal_context_bits][0x300];
- int lstate( const int prev_byte ) const throw()
+ int lstate( const uint8_t prev_byte ) const throw()
{ return ( prev_byte >> ( 8 - literal_context_bits ) ); }
public:
@@ -522,18 +524,21 @@ class LZ_encoder
return price;
}
+ int price_dis( const int dis, const int dis_state ) const throw()
+ {
+ if( dis < modeled_distances )
+ return dis_prices[dis_state][dis];
+ else
+ return dis_slot_prices[dis_state][dis_slots[dis]] +
+ align_prices[dis & (dis_align_size - 1)];
+ }
+
int price_pair( const int dis, const int len, const int pos_state ) const throw()
{
if( len <= min_match_len && dis >= modeled_distances )
return infinite_price;
- int price = len_encoder.price( len, pos_state );
- const int dis_state = get_dis_state( len );
- if( dis < modeled_distances )
- price += dis_prices[dis_state][dis];
- else
- price += dis_slot_prices[dis_state][dis_slots[dis]] +
- align_prices[dis & (dis_align_size - 1)];
- return price;
+ return len_encoder.price( len, pos_state ) +
+ price_dis( dis, get_dis_state( len ) );
}
void encode_pair( const uint32_t dis, const int len, const int pos_state ) throw()