1 | /* |
1 | /* |
2 | * Copyright (c) 2000 Marc Alexander Lehmann <pcg@goof.com> |
2 | * Copyright (c) 2000-2003 Marc Alexander Lehmann <pcg@goof.com> |
3 | * |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without modifica- |
4 | * Redistribution and use in source and binary forms, with or without modifica- |
5 | * tion, are permitted provided that the following conditions are met: |
5 | * tion, are permitted provided that the following conditions are met: |
6 | * |
6 | * |
7 | * 1. Redistributions of source code must retain the above copyright notice, |
7 | * 1. Redistributions of source code must retain the above copyright notice, |
… | |
… | |
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
22 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
23 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- |
24 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH- |
25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
25 | * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
26 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
27 | * |
|
|
28 | * Alternatively, the contents of this file may be used under the terms of |
|
|
29 | * the GNU General Public License version 2 (the "GPL"), in which case the |
|
|
30 | * provisions of the GPL are applicable instead of the above. If you wish to |
|
|
31 | * allow the use of your version of this file only under the terms of the |
|
|
32 | * GPL and not to allow others to use your version of this file under the |
|
|
33 | * BSD license, indicate your decision by deleting the provisions above and |
|
|
34 | * replace them with the notice and other provisions required by the GPL. If |
|
|
35 | * you do not delete the provisions above, a recipient may use your version |
|
|
36 | * of this file under either the BSD or the GPL. |
27 | */ |
37 | */ |
28 | |
38 | |
29 | #ifndef LZFP_h |
39 | #ifndef LZFP_h |
30 | #define LZFP_h |
40 | #define LZFP_h |
31 | |
41 | |
… | |
… | |
48 | #endif |
58 | #endif |
49 | |
59 | |
50 | /* |
60 | /* |
51 | * sacrifice some compression quality in favour of compression speed. |
61 | * sacrifice some compression quality in favour of compression speed. |
52 | * (roughly 1-2% worse compression for large blocks and |
62 | * (roughly 1-2% worse compression for large blocks and |
53 | * 9-10% for small, redundant, blocks and 20% better speed in both cases) |
63 | * 9-10% for small, redundant, blocks and >>20% better speed in both cases) |
54 | * In short: enable this for binary data, disable this for text data. |
64 | * In short: enable this for binary data, disable this for text data. |
55 | */ |
65 | */ |
56 | #ifndef ULTRA_FAST |
66 | #ifndef ULTRA_FAST |
57 | # define ULTRA_FAST 1 |
67 | # define ULTRA_FAST 1 |
58 | #endif |
68 | #endif |
… | |
… | |
78 | */ |
88 | */ |
79 | #ifndef INIT_HTAB |
89 | #ifndef INIT_HTAB |
80 | # define INIT_HTAB 0 |
90 | # define INIT_HTAB 0 |
81 | #endif |
91 | #endif |
82 | |
92 | |
|
|
93 | /* |
|
|
94 | * avoid assigning values to errno variable? for some embedding purposes |
|
|
95 | * (linux kernel for example), this is neccessary. NOTE: this breaks |
|
|
96 | * the documentation in lzf.h. |
|
|
97 | */ |
|
|
98 | #ifndef AVOID_ERRNO |
|
|
99 | # define AVOID_ERRNO 0 |
|
|
100 | #endif |
|
|
101 | |
|
|
102 | /* |
|
|
103 | * Wether to pass the LZF_STATE variable as argument, or allocate it |
|
|
104 | * on the stack. For small-stack environments, define this to 1. |
|
|
105 | * NOTE: this breaks the prototype in lzf.h. |
|
|
106 | */ |
|
|
107 | #ifndef LZF_STATE_ARG |
|
|
108 | # define LZF_STATE_ARG 0 |
|
|
109 | #endif |
|
|
110 | |
83 | /*****************************************************************************/ |
111 | /*****************************************************************************/ |
84 | /* nothing should be changed below */ |
112 | /* nothing should be changed below */ |
85 | |
113 | |
86 | typedef unsigned char u8; |
114 | typedef unsigned char u8; |
|
|
115 | |
|
|
116 | typedef const u8 *LZF_STATE[1 << (HLOG)]; |
87 | |
117 | |
88 | #if !STRICT_ALIGN |
118 | #if !STRICT_ALIGN |
89 | /* for unaligned accesses we need a 16 bit datatype. */ |
119 | /* for unaligned accesses we need a 16 bit datatype. */ |
90 | # include <limits.h> |
120 | # include <limits.h> |
91 | # if USHRT_MAX == 65535 |
121 | # if USHRT_MAX == 65535 |
92 | typedef unsigned short u16; |
122 | typedef unsigned short u16; |
93 | # elif UINT_MAX == 65535 |
123 | # elif UINT_MAX == 65535 |
94 | typedef unsigned int u16; |
124 | typedef unsigned int u16; |
95 | # else |
125 | # else |
96 | # warn need 16 bit datatype when STRICT_ALIGN == 0, this is non-fatal |
|
|
97 | # undef STRICT_ALIGN |
126 | # undef STRICT_ALIGN |
98 | # define STRICT_ALIGN 1 |
127 | # define STRICT_ALIGN 1 |
99 | # endif |
128 | # endif |
100 | #endif |
129 | #endif |
101 | |
130 | |