summaryrefslogtreecommitdiffstats
path: root/encoder.h
diff options
context:
space:
mode:
Diffstat (limited to 'encoder.h')
-rw-r--r--encoder.h29
1 files changed, 17 insertions, 12 deletions
diff --git a/encoder.h b/encoder.h
index daaf10b..e7a6481 100644
--- a/encoder.h
+++ b/encoder.h
@@ -393,7 +393,10 @@ static inline void Lee_update_prices( struct Len_encoder * const len_encoder,
pps[len] = tmp + price0( len_encoder->choice2 ) +
price_symbol( len_encoder->bm_mid[pos_state], len - len_low_symbols, len_mid_bits );
for( ; len < len_encoder->len_symbols; ++len )
- pps[len] = tmp + price1( len_encoder->choice2 ) +
+ /* using 4 slots per value makes "Lee_price" faster */
+ len_encoder->prices[3][len] = len_encoder->prices[2][len] =
+ len_encoder->prices[1][len] = len_encoder->prices[0][len] =
+ tmp + price1( len_encoder->choice2 ) +
price_symbol( len_encoder->bm_high, len - len_low_symbols - len_mid_symbols, len_high_bits );
len_encoder->counters[pos_state] = len_encoder->len_symbols;
}
@@ -430,7 +433,7 @@ struct Literal_encoder
Bit_model bm_literal[1<<literal_context_bits][0x300];
};
-static inline int Lie_state( const int prev_byte )
+static inline int Lie_state( const uint8_t prev_byte )
{ return ( prev_byte >> ( 8 - literal_context_bits ) ); }
static inline void Lie_init( struct Literal_encoder * const literal_encoder )
@@ -558,22 +561,24 @@ static inline int LZe_price_rep( struct LZ_encoder * const encoder, const int re
return price;
}
+static inline int LZe_price_dis( struct LZ_encoder * const encoder,
+ const int dis, const int dis_state )
+ {
+ if( dis < modeled_distances )
+ return encoder->dis_prices[dis_state][dis];
+ else
+ return encoder->dis_slot_prices[dis_state][get_slot( dis )] +
+ encoder->align_prices[dis & (dis_align_size - 1)];
+ }
+
static inline int LZe_price_pair( struct LZ_encoder * const encoder,
const int dis, const int len,
const int pos_state )
{
- const int dis_state = get_dis_state( len );
- int price;
-
if( len <= min_match_len && dis >= modeled_distances )
return infinite_price;
- price = Lee_price( &encoder->len_encoder, len, pos_state );
- if( dis < modeled_distances )
- price += encoder->dis_prices[dis_state][dis];
- else
- price += encoder->dis_slot_prices[dis_state][get_slot( dis )] +
- encoder->align_prices[dis & (dis_align_size - 1)];
- return price;
+ return Lee_price( &encoder->len_encoder, len, pos_state ) +
+ LZe_price_dis( encoder, dis, get_dis_state( len ) );
}
static inline void LZe_encode_pair( struct LZ_encoder * const encoder,