diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-01-15 08:36:25 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-01-15 08:36:25 +0200 |
commit | 9f9b1983013048f2142e8bc7e240149d2687bedc (patch) | |
tree | cee2139cc8e5de11d0f5baca7aec714624e596b7 /src/liblzma/lzma | |
parent | Fix CRC code in case --enable-small is used. (diff) | |
download | xz-9f9b1983013048f2142e8bc7e240149d2687bedc.tar.xz |
Convert bittree_get_price() and bittree_reverse_get_price()
from macros to inline functions.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/lzma/lzma_encoder.c | 19 | ||||
-rw-r--r-- | src/liblzma/lzma/lzma_encoder_getoptimum.c | 16 |
2 files changed, 13 insertions, 22 deletions
diff --git a/src/liblzma/lzma/lzma_encoder.c b/src/liblzma/lzma/lzma_encoder.c index 2c46b0c5..f68633b8 100644 --- a/src/liblzma/lzma/lzma_encoder.c +++ b/src/liblzma/lzma/lzma_encoder.c @@ -116,23 +116,18 @@ lzma_length_encoder_update_table(lzma_length_encoder *lencoder, uint32_t *prices = lencoder->prices[pos_state]; uint32_t i = 0; - for (i = 0; i < num_symbols && i < LEN_LOW_SYMBOLS; ++i) { - prices[i] = a0; - bittree_get_price(prices[i], lencoder->low[pos_state], + for (i = 0; i < num_symbols && i < LEN_LOW_SYMBOLS; ++i) + prices[i] = a0 + bittree_get_price(lencoder->low[pos_state], LEN_LOW_BITS, i); - } - for (; i < num_symbols && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; ++i) { - prices[i] = b0; - bittree_get_price(prices[i], lencoder->mid[pos_state], + for (; i < num_symbols && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; ++i) + prices[i] = b0 + bittree_get_price(lencoder->mid[pos_state], LEN_MID_BITS, i - LEN_LOW_SYMBOLS); - } - for (; i < num_symbols; ++i) { - prices[i] = b1; - bittree_get_price(prices[i], lencoder->high, LEN_HIGH_BITS, + for (; i < num_symbols; ++i) + prices[i] = b1 + bittree_get_price( + lencoder->high, LEN_HIGH_BITS, i - LEN_LOW_SYMBOLS - LEN_MID_SYMBOLS); - } lencoder->counters[pos_state] = num_symbols; diff --git a/src/liblzma/lzma/lzma_encoder_getoptimum.c b/src/liblzma/lzma/lzma_encoder_getoptimum.c index cdeb3145..b00f5c38 100644 --- a/src/liblzma/lzma/lzma_encoder_getoptimum.c +++ b/src/liblzma/lzma/lzma_encoder_getoptimum.c @@ -111,8 +111,7 @@ fill_distances_prices(lzma_coder *coder) const uint32_t pos_slot = get_pos_slot(i); const uint32_t footer_bits = ((pos_slot >> 1) - 1); const uint32_t base = (2 | (pos_slot & 1)) << footer_bits; - temp_prices[i] = 0; - bittree_reverse_get_price(temp_prices[i], + temp_prices[i] = bittree_reverse_get_price( coder->pos_encoders + base - pos_slot - 1, footer_bits, i - base); } @@ -129,8 +128,7 @@ fill_distances_prices(lzma_coder *coder) for (uint32_t pos_slot = 0; pos_slot < dist_table_size; ++pos_slot) { - pos_slot_prices[pos_slot] = 0; - bittree_get_price(pos_slot_prices[pos_slot], encoder, + pos_slot_prices[pos_slot] = bittree_get_price(encoder, POS_SLOT_BITS, pos_slot); } @@ -162,14 +160,12 @@ fill_distances_prices(lzma_coder *coder) static void fill_align_prices(lzma_coder *coder) { - for (uint32_t i = 0; i < ALIGN_TABLE_SIZE; ++i) { - uint32_t tmp = 0; - bittree_reverse_get_price(tmp, coder->pos_align_encoder, - ALIGN_BITS, i); - coder->align_prices[i] = tmp; - } + for (uint32_t i = 0; i < ALIGN_TABLE_SIZE; ++i) + coder->align_prices[i] = bittree_reverse_get_price( + coder->pos_align_encoder, ALIGN_BITS, i); coder->align_price_count = 0; + return; } |