diff options
Diffstat (limited to '')
-rw-r--r-- | lzip.h (renamed from lunzip.h) | 34 |
1 files changed, 26 insertions, 8 deletions
@@ -57,7 +57,7 @@ enum { dis_slot_bits = 6, start_dis_model = 4, end_dis_model = 14, - modeled_distances = 1 << (end_dis_model / 2), + modeled_distances = 1 << (end_dis_model / 2), /* 128 */ dis_align_bits = 4, dis_align_size = 1 << dis_align_bits, @@ -94,6 +94,24 @@ static inline void Bm_init( Bit_model * const probability ) static inline void Bm_array_init( Bit_model * const p, const int size ) { int i = 0; while( i < size ) p[i++] = bit_model_total / 2; } +struct Len_model + { + 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 Lm_init( struct Len_model * const lm ) + { + Bm_init( &lm->choice1 ); + Bm_init( &lm->choice2 ); + Bm_array_init( lm->bm_low[0], pos_states * len_low_symbols ); + Bm_array_init( lm->bm_mid[0], pos_states * len_mid_symbols ); + Bm_array_init( lm->bm_high, len_high_symbols ); + } + struct Pretty_print { @@ -138,11 +156,11 @@ static inline void CRC32_init( void ) } } -static inline void CRC32_update_byte( uint32_t * crc, const uint8_t byte ) +static inline void CRC32_update_byte( uint32_t * const crc, const uint8_t byte ) { *crc = crc32[(*crc^byte)&0xFF] ^ ( *crc >> 8 ); } -static inline void CRC32_update_buf( uint32_t * crc, const uint8_t * const buffer, - const int size ) +static inline void CRC32_update_buf( uint32_t * const crc, + const uint8_t * const buffer, const int size ) { int i; for( i = 0; i < size; ++i ) @@ -177,11 +195,11 @@ static inline uint8_t Fh_version( const File_header data ) static inline bool Fh_verify_version( const File_header data ) { return ( data[4] <= 1 ); } -static inline int Fh_get_dictionary_size( const File_header data ) +static inline unsigned Fh_get_dictionary_size( const File_header data ) { - int sz = ( 1 << ( data[5] & 0x1F ) ); - if( sz > min_dictionary_size && sz <= max_dictionary_size ) - sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 0x07 ); + unsigned sz = ( 1 << ( data[5] & 0x1F ) ); + if( sz > min_dictionary_size ) + sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 ); return sz; } |