From 54878fa0cdaa5af70dae4d9eb872e990e69a5022 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 25 Jan 2021 13:43:58 +0100 Subject: Merging upstream version 1.12. Signed-off-by: Daniel Baumann --- encoder_base.h | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'encoder_base.h') diff --git a/encoder_base.h b/encoder_base.h index 0186dc8..64f147b 100644 --- a/encoder_base.h +++ b/encoder_base.h @@ -1,18 +1,18 @@ -/* Clzip - LZMA lossless data compressor - Copyright (C) 2010-2019 Antonio Diaz Diaz. +/* Clzip - LZMA lossless data compressor + Copyright (C) 2010-2021 Antonio Diaz Diaz. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ enum { price_shift_bits = 6, @@ -133,7 +133,7 @@ static inline int price_symbol_reversed( const Bit_model bm[], int symbol, const bool bit = symbol & 1; symbol >>= 1; price += price_bit( bm[model], bit ); - model = ( model << 1 ) | bit; + model <<= 1; model |= bit; } return price; } @@ -333,28 +333,30 @@ static inline void Re_encode_bit( struct Range_encoder * const renc, static inline void Re_encode_tree3( struct Range_encoder * const renc, Bit_model bm[], const int symbol ) { - int model = 1; + int model; bool bit = ( symbol >> 2 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[1], bit ); + model = 2 | bit; bit = ( symbol >> 1 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit; Re_encode_bit( renc, &bm[model], symbol & 1 ); } static inline void Re_encode_tree6( struct Range_encoder * const renc, Bit_model bm[], const unsigned symbol ) { - int model = 1; + int model; bool bit = ( symbol >> 5 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[1], bit ); + model = 2 | bit; bit = ( symbol >> 4 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit; bit = ( symbol >> 3 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit; bit = ( symbol >> 2 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit; bit = ( symbol >> 1 ) & 1; - Re_encode_bit( renc, &bm[model], bit ); model = ( model << 1 ) | bit; + Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit; Re_encode_bit( renc, &bm[model], symbol & 1 ); } @@ -367,7 +369,7 @@ static inline void Re_encode_tree8( struct Range_encoder * const renc, { const bool bit = ( symbol >> i ) & 1; Re_encode_bit( renc, &bm[model], bit ); - model = ( model << 1 ) | bit; + model <<= 1; model |= bit; } } @@ -381,7 +383,7 @@ static inline void Re_encode_tree_reversed( struct Range_encoder * const renc, const bool bit = symbol & 1; symbol >>= 1; Re_encode_bit( renc, &bm[model], bit ); - model = ( model << 1 ) | bit; + model <<= 1; model |= bit; } } -- cgit v1.2.3