libc/lzf: Make HLOG configurable
(cherry picked from commit ea77dfafe1afe7d399e47871d2ec81fea99626cc)
This commit is contained in:
parent
d3cf5de5f4
commit
9acfbd2163
@ -1,5 +1,9 @@
|
|||||||
/*
|
/****************************************************************************
|
||||||
* Copyright (c) 2000-2008 Marc Alexander Lehmann <schmorp@schmorp.de>
|
* lzf -- an extremely fast/free compression/decompression-method
|
||||||
|
* http://liblzf.plan9.de/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2000-2008 Marc Alexander Lehmann <schmorp@schmorp.de>
|
||||||
|
* This algorithm is believed to be patent-free.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without modifica-
|
* Redistribution and use in source and binary forms, with or without modifica-
|
||||||
* tion, are permitted provided that the following conditions are met:
|
* tion, are permitted provided that the following conditions are met:
|
||||||
@ -22,34 +26,37 @@
|
|||||||
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
* ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
****************************************************************************/
|
||||||
* the GNU General Public License ("GPL") version 2 or any later version,
|
|
||||||
* in which case the provisions of the GPL are applicable instead of
|
|
||||||
* the above. If you wish to allow the use of your version of this file
|
|
||||||
* only under the terms of the GPL and not to allow others to use your
|
|
||||||
* version of this file under the BSD license, indicate your decision
|
|
||||||
* by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL. If you do not delete the
|
|
||||||
* provisions above, a recipient may use your version of this file under
|
|
||||||
* either the BSD or the GPL.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef LZF_H
|
#ifndef __INCLUDE_LZF_H
|
||||||
#define LZF_H
|
#define __INCLUDE_LZF_H 1
|
||||||
|
|
||||||
/***********************************************************************
|
/****************************************************************************
|
||||||
**
|
* Pre-processor Definitions
|
||||||
** lzf -- an extremely fast/free compression/decompression-method
|
****************************************************************************/
|
||||||
** http://liblzf.plan9.de/
|
|
||||||
**
|
|
||||||
** This algorithm is believed to be patent-free.
|
|
||||||
**
|
|
||||||
***********************************************************************/
|
|
||||||
|
|
||||||
#define LZF_VERSION 0x0105 /* 1.5, API version */
|
#define LZF_VERSION 0x0105 /* 1.5, API version */
|
||||||
|
#define HLOG CONFIG_LIBC_LZF_HLOG
|
||||||
|
|
||||||
/*
|
/****************************************************************************
|
||||||
* Compress in_len bytes stored at the memory block starting at
|
* Public Types
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#if LZF_USE_OFFSETS
|
||||||
|
# define LZF_HSLOT_BIAS ((const uint8_t *)in_data)
|
||||||
|
typedef unsigned int lzf_hslot_t;
|
||||||
|
#else
|
||||||
|
# define LZF_HSLOT_BIAS 0
|
||||||
|
typedef const uint8_t *lzf_hslot_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef lzf_hslot_t LZF_STATE[1 << HLOG];
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/* Compress in_len bytes stored at the memory block starting at
|
||||||
* in_data and write the result to out_data, up to a maximum length
|
* in_data and write the result to out_data, up to a maximum length
|
||||||
* of out_len bytes.
|
* of out_len bytes.
|
||||||
*
|
*
|
||||||
@ -71,14 +78,13 @@
|
|||||||
* If the option LZF_STATE_ARG is enabled, an extra argument must be
|
* If the option LZF_STATE_ARG is enabled, an extra argument must be
|
||||||
* supplied which is not reflected in this header file. Refer to lzfP.h
|
* supplied which is not reflected in this header file. Refer to lzfP.h
|
||||||
* and lzf_c.c.
|
* and lzf_c.c.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
unsigned int
|
|
||||||
lzf_compress (const void *const in_data, unsigned int in_len,
|
|
||||||
void *out_data, unsigned int out_len);
|
|
||||||
|
|
||||||
/*
|
unsigned int lzf_compress(FAR const void *const in_data,
|
||||||
* Decompress data compressed with some version of the lzf_compress
|
unsigned int in_len, FAR void *out_data,
|
||||||
|
unsigned int out_len);
|
||||||
|
|
||||||
|
/* Decompress data compressed with some version of the lzf_compress
|
||||||
* function and stored at location in_data and length in_len. The result
|
* function and stored at location in_data and length in_len. The result
|
||||||
* will be stored at out_data up to a maximum of out_len characters.
|
* will be stored at out_data up to a maximum of out_len characters.
|
||||||
*
|
*
|
||||||
@ -92,9 +98,9 @@ lzf_compress (const void *const in_data, unsigned int in_len,
|
|||||||
*
|
*
|
||||||
* This function is very fast, about as fast as a copying loop.
|
* This function is very fast, about as fast as a copying loop.
|
||||||
*/
|
*/
|
||||||
unsigned int
|
|
||||||
lzf_decompress (const void *const in_data, unsigned int in_len,
|
|
||||||
void *out_data, unsigned int out_len);
|
|
||||||
|
|
||||||
#endif
|
unsigned int lzf_decompress(FAR const void *const in_data,
|
||||||
|
unsigned int in_len, FAR void *out_data,
|
||||||
|
unsigned int out_len);
|
||||||
|
|
||||||
|
#endif /* __INCLUDE_LZF_H */
|
||||||
|
@ -29,6 +29,22 @@ config LIBC_LZF_FASTEST
|
|||||||
|
|
||||||
endchoice # Compression options
|
endchoice # Compression options
|
||||||
|
|
||||||
|
config LIBC_LZF_HLOG
|
||||||
|
int "Log2 Hash table size"
|
||||||
|
default 13
|
||||||
|
range 1 22
|
||||||
|
---help---
|
||||||
|
Size of hashtable is (1 << HLOG) * sizeof (char *). Decompression is
|
||||||
|
independent of the hash table size 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 22).
|
||||||
|
|
||||||
|
#ifndef HLOG
|
||||||
|
# define HLOG 13
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
config LIBC_LZF_ALIGN
|
config LIBC_LZF_ALIGN
|
||||||
bool "Strict alignment"
|
bool "Strict alignment"
|
||||||
default y
|
default y
|
||||||
|
@ -54,17 +54,6 @@ using namespace std;
|
|||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Size of hashtable is (1 << HLOG) * sizeof (char *). Decompression is
|
|
||||||
* independent of the hash table size 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 22).
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef HLOG
|
|
||||||
# define HLOG 13
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* You may choose to pre-set the hash table (might be faster on some modern
|
/* You may choose to pre-set the hash table (might be faster on some modern
|
||||||
* CPUs and large (>>64k) blocks, and also makes compression deterministic/
|
* CPUs and large (>>64k) blocks, and also makes compression deterministic/
|
||||||
* repeatable when the configuration otherwise is the same).
|
* repeatable when the configuration otherwise is the same).
|
||||||
@ -110,14 +99,4 @@ using namespace std;
|
|||||||
* Public Types
|
* Public Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#if LZF_USE_OFFSETS
|
|
||||||
# define LZF_HSLOT_BIAS ((const uint8_t *)in_data)
|
|
||||||
typedef unsigned int LZF_HSLOT;
|
|
||||||
#else
|
|
||||||
# define LZF_HSLOT_BIAS 0
|
|
||||||
typedef const uint8_t *LZF_HSLOT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
|
|
||||||
|
|
||||||
#endif /* __LIBC_LZF_LZFP_H */
|
#endif /* __LIBC_LZF_LZFP_H */
|
||||||
|
@ -147,7 +147,7 @@ unsigned int lzf_compress(FAR const void *const in_data, unsigned int in_len,
|
|||||||
hval = FRST (ip);
|
hval = FRST (ip);
|
||||||
while (ip < in_end - 2)
|
while (ip < in_end - 2)
|
||||||
{
|
{
|
||||||
LZF_HSLOT *hslot;
|
lzf_hslot_t *hslot;
|
||||||
|
|
||||||
hval = NEXT (hval, ip);
|
hval = NEXT (hval, ip);
|
||||||
hslot = htab + IDX (hval);
|
hslot = htab + IDX (hval);
|
||||||
|
Loading…
Reference in New Issue
Block a user