--- Compress-LZF/lzfP.h 2010/06/01 03:30:34 1.8 +++ Compress-LZF/lzfP.h 2013/08/25 18:13:26 1.9 @@ -1,16 +1,16 @@ /* * Copyright (c) 2000-2007 Marc Alexander Lehmann - * + * * Redistribution and use in source and binary forms, with or without modifica- * tion, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO @@ -49,7 +49,7 @@ * the difference between 15 and 14 is very small * for small blocks (and 14 is usually a bit faster). * For a low-memory/faster configuration, use HLOG == 13; - * For best compression, use 15 or 16 (or more, up to 23). + * For best compression, use 15 or 16 (or more, up to 22). */ #ifndef HLOG # define HLOG 16 @@ -88,7 +88,7 @@ * deterministic/repeatable when the configuration otherwise is the same). */ #ifndef INIT_HTAB -# define INIT_HTAB 0 +# define INIT_HTAB 1 #endif /* @@ -122,11 +122,29 @@ #endif /* + * Whether the target CPU has a slow multiplication. This affects + * the default hash function for the compressor, and enables a slightly + * worse hash function that needs only shifts. + */ +#ifndef MULTIPLICATION_IS_SLOW +# define MULTIPLICATION_IS_SLOW 0 +#endif + +/* + * If defined, then this data type will be used for storing offsets. + * This can be useful if you want to use a huge hashtable, want to + * conserve memory, or both, and your data fits into e.g. 64kb. + * If instead you want to compress data > 4GB, then it's better to + * to "#define LZF_USE_OFFSETS 0" instead. + */ +/*#define LZF_HSLOT unsigned short*/ + +/* * Whether to store pointers or offsets inside the hash table. On * 64 bit architetcures, pointers take up twice as much space, * and might also be slower. Default is to autodetect. */ -/*#define LZF_USER_OFFSETS autodetect */ +/*#define LZF_USE_OFFSETS autodetect */ /*****************************************************************************/ /* nothing should be changed below */ @@ -141,7 +159,7 @@ #endif #ifndef LZF_USE_OFFSETS -# if defined (WIN32) +# ifdef _WIN32 # define LZF_USE_OFFSETS defined(_M_X64) # else # if __cplusplus > 199711L @@ -155,26 +173,27 @@ typedef unsigned char u8; -#if LZF_USE_OFFSETS +#ifdef LZF_HSLOT # define LZF_HSLOT_BIAS ((const u8 *)in_data) - typedef unsigned int LZF_HSLOT; #else -# define LZF_HSLOT_BIAS 0 - typedef const u8 *LZF_HSLOT; +# if LZF_USE_OFFSETS +# define LZF_HSLOT_BIAS ((const u8 *)in_data) + typedef unsigned int LZF_HSLOT; +# else +# define LZF_HSLOT_BIAS 0 + typedef const u8 *LZF_HSLOT; +# endif #endif typedef LZF_HSLOT LZF_STATE[1 << (HLOG)]; -#if !STRICT_ALIGN -/* for unaligned accesses we need a 16 bit datatype. */ -# if USHRT_MAX == 65535 - typedef unsigned short u16; -# elif UINT_MAX == 65535 - typedef unsigned int u16; -# else -# undef STRICT_ALIGN -# define STRICT_ALIGN 1 -# endif +#if USHRT_MAX == 65535 + typedef unsigned short u16; +#elif UINT_MAX == 65535 + typedef unsigned int u16; +#else +# undef STRICT_ALIGN +# define STRICT_ALIGN 1 #endif #if ULTRA_FAST