Rizin
unix-like reverse engineering framework and cli tools
price.h File Reference

Probability price calculation. More...

Go to the source code of this file.

Macros

#define RC_MOVE_REDUCING_BITS   4
 
#define RC_BIT_PRICE_SHIFT_BITS   4
 
#define RC_PRICE_TABLE_SIZE   (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS)
 
#define RC_INFINITY_PRICE   (UINT32_C(1) << 30)
 

Functions

static uint32_t rc_bit_price (const probability prob, const uint32_t bit)
 
static uint32_t rc_bit_0_price (const probability prob)
 
static uint32_t rc_bit_1_price (const probability prob)
 
static uint32_t rc_bittree_price (const probability *const probs, const uint32_t bit_levels, uint32_t symbol)
 
static uint32_t rc_bittree_reverse_price (const probability *const probs, uint32_t bit_levels, uint32_t symbol)
 
static uint32_t rc_direct_price (const uint32_t bits)
 

Variables

const uint8_t lzma_rc_prices [RC_PRICE_TABLE_SIZE]
 Lookup table for the inline functions defined in this file. More...
 

Detailed Description

Probability price calculation.

Definition in file price.h.

Macro Definition Documentation

◆ RC_BIT_PRICE_SHIFT_BITS

#define RC_BIT_PRICE_SHIFT_BITS   4

Definition at line 18 of file price.h.

◆ RC_INFINITY_PRICE

#define RC_INFINITY_PRICE   (UINT32_C(1) << 30)

Definition at line 21 of file price.h.

◆ RC_MOVE_REDUCING_BITS

#define RC_MOVE_REDUCING_BITS   4

Definition at line 17 of file price.h.

◆ RC_PRICE_TABLE_SIZE

#define RC_PRICE_TABLE_SIZE   (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS)

Definition at line 19 of file price.h.

Function Documentation

◆ rc_bit_0_price()

static uint32_t rc_bit_0_price ( const probability  prob)
inlinestatic

Definition at line 37 of file price.h.

38 {
39  return lzma_rc_prices[prob >> RC_MOVE_REDUCING_BITS];
40 }
#define RC_MOVE_REDUCING_BITS
Definition: price.h:17
const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE]
Lookup table for the inline functions defined in this file.
Definition: price_table.c:5

References lzma_rc_prices, and RC_MOVE_REDUCING_BITS.

Referenced by get_pure_rep_price(), get_short_rep_price(), helper1(), helper2(), and length_update_prices().

◆ rc_bit_1_price()

static uint32_t rc_bit_1_price ( const probability  prob)
inlinestatic

Definition at line 44 of file price.h.

45 {
46  return lzma_rc_prices[(prob ^ (RC_BIT_MODEL_TOTAL - 1))
48 }
#define RC_BIT_MODEL_TOTAL
Definition: range_common.h:28

References lzma_rc_prices, RC_BIT_MODEL_TOTAL, and RC_MOVE_REDUCING_BITS.

Referenced by get_pure_rep_price(), helper1(), helper2(), and length_update_prices().

◆ rc_bit_price()

static uint32_t rc_bit_price ( const probability  prob,
const uint32_t  bit 
)
inlinestatic

Definition at line 29 of file price.h.

30 {
31  return lzma_rc_prices[(prob ^ ((UINT32_C(0) - bit)
33 }
RzCryptoSelector bit
Definition: crypto.c:16
#define UINT32_C(val)

References bit, lzma_rc_prices, RC_BIT_MODEL_TOTAL, RC_MOVE_REDUCING_BITS, and UINT32_C.

Referenced by get_literal_price(), get_pure_rep_price(), rc_bittree_price(), and rc_bittree_reverse_price().

◆ rc_bittree_price()

static uint32_t rc_bittree_price ( const probability *const  probs,
const uint32_t  bit_levels,
uint32_t  symbol 
)
inlinestatic

Definition at line 52 of file price.h.

54 {
55  uint32_t price = 0;
56  symbol += UINT32_C(1) << bit_levels;
57 
58  do {
59  const uint32_t bit = symbol & 1;
60  symbol >>= 1;
61  price += rc_bit_price(probs[symbol], bit);
62  } while (symbol != 1);
63 
64  return price;
65 }
static uint32_t rc_bit_price(const probability prob, const uint32_t bit)
Definition: price.h:29
unsigned int uint32_t
Definition: sftypes.h:29

References bit, rc_bit_price(), and UINT32_C.

Referenced by fill_dist_prices(), get_literal_price(), and length_update_prices().

◆ rc_bittree_reverse_price()

static uint32_t rc_bittree_reverse_price ( const probability *const  probs,
uint32_t  bit_levels,
uint32_t  symbol 
)
inlinestatic

Definition at line 69 of file price.h.

71 {
72  uint32_t price = 0;
73  uint32_t model_index = 1;
74 
75  do {
76  const uint32_t bit = symbol & 1;
77  symbol >>= 1;
78  price += rc_bit_price(probs[model_index], bit);
79  model_index = (model_index << 1) + bit;
80  } while (--bit_levels != 0);
81 
82  return price;
83 }

References bit, and rc_bit_price().

Referenced by fill_align_prices(), and fill_dist_prices().

◆ rc_direct_price()

static uint32_t rc_direct_price ( const uint32_t  bits)
inlinestatic

Definition at line 87 of file price.h.

88 {
89  return bits << RC_BIT_PRICE_SHIFT_BITS;
90 }
int bits(struct state *s, int need)
Definition: blast.c:72
#define RC_BIT_PRICE_SHIFT_BITS
Definition: price.h:18

References bits(), and RC_BIT_PRICE_SHIFT_BITS.

Referenced by fill_dist_prices().

Variable Documentation

◆ lzma_rc_prices

const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE]
extern

Lookup table for the inline functions defined in this file.

Definition at line 5 of file price_table.c.

Referenced by print_price_table(), rc_bit_0_price(), rc_bit_1_price(), and rc_bit_price().