summaryrefslogtreecommitdiffstats
path: root/decoder.h
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:48:19 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 13:48:19 +0000
commitf84d656826e79b4c73e42656005c34a80c9bff86 (patch)
tree445c47ac2fbbf07c76f30ef998e1ff653a99dd2c /decoder.h
parentAdding upstream version 1.4~rc2. (diff)
downloadlzlib-f84d656826e79b4c73e42656005c34a80c9bff86.tar.xz
lzlib-f84d656826e79b4c73e42656005c34a80c9bff86.zip
Adding upstream version 1.4.upstream/1.4
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'decoder.h')
-rw-r--r--decoder.h71
1 files changed, 26 insertions, 45 deletions
diff --git a/decoder.h b/decoder.h
index 49e2bef..c8d3786 100644
--- a/decoder.h
+++ b/decoder.h
@@ -216,24 +216,24 @@ static inline int Rd_decode_bit( struct Range_decoder * const rdec,
static inline int Rd_decode_tree( struct Range_decoder * const rdec,
Bit_model bm[], const int num_bits )
{
- int model = 1;
+ int symbol = 1;
int i;
for( i = num_bits; i > 0; --i )
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- return model - (1 << num_bits);
+ symbol = ( symbol << 1 ) | Rd_decode_bit( rdec, &bm[symbol] );
+ return symbol - (1 << num_bits);
}
static inline int Rd_decode_tree6( struct Range_decoder * const rdec,
Bit_model bm[] )
{
- int model = 1;
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- model = ( model << 1 ) | Rd_decode_bit( rdec, &bm[model] );
- return model - (1 << 6);
+ int symbol = 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] );
+ 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] );
+ return symbol - (1 << 6);
}
static inline int Rd_decode_tree_reversed( struct Range_decoder * const rdec,
@@ -289,36 +289,17 @@ static inline int Rd_decode_matched( struct Range_decoder * const rdec,
return symbol - 0x100;
}
-
-struct Len_decoder
- {
- Bit_model choice1;
- Bit_model choice2;
- Bit_model bm_low[pos_states][len_low_symbols];
- Bit_model bm_mid[pos_states][len_mid_symbols];
- Bit_model bm_high[len_high_symbols];
- };
-
-static inline void Led_init( struct Len_decoder * const len_decoder )
- {
- Bm_init( &len_decoder->choice1 );
- Bm_init( &len_decoder->choice2 );
- Bm_array_init( len_decoder->bm_low[0], pos_states * len_low_symbols );
- Bm_array_init( len_decoder->bm_mid[0], pos_states * len_mid_symbols );
- Bm_array_init( len_decoder->bm_high, len_high_symbols );
- }
-
-static inline int Led_decode( struct Len_decoder * const len_decoder,
- struct Range_decoder * const rdec,
- const int pos_state )
+static inline int Rd_decode_len( struct Range_decoder * const rdec,
+ struct Len_model * const lm,
+ const int pos_state )
{
- if( Rd_decode_bit( rdec, &len_decoder->choice1 ) == 0 )
- return Rd_decode_tree( rdec, len_decoder->bm_low[pos_state], len_low_bits );
- if( Rd_decode_bit( rdec, &len_decoder->choice2 ) == 0 )
+ if( Rd_decode_bit( rdec, &lm->choice1 ) == 0 )
+ return Rd_decode_tree( rdec, lm->bm_low[pos_state], len_low_bits );
+ if( Rd_decode_bit( rdec, &lm->choice2 ) == 0 )
return len_low_symbols +
- Rd_decode_tree( rdec, len_decoder->bm_mid[pos_state], len_mid_bits );
+ Rd_decode_tree( rdec, lm->bm_mid[pos_state], len_mid_bits );
return len_low_symbols + len_mid_symbols +
- Rd_decode_tree( rdec, len_decoder->bm_high, len_high_bits );
+ Rd_decode_tree( rdec, lm->bm_high, len_high_bits );
}
@@ -350,9 +331,9 @@ struct LZ_decoder
Bit_model bm_dis[modeled_distances-end_dis_model];
Bit_model bm_align[dis_align_size];
- struct Range_decoder * range_decoder;
- struct Len_decoder len_decoder;
- struct Len_decoder rep_match_len_decoder;
+ struct Range_decoder * rdec;
+ struct Len_model match_len_model;
+ struct Len_model rep_len_model;
};
static inline bool LZd_enough_free_bytes( const struct LZ_decoder * const decoder )
@@ -403,7 +384,7 @@ static inline void LZd_copy_block( struct LZ_decoder * const decoder,
static inline bool LZd_init( struct LZ_decoder * const decoder,
const File_header header,
- struct Range_decoder * const rdec )
+ struct Range_decoder * const rde )
{
decoder->dictionary_size = Fh_get_dictionary_size( header );
if( !Cb_init( &decoder->cb, max( 65536, decoder->dictionary_size ) + lzd_min_free_bytes ) )
@@ -430,9 +411,9 @@ static inline bool LZd_init( struct LZ_decoder * const decoder,
Bm_array_init( decoder->bm_dis, modeled_distances - end_dis_model );
Bm_array_init( decoder->bm_align, dis_align_size );
- decoder->range_decoder = rdec;
- Led_init( &decoder->len_decoder );
- Led_init( &decoder->rep_match_len_decoder );
+ decoder->rdec = rde;
+ Lm_init( &decoder->match_len_model );
+ Lm_init( &decoder->rep_len_model );
decoder->cb.buffer[decoder->cb.buffer_size-1] = 0; /* prev_byte of first_byte */
return true;
}