summaryrefslogtreecommitdiffstats
path: root/encoder_base.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 12:43:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-01-25 12:43:54 +0000
commitdc114ed0e55813f66a71a56276bc81db6dfa16f1 (patch)
treed3c0b53871caf5f90bb4397ed72533601bb38f6d /encoder_base.h
parentAdding upstream version 1.11. (diff)
downloadclzip-upstream/1.12.tar.xz
clzip-upstream/1.12.zip
Adding upstream version 1.12.upstream/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;
}
}