From 6048988437e5d1409f10c51ed7292b322d2974d6 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Thu, 6 Aug 2015 23:35:43 -0500 Subject: [PATCH] lzms_decompress.c: move range normalization upwards --- src/lzms_decompress.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lzms_decompress.c b/src/lzms_decompress.c index 47cd6561..070cdb64 100644 --- a/src/lzms_decompress.c +++ b/src/lzms_decompress.c @@ -492,10 +492,6 @@ lzms_decode_bit(struct lzms_range_decoder *rd, u32 *state_p, u32 num_states, /* Load the probability entry corresponding to the current state. */ prob_entry = &probs[*state_p]; - /* Get the probability (out of LZMS_PROBABILITY_DENOMINATOR) that the - * next bit is 0. */ - prob = lzms_get_probability(prob_entry); - /* Normalize if needed. */ if (rd->range <= 0xffff) { rd->range <<= 16; @@ -504,6 +500,10 @@ lzms_decode_bit(struct lzms_range_decoder *rd, u32 *state_p, u32 num_states, rd->code |= le16_to_cpu(*rd->next++); } + /* Get the probability (out of LZMS_PROBABILITY_DENOMINATOR) that the + * next bit is 0. */ + prob = lzms_get_probability(prob_entry); + /* Based on the probability, calculate the bound between the 0-bit * region and the 1-bit region of the range. */ bound = (rd->range >> LZMS_PROBABILITY_BITS) * prob; -- 2.43.0