summaryrefslogtreecommitdiffstats
path: root/encoder_base.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 12:43:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 12:44:09 +0000
commit54878fa0cdaa5af70dae4d9eb872e990e69a5022 (patch)
treef3145508a6054776d4fb7fb7ea973712606f7118 /encoder_base.h
parentReleasing debian version 1.11-9. (diff)
downloadclzip-54878fa0cdaa5af70dae4d9eb872e990e69a5022.tar.xz
clzip-54878fa0cdaa5af70dae4d9eb872e990e69a5022.zip
Merging upstream version 1.12.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'encoder_base.h')
-rw-r--r--encoder_base.h50
1 files changed, 26 insertions, 24 deletions
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 <http://www.gnu.org/licenses/>.
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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;
}
}