summaryrefslogtreecommitdiffstats
path: root/encoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:45:24 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:45:24 +0000
commit53d61f05fc82d86829666485c0012780c1c93da2 (patch)
treeec05873b6fec3fd5f57543449a1a459ccd5190f0 /encoder.h
parentAdding upstream version 1.1. (diff)
downloadlzlib-53d61f05fc82d86829666485c0012780c1c93da2.tar.xz
lzlib-53d61f05fc82d86829666485c0012780c1c93da2.zip
Adding upstream version 1.2.upstream/1.2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
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()