1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file range_encoder.c
4 /// \brief Static initializations for the range encoder's prices array
6 // Copyright (C) 1999-2006 Igor Pavlov
7 // Copyright (C) 2007 Lasse Collin
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
19 ///////////////////////////////////////////////////////////////////////////////
21 #include "range_encoder.h"
24 #define NUM_BITS (BIT_MODEL_TOTAL_BITS - MOVE_REDUCING_BITS)
27 uint32_t lzma_rc_prob_prices[BIT_MODEL_TOTAL >> MOVE_REDUCING_BITS];
33 // Initialize lzma_rc_prob_prices[].
34 for (int i = NUM_BITS - 1; i >= 0; --i) {
35 const uint32_t start = 1 << (NUM_BITS - i - 1);
36 const uint32_t end = 1 << (NUM_BITS - i);
38 for (uint32_t j = start; j < end; ++j) {
39 lzma_rc_prob_prices[j] = (i << BIT_PRICE_SHIFT_BITS)
40 + (((end - j) << BIT_PRICE_SHIFT_BITS)
41 >> (NUM_BITS - i - 1));