summaryrefslogtreecommitdiffstats
path: root/encoder_base.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--encoder_base.h25
1 files changed, 9 insertions, 16 deletions
diff --git a/encoder_base.h b/encoder_base.h
index 64f147b..f47ec48 100644
--- a/encoder_base.h
+++ b/encoder_base.h
@@ -1,5 +1,5 @@
/* Clzip - LZMA lossless data compressor
- Copyright (C) 2010-2021 Antonio Diaz Diaz.
+ Copyright (C) 2010-2022 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
@@ -83,10 +83,9 @@ static inline int price_bit( const Bit_model bm, const bool bit )
static inline int price_symbol3( const Bit_model bm[], int symbol )
{
- int price;
bool bit = symbol & 1;
symbol |= 8; symbol >>= 1;
- price = price_bit( bm[symbol], bit );
+ int price = price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
return price + price_bit( bm[1], symbol & 1 );
}
@@ -94,10 +93,9 @@ static inline int price_symbol3( const Bit_model bm[], int symbol )
static inline int price_symbol6( const Bit_model bm[], unsigned symbol )
{
- int price;
bool bit = symbol & 1;
symbol |= 64; symbol >>= 1;
- price = price_bit( bm[symbol], bit );
+ int price = price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
@@ -108,10 +106,9 @@ static inline int price_symbol6( const Bit_model bm[], unsigned symbol )
static inline int price_symbol8( const Bit_model bm[], int symbol )
{
- int price;
bool bit = symbol & 1;
symbol |= 0x100; symbol >>= 1;
- price = price_bit( bm[symbol], bit );
+ int price = price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
bit = symbol & 1; symbol >>= 1; price += price_bit( bm[symbol], bit );
@@ -307,8 +304,7 @@ static inline void Re_encode( struct Range_encoder * const renc,
{
renc->range >>= 1;
if( symbol & mask ) renc->low += renc->range;
- if( renc->range <= 0x00FFFFFFU )
- { renc->range <<= 8; Re_shift_low( renc ); }
+ if( renc->range <= 0x00FFFFFFU ) { renc->range <<= 8; Re_shift_low( renc ); }
}
}
@@ -333,10 +329,9 @@ 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;
bool bit = ( symbol >> 2 ) & 1;
Re_encode_bit( renc, &bm[1], bit );
- model = 2 | bit;
+ int model = 2 | bit;
bit = ( symbol >> 1 ) & 1;
Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit;
Re_encode_bit( renc, &bm[model], symbol & 1 );
@@ -345,10 +340,9 @@ static inline void Re_encode_tree3( struct Range_encoder * const renc,
static inline void Re_encode_tree6( struct Range_encoder * const renc,
Bit_model bm[], const unsigned symbol )
{
- int model;
bool bit = ( symbol >> 5 ) & 1;
Re_encode_bit( renc, &bm[1], bit );
- model = 2 | bit;
+ int model = 2 | bit;
bit = ( symbol >> 4 ) & 1;
Re_encode_bit( renc, &bm[model], bit ); model <<= 1; model |= bit;
bit = ( symbol >> 3 ) & 1;
@@ -479,8 +473,7 @@ static inline int LZeb_price_matched( const struct LZ_encoder_base * const eb,
static inline void LZeb_encode_literal( struct LZ_encoder_base * const eb,
const uint8_t prev_byte, const uint8_t symbol )
- { Re_encode_tree8( &eb->renc, eb->bm_literal[get_lit_state(prev_byte)],
- symbol ); }
+ { Re_encode_tree8( &eb->renc, eb->bm_literal[get_lit_state(prev_byte)], symbol ); }
static inline void LZeb_encode_matched( struct LZ_encoder_base * const eb,
const uint8_t prev_byte, const uint8_t symbol, const uint8_t match_byte )
@@ -491,8 +484,8 @@ static inline void LZeb_encode_pair( struct LZ_encoder_base * const eb,
const unsigned dis, const int len,
const int pos_state )
{
- const unsigned dis_slot = get_slot( dis );
Re_encode_len( &eb->renc, &eb->match_len_model, len, pos_state );
+ const unsigned dis_slot = get_slot( dis );
Re_encode_tree6( &eb->renc, eb->bm_dis_slot[get_len_state(len)], dis_slot );
if( dis_slot >= start_dis_model )