"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lzip.h" between
lzlib-1.11.tar.lz and lzlib-1.12-rc1.tar.lz

About: Lzlib is a data compression library providing in-memory LZMA compression and decompression functions using the lzip format. Release candidate.

lzip.h  (lzlib-1.11.tar.lz):lzip.h  (lzlib-1.12-rc1.tar.lz)
/* Lzlib - Compression library for the lzip format /* Lzlib - Compression library for the lzip format
Copyright (C) 2009-2019 Antonio Diaz Diaz. Copyright (C) 2009-2020 Antonio Diaz Diaz.
This library is free software. Redistribution and use in source and This library is free software. Redistribution and use in source and
binary forms, with or without modification, are permitted provided binary forms, with or without modification, are permitted provided
that the following conditions are met: that the following conditions are met:
1. Redistributions of source code must retain the above copyright 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer. notice, this list of conditions, and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright 2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the notice, this list of conditions, and the following disclaimer in the
documentation and/or other materials provided with the distribution. documentation and/or other materials provided with the distribution.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/ */
#ifndef max #ifndef max
#define max(x,y) ((x) >= (y) ? (x) : (y)) #define max(x,y) ((x) >= (y) ? (x) : (y))
#endif #endif
#ifndef min #ifndef min
#define min(x,y) ((x) <= (y) ? (x) : (y)) #define min(x,y) ((x) <= (y) ? (x) : (y))
#endif #endif
typedef int State; typedef int State;
skipping to change at line 85 skipping to change at line 85
max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols, max_len_symbols = len_low_symbols + len_mid_symbols + len_high_symbols,
min_match_len = 2, /* must be 2 */ min_match_len = 2, /* must be 2 */
max_match_len = min_match_len + max_len_symbols - 1, /* 273 */ max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
min_match_len_limit = 5 }; min_match_len_limit = 5 };
static inline int get_len_state( const int len ) static inline int get_len_state( const int len )
{ return min( len - min_match_len, len_states - 1 ); } { return min( len - min_match_len, len_states - 1 ); }
static inline int get_lit_state( const uint8_t prev_byte ) static inline int get_lit_state( const uint8_t prev_byte )
{ return ( prev_byte >> ( 8 - literal_context_bits ) ); } { return prev_byte >> ( 8 - literal_context_bits ); }
enum { bit_model_move_bits = 5, enum { bit_model_move_bits = 5,
bit_model_total_bits = 11, bit_model_total_bits = 11,
bit_model_total = 1 << bit_model_total_bits }; bit_model_total = 1 << bit_model_total_bits };
typedef int Bit_model; typedef int Bit_model;
static inline void Bm_init( Bit_model * const probability ) static inline void Bm_init( Bit_model * const probability )
{ *probability = bit_model_total / 2; } { *probability = bit_model_total / 2; }
skipping to change at line 193 skipping to change at line 193
{ {
int bits = 0; int bits = 0;
while( value > 0 ) { value >>= 1; ++bits; } while( value > 0 ) { value >>= 1; ++bits; }
return bits; return bits;
} }
static const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */ static const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
typedef uint8_t Lzip_header[6]; /* 0-3 magic bytes */ typedef uint8_t Lzip_header[6]; /* 0-3 magic bytes */
/* 4 version */ /* 4 version */
/* 5 coded_dict_size */ /* 5 coded dictionary size */
enum { Lh_size = 6 }; enum { Lh_size = 6 };
static inline void Lh_set_magic( Lzip_header data ) static inline void Lh_set_magic( Lzip_header data )
{ memcpy( data, lzip_magic, 4 ); data[4] = 1; } { memcpy( data, lzip_magic, 4 ); data[4] = 1; }
static inline bool Lh_verify_magic( const Lzip_header data ) static inline bool Lh_verify_magic( const Lzip_header data )
{ return ( memcmp( data, lzip_magic, 4 ) == 0 ); } { return ( memcmp( data, lzip_magic, 4 ) == 0 ); }
/* detect (truncated) header */ /* detect (truncated) header */
static inline bool Lh_verify_prefix( const Lzip_header data, const int sz ) static inline bool Lh_verify_prefix( const Lzip_header data, const int sz )
skipping to change at line 251 skipping to change at line 251
unsigned i; unsigned i;
for( i = 7; i >= 1; --i ) for( i = 7; i >= 1; --i )
if( base_size - ( i * fraction ) >= sz ) if( base_size - ( i * fraction ) >= sz )
{ data[5] |= ( i << 5 ); break; } { data[5] |= ( i << 5 ); break; }
} }
return true; return true;
} }
static inline bool Lh_verify( const Lzip_header data ) static inline bool Lh_verify( const Lzip_header data )
{ {
if( Lh_verify_magic( data ) && Lh_verify_version( data ) ) return Lh_verify_magic( data ) && Lh_verify_version( data ) &&
return isvalid_ds( Lh_get_dictionary_size( data ) ); isvalid_ds( Lh_get_dictionary_size( data ) );
return false;
} }
typedef uint8_t Lzip_trailer[20]; typedef uint8_t Lzip_trailer[20];
/* 0-3 CRC32 of the uncompressed data */ /* 0-3 CRC32 of the uncompressed data */
/* 4-11 size of the uncompressed data */ /* 4-11 size of the uncompressed data */
/* 12-19 member size including header and trailer */ /* 12-19 member size including header and trailer */
enum { Lt_size = 20 }; enum { Lt_size = 20 };
static inline unsigned Lt_get_data_crc( const Lzip_trailer data ) static inline unsigned Lt_get_data_crc( const Lzip_trailer data )
{ {
 End of changes. 5 change blocks. 
21 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)