Coverage Report

Created: 2026-01-20 07:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/xz/src/liblzma/rangecoder/price.h
Line
Count
Source
1
// SPDX-License-Identifier: 0BSD
2
3
///////////////////////////////////////////////////////////////////////////////
4
//
5
/// \file       price.h
6
/// \brief      Probability price calculation
7
//
8
//  Author:     Igor Pavlov
9
//
10
///////////////////////////////////////////////////////////////////////////////
11
12
#ifndef LZMA_PRICE_H
13
#define LZMA_PRICE_H
14
15
16
0
#define RC_MOVE_REDUCING_BITS 4
17
0
#define RC_BIT_PRICE_SHIFT_BITS 4
18
#define RC_PRICE_TABLE_SIZE (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS)
19
20
0
#define RC_INFINITY_PRICE (UINT32_C(1) << 30)
21
22
23
/// Lookup table for the inline functions defined in this file.
24
lzma_attr_visibility_hidden
25
extern const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE];
26
27
28
static inline uint32_t
29
rc_bit_price(const probability prob, const uint32_t bit)
30
0
{
31
0
  return lzma_rc_prices[(prob ^ ((UINT32_C(0) - bit)
32
0
      & (RC_BIT_MODEL_TOTAL - 1))) >> RC_MOVE_REDUCING_BITS];
33
0
}
Unexecuted instantiation: lzma_encoder.c:rc_bit_price
Unexecuted instantiation: lzma_encoder_optimum_fast.c:rc_bit_price
Unexecuted instantiation: lzma_encoder_optimum_normal.c:rc_bit_price
Unexecuted instantiation: price_table.c:rc_bit_price
34
35
36
static inline uint32_t
37
rc_bit_0_price(const probability prob)
38
0
{
39
0
  return lzma_rc_prices[prob >> RC_MOVE_REDUCING_BITS];
40
0
}
Unexecuted instantiation: lzma_encoder.c:rc_bit_0_price
Unexecuted instantiation: lzma_encoder_optimum_fast.c:rc_bit_0_price
Unexecuted instantiation: lzma_encoder_optimum_normal.c:rc_bit_0_price
Unexecuted instantiation: price_table.c:rc_bit_0_price
41
42
43
static inline uint32_t
44
rc_bit_1_price(const probability prob)
45
0
{
46
0
  return lzma_rc_prices[(prob ^ (RC_BIT_MODEL_TOTAL - 1))
47
0
      >> RC_MOVE_REDUCING_BITS];
48
0
}
Unexecuted instantiation: lzma_encoder.c:rc_bit_1_price
Unexecuted instantiation: lzma_encoder_optimum_fast.c:rc_bit_1_price
Unexecuted instantiation: lzma_encoder_optimum_normal.c:rc_bit_1_price
Unexecuted instantiation: price_table.c:rc_bit_1_price
49
50
51
static inline uint32_t
52
rc_bittree_price(const probability *const probs,
53
    const uint32_t bit_levels, uint32_t symbol)
54
0
{
55
0
  uint32_t price = 0;
56
0
  symbol += UINT32_C(1) << bit_levels;
57
58
0
  do {
59
0
    const uint32_t bit = symbol & 1;
60
0
    symbol >>= 1;
61
0
    price += rc_bit_price(probs[symbol], bit);
62
0
  } while (symbol != 1);
63
64
0
  return price;
65
0
}
Unexecuted instantiation: lzma_encoder.c:rc_bittree_price
Unexecuted instantiation: lzma_encoder_optimum_fast.c:rc_bittree_price
Unexecuted instantiation: lzma_encoder_optimum_normal.c:rc_bittree_price
Unexecuted instantiation: price_table.c:rc_bittree_price
66
67
68
static inline uint32_t
69
rc_bittree_reverse_price(const probability *const probs,
70
    uint32_t bit_levels, uint32_t symbol)
71
0
{
72
0
  uint32_t price = 0;
73
0
  uint32_t model_index = 1;
74
75
0
  do {
76
0
    const uint32_t bit = symbol & 1;
77
0
    symbol >>= 1;
78
0
    price += rc_bit_price(probs[model_index], bit);
79
0
    model_index = (model_index << 1) + bit;
80
0
  } while (--bit_levels != 0);
81
82
0
  return price;
83
0
}
Unexecuted instantiation: lzma_encoder.c:rc_bittree_reverse_price
Unexecuted instantiation: lzma_encoder_optimum_fast.c:rc_bittree_reverse_price
Unexecuted instantiation: lzma_encoder_optimum_normal.c:rc_bittree_reverse_price
Unexecuted instantiation: price_table.c:rc_bittree_reverse_price
84
85
86
static inline uint32_t
87
rc_direct_price(const uint32_t bits)
88
0
{
89
0
   return bits << RC_BIT_PRICE_SHIFT_BITS;
90
0
}
Unexecuted instantiation: lzma_encoder.c:rc_direct_price
Unexecuted instantiation: lzma_encoder_optimum_fast.c:rc_direct_price
Unexecuted instantiation: lzma_encoder_optimum_normal.c:rc_direct_price
Unexecuted instantiation: price_table.c:rc_direct_price
91
92
#endif