summaryrefslogtreecommitdiffstats
path: root/decoder.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 /decoder.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 'decoder.h')
-rw-r--r--decoder.h45
1 files changed, 20 insertions, 25 deletions
diff --git a/decoder.h b/decoder.h
index 95c9bab..a8d8eab 100644
--- a/decoder.h
+++ b/decoder.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 { rd_buffer_size = 16384 };
@@ -107,7 +107,7 @@ static inline unsigned Rd_decode( struct Range_decoder * const rdec,
/* symbol <<= 1; */
/* if( rdec->code >= rdec->range ) { rdec->code -= rdec->range; symbol |= 1; } */
bit = ( rdec->code >= rdec->range );
- symbol = ( symbol << 1 ) + bit;
+ symbol <<= 1; symbol += bit;
rdec->code -= rdec->range & ( 0U - bit );
}
return symbol;
@@ -137,8 +137,7 @@ static inline unsigned Rd_decode_bit( struct Range_decoder * const rdec,
static inline unsigned Rd_decode_tree3( struct Range_decoder * const rdec,
Bit_model bm[] )
{
- unsigned symbol = 1;
- symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
+ unsigned symbol = 2 | Rd_decode_bit( rdec, &bm[1] );
symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
return symbol & 7;
@@ -147,8 +146,7 @@ static inline unsigned Rd_decode_tree3( struct Range_decoder * const rdec,
static inline unsigned Rd_decode_tree6( struct Range_decoder * const rdec,
Bit_model bm[] )
{
- unsigned symbol = 1;
- symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
+ unsigned symbol = 2 | Rd_decode_bit( rdec, &bm[1] );
symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
@@ -177,7 +175,7 @@ Rd_decode_tree_reversed( struct Range_decoder * const rdec,
for( i = 0; i < num_bits; ++i )
{
const unsigned bit = Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) + bit;
+ model <<= 1; model += bit;
symbol |= ( bit << i );
}
return symbol;
@@ -187,12 +185,9 @@ static inline unsigned
Rd_decode_tree_reversed4( struct Range_decoder * const rdec, Bit_model bm[] )
{
unsigned symbol = Rd_decode_bit( rdec, &bm[1] );
- unsigned model = 2 + symbol;
- unsigned bit = Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) + bit; symbol |= ( bit << 1 );
- bit = Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) + bit; symbol |= ( bit << 2 );
- symbol |= ( Rd_decode_bit( rdec, &bm[model] ) << 3 );
+ symbol += Rd_decode_bit( rdec, &bm[2+symbol] ) << 1;
+ symbol += Rd_decode_bit( rdec, &bm[4+symbol] ) << 2;
+ symbol += Rd_decode_bit( rdec, &bm[8+symbol] ) << 3;
return symbol;
}
@@ -205,7 +200,7 @@ static inline unsigned Rd_decode_matched( struct Range_decoder * const rdec,
{
const unsigned match_bit = ( match_byte <<= 1 ) & mask;
const unsigned bit = Rd_decode_bit( rdec, &bm[symbol+match_bit+mask] );
- symbol = ( symbol << 1 ) + bit;
+ symbol <<= 1; symbol += bit;
if( symbol > 0xFF ) return symbol & 0xFF;
mask &= ~(match_bit ^ (bit << 8)); /* if( match_bit != bit ) mask = 0; */
}