annotate minilzo.c @ 5538:70725449c947

VM Fix by Uwe.Reder@3soft.de
author atmos4
date Tue, 09 Apr 2002 13:18:45 +0000
parents b081763865d4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3803
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1 /* minilzo.c -- mini subset of the LZO real-time data compression library
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
3 This file is part of the LZO real-time data compression library.
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
5 Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
6 Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
7 Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
8 Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
9 Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
10
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
11 The LZO library is free software; you can redistribute it and/or
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
12 modify it under the terms of the GNU General Public License as
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
13 published by the Free Software Foundation; either version 2 of
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
14 the License, or (at your option) any later version.
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
15
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
16 The LZO library is distributed in the hope that it will be useful,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
19 GNU General Public License for more details.
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
20
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
21 You should have received a copy of the GNU General Public License
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
22 along with the LZO library; see the file COPYING.
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
23 If not, write to the Free Software Foundation, Inc.,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
24 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
25
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
26 Markus F.X.J. Oberhumer
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
27 <markus.oberhumer@jk.uni-linz.ac.at>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
28 http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
29 */
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
30
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
31 /*
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
32 * NOTE:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
33 * the full LZO package can be found at
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
34 * http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
35 */
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
36
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
37 #define __LZO_IN_MINILZO
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
38
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
39 #ifdef MINILZO_HAVE_CONFIG_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
40 # include <config.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
41 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
42
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
43 #undef LZO_HAVE_CONFIG_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
44 #include "minilzo.h"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
45
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
46 #if !defined(MINILZO_VERSION) || (MINILZO_VERSION != 0x1070)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
47 # error "version mismatch in miniLZO source files"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
48 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
49
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
50 #ifdef MINILZO_HAVE_CONFIG_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
51 # define LZO_HAVE_CONFIG_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
52 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
53
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
54 #if !defined(LZO_NO_SYS_TYPES_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
55 # include <sys/types.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
56 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
57 #include <stdio.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
58
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
59 #ifndef __LZO_CONF_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
60 #define __LZO_CONF_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
61
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
62 #if !defined(__LZO_IN_MINILZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
63 # ifndef __LZOCONF_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
64 # include <lzoconf.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
65 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
66 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
67
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
68 #if defined(__BOUNDS_CHECKING_ON)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
69 # include <unchecked.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
70 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
71 # define BOUNDS_CHECKING_OFF_DURING(stmt) stmt
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
72 # define BOUNDS_CHECKING_OFF_IN_EXPR(expr) (expr)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
73 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
74
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
75 #if !defined(LZO_HAVE_CONFIG_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
76 # include <stddef.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
77 # include <string.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
78 # if !defined(NO_STDLIB_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
79 # include <stdlib.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
80 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
81 # define HAVE_MEMCMP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
82 # define HAVE_MEMCPY
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
83 # define HAVE_MEMMOVE
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
84 # define HAVE_MEMSET
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
85 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
86 # include <sys/types.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
87 # if defined(STDC_HEADERS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
88 # include <string.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
89 # include <stdlib.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
90 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
91 # if defined(HAVE_STDDEF_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
92 # include <stddef.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
93 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
94 # if defined(HAVE_MEMORY_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
95 # include <memory.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
96 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
97 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
98
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
99 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
100 # define HAVE_MALLOC_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
101 # define HAVE_HALLOC
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
102 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
103
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
104 #undef NDEBUG
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
105 #if !defined(LZO_DEBUG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
106 # define NDEBUG
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
107 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
108 #if defined(LZO_DEBUG) || !defined(NDEBUG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
109 # if !defined(NO_STDIO_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
110 # include <stdio.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
111 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
112 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
113 #include <assert.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
114
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
115 #if !defined(LZO_UNUSED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
116 # define LZO_UNUSED(parm) (parm = parm)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
117 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
118
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
119 #if !defined(__inline__) && !defined(__GNUC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
120 # if defined(__cplusplus)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
121 # define __inline__ inline
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
122 # else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
123 # define __inline__
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
124 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
125 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
126
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
127 #if defined(NO_MEMCMP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
128 # undef HAVE_MEMCMP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
129 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
130
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
131 #if !defined(HAVE_MEMCMP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
132 # undef memcmp
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
133 # define memcmp lzo_memcmp
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
134 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
135 #if !defined(HAVE_MEMCPY)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
136 # undef memcpy
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
137 # define memcpy lzo_memcpy
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
138 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
139 #if !defined(HAVE_MEMMOVE)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
140 # undef memmove
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
141 # define memmove lzo_memmove
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
142 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
143 #if !defined(HAVE_MEMSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
144 # undef memset
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
145 # define memset lzo_memset
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
146 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
147
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
148 #if 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
149 # define LZO_BYTE(x) ((unsigned char) (x))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
150 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
151 # define LZO_BYTE(x) ((unsigned char) ((x) & 0xff))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
152 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
153 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
154 # define LZO_USHORT(x) ((unsigned short) (x))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
155 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
156 # define LZO_USHORT(x) ((unsigned short) ((x) & 0xffff))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
157 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
158
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
159 #define LZO_MAX(a,b) ((a) >= (b) ? (a) : (b))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
160 #define LZO_MIN(a,b) ((a) <= (b) ? (a) : (b))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
161 #define LZO_MAX3(a,b,c) ((a) >= (b) ? LZO_MAX(a,c) : LZO_MAX(b,c))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
162 #define LZO_MIN3(a,b,c) ((a) <= (b) ? LZO_MIN(a,c) : LZO_MIN(b,c))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
163
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
164 #define lzo_sizeof(type) ((lzo_uint) (sizeof(type)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
165
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
166 #define LZO_HIGH(array) ((lzo_uint) (sizeof(array)/sizeof(*(array))))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
167
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
168 #define LZO_SIZE(bits) (1u << (bits))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
169 #define LZO_MASK(bits) (LZO_SIZE(bits) - 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
170
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
171 #define LZO_LSIZE(bits) (1ul << (bits))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
172 #define LZO_LMASK(bits) (LZO_LSIZE(bits) - 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
173
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
174 #define LZO_USIZE(bits) ((lzo_uint) 1 << (bits))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
175 #define LZO_UMASK(bits) (LZO_USIZE(bits) - 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
176
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
177 #define LZO_STYPE_MAX(b) (((1l << (8*(b)-2)) - 1l) + (1l << (8*(b)-2)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
178 #define LZO_UTYPE_MAX(b) (((1ul << (8*(b)-1)) - 1ul) + (1ul << (8*(b)-1)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
179
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
180 #if !defined(SIZEOF_UNSIGNED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
181 # if (UINT_MAX == 0xffff)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
182 # define SIZEOF_UNSIGNED 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
183 # elif (UINT_MAX == LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
184 # define SIZEOF_UNSIGNED 4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
185 # elif (UINT_MAX >= LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
186 # define SIZEOF_UNSIGNED 8
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
187 # else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
188 # error SIZEOF_UNSIGNED
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
189 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
190 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
191
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
192 #if !defined(SIZEOF_UNSIGNED_LONG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
193 # if (ULONG_MAX == LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
194 # define SIZEOF_UNSIGNED_LONG 4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
195 # elif (ULONG_MAX >= LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
196 # define SIZEOF_UNSIGNED_LONG 8
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
197 # else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
198 # error SIZEOF_UNSIGNED_LONG
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
199 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
200 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
201
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
202 #if !defined(SIZEOF_SIZE_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
203 # define SIZEOF_SIZE_T SIZEOF_UNSIGNED
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
204 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
205 #if !defined(SIZE_T_MAX)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
206 # define SIZE_T_MAX LZO_UTYPE_MAX(SIZEOF_SIZE_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
207 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
208
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
209 #if 1 && defined(__LZO_i386) && (UINT_MAX == LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
210 # if !defined(LZO_UNALIGNED_OK_2) && (USHRT_MAX == 0xffff)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
211 # define LZO_UNALIGNED_OK_2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
212 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
213 # if !defined(LZO_UNALIGNED_OK_4) && (LZO_UINT32_MAX == LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
214 # define LZO_UNALIGNED_OK_4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
215 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
216 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
217
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
218 #if defined(LZO_UNALIGNED_OK_2) || defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
219 # if !defined(LZO_UNALIGNED_OK)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
220 # define LZO_UNALIGNED_OK
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
221 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
222 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
223
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
224 #if defined(__LZO_NO_UNALIGNED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
225 # undef LZO_UNALIGNED_OK
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
226 # undef LZO_UNALIGNED_OK_2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
227 # undef LZO_UNALIGNED_OK_4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
228 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
229
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
230 #if defined(LZO_UNALIGNED_OK_2) && (USHRT_MAX != 0xffff)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
231 # error "LZO_UNALIGNED_OK_2 must not be defined on this system"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
232 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
233 #if defined(LZO_UNALIGNED_OK_4) && (LZO_UINT32_MAX != LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
234 # error "LZO_UNALIGNED_OK_4 must not be defined on this system"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
235 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
236
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
237 #if defined(__LZO_NO_ALIGNED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
238 # undef LZO_ALIGNED_OK_4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
239 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
240
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
241 #if defined(LZO_ALIGNED_OK_4) && (LZO_UINT32_MAX != LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
242 # error "LZO_ALIGNED_OK_4 must not be defined on this system"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
243 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
244
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
245 #define LZO_LITTLE_ENDIAN 1234
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
246 #define LZO_BIG_ENDIAN 4321
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
247 #define LZO_PDP_ENDIAN 3412
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
248
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
249 #if !defined(LZO_BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
250 # if defined(MFX_BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
251 # define LZO_BYTE_ORDER MFX_BYTE_ORDER
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
252 # elif defined(__LZO_i386)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
253 # define LZO_BYTE_ORDER LZO_LITTLE_ENDIAN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
254 # elif defined(BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
255 # define LZO_BYTE_ORDER BYTE_ORDER
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
256 # elif defined(__BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
257 # define LZO_BYTE_ORDER __BYTE_ORDER
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
258 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
259 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
260
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
261 #if defined(LZO_BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
262 # if (LZO_BYTE_ORDER != LZO_LITTLE_ENDIAN) && \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
263 (LZO_BYTE_ORDER != LZO_BIG_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
264 # error "invalid LZO_BYTE_ORDER"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
265 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
266 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
267
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
268 #if defined(LZO_UNALIGNED_OK) && !defined(LZO_BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
269 # error "LZO_BYTE_ORDER is not defined"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
270 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
271
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
272 #define LZO_OPTIMIZE_GNUC_i386_IS_BUGGY
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
273
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
274 #if defined(NDEBUG) && !defined(LZO_DEBUG) && !defined(__LZO_CHECKER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
275 # if defined(__GNUC__) && defined(__i386__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
276 # if !defined(LZO_OPTIMIZE_GNUC_i386_IS_BUGGY)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
277 # define LZO_OPTIMIZE_GNUC_i386
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
278 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
279 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
280 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
281
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
282 __LZO_EXTERN_C int __lzo_init_done;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
283 __LZO_EXTERN_C const lzo_byte __lzo_copyright[];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
284 LZO_EXTERN(const lzo_byte *) lzo_copyright(void);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
285 __LZO_EXTERN_C const lzo_uint32 _lzo_crc32_table[256];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
286
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
287 #define _LZO_STRINGIZE(x) #x
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
288 #define _LZO_MEXPAND(x) _LZO_STRINGIZE(x)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
289
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
290 #define _LZO_CONCAT2(a,b) a ## b
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
291 #define _LZO_CONCAT3(a,b,c) a ## b ## c
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
292 #define _LZO_CONCAT4(a,b,c,d) a ## b ## c ## d
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
293 #define _LZO_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
294
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
295 #define _LZO_ECONCAT2(a,b) _LZO_CONCAT2(a,b)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
296 #define _LZO_ECONCAT3(a,b,c) _LZO_CONCAT3(a,b,c)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
297 #define _LZO_ECONCAT4(a,b,c,d) _LZO_CONCAT4(a,b,c,d)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
298 #define _LZO_ECONCAT5(a,b,c,d,e) _LZO_CONCAT5(a,b,c,d,e)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
299
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
300 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
301
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
302 #define __LZO_IS_COMPRESS_QUERY(i,il,o,ol,w) ((lzo_voidp)(o) == (w))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
303 #define __LZO_QUERY_COMPRESS(i,il,o,ol,w,n,s) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
304 (*ol = (n)*(s), LZO_E_OK)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
305
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
306 #define __LZO_IS_DECOMPRESS_QUERY(i,il,o,ol,w) ((lzo_voidp)(o) == (w))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
307 #define __LZO_QUERY_DECOMPRESS(i,il,o,ol,w,n,s) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
308 (*ol = (n)*(s), LZO_E_OK)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
309
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
310 #define __LZO_IS_OPTIMIZE_QUERY(i,il,o,ol,w) ((lzo_voidp)(o) == (w))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
311 #define __LZO_QUERY_OPTIMIZE(i,il,o,ol,w,n,s) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
312 (*ol = (n)*(s), LZO_E_OK)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
313
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
314 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
315
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
316 #ifndef __LZO_PTR_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
317 #define __LZO_PTR_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
318
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
319 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
320 extern "C" {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
321 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
322
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
323 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
324 # include <dos.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
325 # if 1 && defined(__WATCOMC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
326 # include <i86.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
327 __LZO_EXTERN_C unsigned char _HShift;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
328 # define __LZO_HShift _HShift
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
329 # elif 1 && defined(_MSC_VER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
330 __LZO_EXTERN_C unsigned short __near _AHSHIFT;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
331 # define __LZO_HShift ((unsigned) &_AHSHIFT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
332 # elif defined(__LZO_WIN16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
333 # define __LZO_HShift 3
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
334 # else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
335 # define __LZO_HShift 12
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
336 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
337 # if !defined(_FP_SEG) && defined(FP_SEG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
338 # define _FP_SEG FP_SEG
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
339 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
340 # if !defined(_FP_OFF) && defined(FP_OFF)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
341 # define _FP_OFF FP_OFF
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
342 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
343 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
344
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
345 #if (UINT_MAX >= LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
346 typedef ptrdiff_t lzo_ptrdiff_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
347 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
348 typedef long lzo_ptrdiff_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
349 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
350
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
351 #if !defined(__LZO_HAVE_PTR_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
352 # if defined(lzo_ptr_t)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
353 # define __LZO_HAVE_PTR_T
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
354 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
355 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
356 #if !defined(__LZO_HAVE_PTR_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
357 # if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_LONG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
358 # if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_LONG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
359 typedef unsigned long lzo_ptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
360 typedef long lzo_sptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
361 # define __LZO_HAVE_PTR_T
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
362 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
363 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
364 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
365 #if !defined(__LZO_HAVE_PTR_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
366 # if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
367 # if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
368 typedef unsigned int lzo_ptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
369 typedef int lzo_sptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
370 # define __LZO_HAVE_PTR_T
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
371 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
372 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
373 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
374 #if !defined(__LZO_HAVE_PTR_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
375 # if defined(SIZEOF_CHAR_P) && defined(SIZEOF_UNSIGNED_SHORT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
376 # if (SIZEOF_CHAR_P == SIZEOF_UNSIGNED_SHORT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
377 typedef unsigned short lzo_ptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
378 typedef short lzo_sptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
379 # define __LZO_HAVE_PTR_T
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
380 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
381 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
382 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
383 #if !defined(__LZO_HAVE_PTR_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
384 # if defined(LZO_HAVE_CONFIG_H) || defined(SIZEOF_CHAR_P)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
385 # error "no suitable type for lzo_ptr_t"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
386 # else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
387 typedef unsigned long lzo_ptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
388 typedef long lzo_sptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
389 # define __LZO_HAVE_PTR_T
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
390 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
391 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
392
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
393 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
394 #define PTR(a) ((lzo_bytep) (a))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
395 #define PTR_ALIGNED_4(a) ((_FP_OFF(a) & 3) == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
396 #define PTR_ALIGNED2_4(a,b) (((_FP_OFF(a) | _FP_OFF(b)) & 3) == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
397 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
398 #define PTR(a) ((lzo_ptr_t) (a))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
399 #define PTR_LINEAR(a) PTR(a)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
400 #define PTR_ALIGNED_4(a) ((PTR_LINEAR(a) & 3) == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
401 #define PTR_ALIGNED_8(a) ((PTR_LINEAR(a) & 7) == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
402 #define PTR_ALIGNED2_4(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 3) == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
403 #define PTR_ALIGNED2_8(a,b) (((PTR_LINEAR(a) | PTR_LINEAR(b)) & 7) == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
404 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
405
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
406 #define PTR_LT(a,b) (PTR(a) < PTR(b))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
407 #define PTR_GE(a,b) (PTR(a) >= PTR(b))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
408 #define PTR_DIFF(a,b) ((lzo_ptrdiff_t) (PTR(a) - PTR(b)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
409
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
410 LZO_EXTERN(lzo_ptr_t)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
411 __lzo_ptr_linear(const lzo_voidp ptr);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
412
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
413 typedef union
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
414 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
415 char a_char;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
416 unsigned char a_uchar;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
417 short a_short;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
418 unsigned short a_ushort;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
419 int a_int;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
420 unsigned int a_uint;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
421 long a_long;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
422 unsigned long a_ulong;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
423 lzo_int a_lzo_int;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
424 lzo_uint a_lzo_uint;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
425 lzo_int32 a_lzo_int32;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
426 lzo_uint32 a_lzo_uint32;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
427 ptrdiff_t a_ptrdiff_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
428 lzo_ptrdiff_t a_lzo_ptrdiff_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
429 lzo_ptr_t a_lzo_ptr_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
430 char * a_charp;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
431 lzo_bytep a_lzo_bytep;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
432 lzo_bytepp a_lzo_bytepp;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
433 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
434 lzo_align_t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
435
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
436 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
437 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
438 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
439
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
440 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
441
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
442 #define LZO_DETERMINISTIC
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
443
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
444 #define LZO_DICT_USE_PTR
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
445 #if defined(__LZO_DOS16) || defined(__LZO_WIN16) || defined(__LZO_STRICT_16BIT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
446 # undef LZO_DICT_USE_PTR
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
447 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
448
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
449 #if defined(LZO_DICT_USE_PTR)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
450 # define lzo_dict_t const lzo_bytep
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
451 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
452 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
453 # define lzo_dict_t lzo_uint
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
454 # define lzo_dict_p lzo_dict_t __LZO_MMODEL *
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
455 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
456
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
457 #if !defined(lzo_moff_t)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
458 #define lzo_moff_t lzo_uint
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
459 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
460
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
461 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
462
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
463 LZO_PUBLIC(lzo_ptr_t)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
464 __lzo_ptr_linear(const lzo_voidp ptr)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
465 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
466 lzo_ptr_t p;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
467
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
468 #if defined(__LZO_DOS16) || defined(__LZO_WIN16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
469 p = (((lzo_ptr_t)(_FP_SEG(ptr))) << (16 - __LZO_HShift)) + (_FP_OFF(ptr));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
470 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
471 p = PTR_LINEAR(ptr);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
472 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
473
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
474 return p;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
475 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
476
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
477 LZO_PUBLIC(unsigned)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
478 __lzo_align_gap(const lzo_voidp ptr, lzo_uint size)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
479 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
480 lzo_ptr_t p, s, n;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
481
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
482 assert(size > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
483
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
484 p = __lzo_ptr_linear(ptr);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
485 s = (lzo_ptr_t) (size - 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
486 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
487 assert((size & (size - 1)) == 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
488 n = ((p + s) & ~s) - p;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
489 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
490 n = (((p + s) / size) * size) - p;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
491 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
492
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
493 assert((long)n >= 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
494 assert(n <= s);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
495
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
496 return (unsigned)n;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
497 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
498
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
499 #ifndef __LZO_UTIL_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
500 #define __LZO_UTIL_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
501
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
502 #ifndef __LZO_CONF_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
503 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
504
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
505 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
506 extern "C" {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
507 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
508
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
509 #if 1 && defined(HAVE_MEMCPY)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
510 #if !defined(__LZO_DOS16) && !defined(__LZO_WIN16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
511
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
512 #define MEMCPY8_DS(dest,src,len) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
513 memcpy(dest,src,len); \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
514 dest += len; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
515 src += len
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
516
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
517 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
518 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
519
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
520 #if 0 && !defined(MEMCPY8_DS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
521
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
522 #define MEMCPY8_DS(dest,src,len) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
523 { do { \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
524 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
525 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
526 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
527 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
528 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
529 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
530 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
531 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
532 len -= 8; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
533 } while (len > 0); }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
534
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
535 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
536
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
537 #if !defined(MEMCPY8_DS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
538
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
539 #define MEMCPY8_DS(dest,src,len) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
540 { register lzo_uint __l = (len) / 8; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
541 do { \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
542 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
543 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
544 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
545 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
546 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
547 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
548 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
549 *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
550 } while (--__l > 0); }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
551
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
552 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
553
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
554 #define MEMCPY_DS(dest,src,len) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
555 do *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
556 while (--len > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
557
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
558 #define MEMMOVE_DS(dest,src,len) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
559 do *dest++ = *src++; \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
560 while (--len > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
561
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
562 #if 0 && defined(LZO_OPTIMIZE_GNUC_i386)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
563
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
564 #define BZERO8_PTR(s,l,n) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
565 __asm__ __volatile__( \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
566 "movl %0,%%eax \n" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
567 "movl %1,%%edi \n" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
568 "movl %2,%%ecx \n" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
569 "cld \n" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
570 "rep \n" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
571 "stosl %%eax,(%%edi) \n" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
572 : \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
573 :"g" (0),"g" (s),"g" (n) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
574 :"eax","edi","ecx", "memory", "cc" \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
575 )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
576
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
577 #elif (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
578
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
579 #if 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
580 #define BZERO8_PTR(s,l,n) memset((s),0,(lzo_uint)(l)*(n))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
581 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
582 #define BZERO8_PTR(s,l,n) memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
583 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
584
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
585 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
586
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
587 #define BZERO8_PTR(s,l,n) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
588 lzo_memset((lzo_voidp)(s),0,(lzo_uint)(l)*(n))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
589
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
590 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
591
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
592 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
593 #if defined(__GNUC__) && defined(__i386__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
594
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
595 unsigned char lzo_rotr8(unsigned char value, int shift);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
596 extern __inline__ unsigned char lzo_rotr8(unsigned char value, int shift)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
597 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
598 unsigned char result;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
599
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
600 __asm__ __volatile__ ("movb %b1, %b0; rorb %b2, %b0"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
601 : "=a"(result) : "g"(value), "c"(shift));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
602 return result;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
603 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
604
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
605 unsigned short lzo_rotr16(unsigned short value, int shift);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
606 extern __inline__ unsigned short lzo_rotr16(unsigned short value, int shift)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
607 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
608 unsigned short result;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
609
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
610 __asm__ __volatile__ ("movw %b1, %b0; rorw %b2, %b0"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
611 : "=a"(result) : "g"(value), "c"(shift));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
612 return result;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
613 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
614
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
615 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
616 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
617
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
618 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
619 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
620 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
621
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
622 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
623
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
624 LZO_PUBLIC(lzo_bool)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
625 lzo_assert(int expr)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
626 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
627 return (expr) ? 1 : 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
628 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
629
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
630 /* If you use the LZO library in a product, you *must* keep this
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
631 * copyright string in the executable of your product.
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
632 */
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
633
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
634 const lzo_byte __lzo_copyright[] =
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
635 #if !defined(__LZO_IN_MINLZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
636 LZO_VERSION_STRING;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
637 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
638 "\n\n\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
639 "LZO real-time data compression library.\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
640 "Copyright (C) 1996, 1997, 1998, 1999, 2000 Markus Franz Xaver Johannes Oberhumer\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
641 "<markus.oberhumer@jk.uni-linz.ac.at>\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
642 "http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
643 "\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
644 "LZO version: v" LZO_VERSION_STRING ", " LZO_VERSION_DATE "\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
645 "LZO build date: " __DATE__ " " __TIME__ "\n\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
646 "LZO special compilation options:\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
647 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
648 " __cplusplus\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
649 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
650 #if defined(__PIC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
651 " __PIC__\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
652 #elif defined(__pic__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
653 " __pic__\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
654 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
655 #if (UINT_MAX < LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
656 " 16BIT\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
657 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
658 #if defined(__LZO_STRICT_16BIT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
659 " __LZO_STRICT_16BIT\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
660 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
661 #if (UINT_MAX > LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
662 " UINT_MAX=" _LZO_MEXPAND(UINT_MAX) "\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
663 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
664 #if (ULONG_MAX > LZO_0xffffffffL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
665 " ULONG_MAX=" _LZO_MEXPAND(ULONG_MAX) "\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
666 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
667 #if defined(LZO_BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
668 " LZO_BYTE_ORDER=" _LZO_MEXPAND(LZO_BYTE_ORDER) "\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
669 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
670 #if defined(LZO_UNALIGNED_OK_2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
671 " LZO_UNALIGNED_OK_2\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
672 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
673 #if defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
674 " LZO_UNALIGNED_OK_4\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
675 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
676 #if defined(LZO_ALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
677 " LZO_ALIGNED_OK_4\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
678 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
679 #if defined(LZO_DICT_USE_PTR)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
680 " LZO_DICT_USE_PTR\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
681 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
682 #if defined(__LZO_QUERY_COMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
683 " __LZO_QUERY_COMPRESS\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
684 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
685 #if defined(__LZO_QUERY_DECOMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
686 " __LZO_QUERY_DECOMPRESS\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
687 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
688 #if defined(__LZO_IN_MINILZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
689 " __LZO_IN_MINILZO\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
690 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
691 "\n\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
692 "$Id: LZO " LZO_VERSION_STRING " built " __DATE__ " " __TIME__
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
693 #if defined(__GNUC__) && defined(__VERSION__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
694 " by gcc " __VERSION__
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
695 #elif defined(__BORLANDC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
696 " by Borland C " _LZO_MEXPAND(__BORLANDC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
697 #elif defined(_MSC_VER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
698 " by Microsoft C " _LZO_MEXPAND(_MSC_VER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
699 #elif defined(__PUREC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
700 " by Pure C " _LZO_MEXPAND(__PUREC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
701 #elif defined(__SC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
702 " by Symantec C " _LZO_MEXPAND(__SC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
703 #elif defined(__TURBOC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
704 " by Turbo C " _LZO_MEXPAND(__TURBOC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
705 #elif defined(__WATCOMC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
706 " by Watcom C " _LZO_MEXPAND(__WATCOMC__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
707 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
708 " $\n"
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
709 "$Copyright: LZO (C) 1996, 1997, 1998, 1999, 2000 Markus Franz Xaver Johannes Oberhumer $\n";
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
710 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
711
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
712 LZO_PUBLIC(const lzo_byte *)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
713 lzo_copyright(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
714 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
715 return __lzo_copyright;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
716 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
717
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
718 LZO_PUBLIC(unsigned)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
719 lzo_version(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
720 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
721 return LZO_VERSION;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
722 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
723
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
724 LZO_PUBLIC(const char *)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
725 lzo_version_string(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
726 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
727 return LZO_VERSION_STRING;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
728 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
729
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
730 LZO_PUBLIC(const char *)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
731 lzo_version_date(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
732 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
733 return LZO_VERSION_DATE;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
734 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
735
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
736 LZO_PUBLIC(const lzo_charp)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
737 _lzo_version_string(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
738 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
739 return LZO_VERSION_STRING;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
740 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
741
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
742 LZO_PUBLIC(const lzo_charp)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
743 _lzo_version_date(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
744 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
745 return LZO_VERSION_DATE;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
746 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
747
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
748 #define LZO_BASE 65521u
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
749 #define LZO_NMAX 5552
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
750
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
751 #define LZO_DO1(buf,i) {s1 += buf[i]; s2 += s1;}
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
752 #define LZO_DO2(buf,i) LZO_DO1(buf,i); LZO_DO1(buf,i+1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
753 #define LZO_DO4(buf,i) LZO_DO2(buf,i); LZO_DO2(buf,i+2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
754 #define LZO_DO8(buf,i) LZO_DO4(buf,i); LZO_DO4(buf,i+4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
755 #define LZO_DO16(buf,i) LZO_DO8(buf,i); LZO_DO8(buf,i+8);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
756
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
757 LZO_PUBLIC(lzo_uint32)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
758 lzo_adler32(lzo_uint32 adler, const lzo_byte *buf, lzo_uint len)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
759 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
760 lzo_uint32 s1 = adler & 0xffff;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
761 lzo_uint32 s2 = (adler >> 16) & 0xffff;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
762 int k;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
763
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
764 if (buf == NULL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
765 return 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
766
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
767 while (len > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
768 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
769 k = len < LZO_NMAX ? (int) len : LZO_NMAX;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
770 len -= k;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
771 if (k >= 16) do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
772 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
773 LZO_DO16(buf,0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
774 buf += 16;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
775 k -= 16;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
776 } while (k >= 16);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
777 if (k != 0) do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
778 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
779 s1 += *buf++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
780 s2 += s1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
781 } while (--k > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
782 s1 %= LZO_BASE;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
783 s2 %= LZO_BASE;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
784 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
785 return (s2 << 16) | s1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
786 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
787
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
788 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
789 lzo_memcmp(const lzo_voidp s1, const lzo_voidp s2, lzo_uint len)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
790 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
791 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCMP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
792 return memcmp(s1,s2,len);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
793 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
794 const lzo_byte *p1 = (const lzo_byte *) s1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
795 const lzo_byte *p2 = (const lzo_byte *) s2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
796 int d;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
797
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
798 if (len > 0) do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
799 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
800 d = *p1 - *p2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
801 if (d != 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
802 return d;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
803 p1++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
804 p2++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
805 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
806 while (--len > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
807 return 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
808 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
809 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
810
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
811 LZO_PUBLIC(lzo_voidp)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
812 lzo_memcpy(lzo_voidp dest, const lzo_voidp src, lzo_uint len)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
813 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
814 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMCPY)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
815 return memcpy(dest,src,len);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
816 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
817 lzo_byte *p1 = (lzo_byte *) dest;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
818 const lzo_byte *p2 = (const lzo_byte *) src;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
819
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
820 if (len <= 0 || p1 == p2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
821 return dest;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
822 do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
823 *p1++ = *p2++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
824 while (--len > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
825 return dest;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
826 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
827 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
828
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
829 LZO_PUBLIC(lzo_voidp)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
830 lzo_memmove(lzo_voidp dest, const lzo_voidp src, lzo_uint len)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
831 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
832 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMMOVE)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
833 return memmove(dest,src,len);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
834 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
835 lzo_byte *p1 = (lzo_byte *) dest;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
836 const lzo_byte *p2 = (const lzo_byte *) src;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
837
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
838 if (len <= 0 || p1 == p2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
839 return dest;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
840
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
841 if (p1 < p2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
842 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
843 do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
844 *p1++ = *p2++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
845 while (--len > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
846 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
847 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
848 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
849 p1 += len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
850 p2 += len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
851 do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
852 *--p1 = *--p2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
853 while (--len > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
854 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
855 return dest;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
856 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
857 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
858
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
859 LZO_PUBLIC(lzo_voidp)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
860 lzo_memset(lzo_voidp s, int c, lzo_uint len)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
861 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
862 #if (LZO_UINT_MAX <= SIZE_T_MAX) && defined(HAVE_MEMSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
863 return memset(s,c,len);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
864 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
865 lzo_byte *p = (lzo_byte *) s;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
866
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
867 if (len > 0) do
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
868 *p++ = LZO_BYTE(c);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
869 while (--len > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
870 return s;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
871 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
872 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
873
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
874 #include <stdio.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
875
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
876 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
877 # define IS_SIGNED(type) (((type) (1ul << (8 * sizeof(type) - 1))) < 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
878 # define IS_UNSIGNED(type) (((type) (1ul << (8 * sizeof(type) - 1))) > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
879 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
880 # define IS_SIGNED(type) (((type) (-1)) < ((type) 0))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
881 # define IS_UNSIGNED(type) (((type) (-1)) > ((type) 0))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
882 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
883
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
884 static lzo_bool schedule_insns_bug(void);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
885 static lzo_bool strength_reduce_bug(int *);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
886
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
887 #if 0 || defined(LZO_DEBUG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
888 static lzo_bool __lzo_assert_fail(const char *s, unsigned line)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
889 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
890 #if defined(__palmos__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
891 printf("LZO assertion failed in line %u: '%s'\n",line,s);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
892 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
893 fprintf(stderr,"LZO assertion failed in line %u: '%s'\n",line,s);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
894 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
895 return 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
896 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
897 # define __lzo_assert(x) ((x) ? 1 : __lzo_assert_fail(#x,__LINE__))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
898 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
899 # define __lzo_assert(x) ((x) ? 1 : 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
900 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
901
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
902 static lzo_bool basic_integral_check(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
903 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
904 lzo_bool r = 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
905 lzo_bool sanity;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
906
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
907 r &= __lzo_assert(CHAR_BIT == 8);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
908 r &= __lzo_assert(sizeof(char) == 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
909 r &= __lzo_assert(sizeof(short) >= 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
910 r &= __lzo_assert(sizeof(long) >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
911 r &= __lzo_assert(sizeof(int) >= sizeof(short));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
912 r &= __lzo_assert(sizeof(long) >= sizeof(int));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
913
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
914 r &= __lzo_assert(sizeof(lzo_uint32) >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
915 r &= __lzo_assert(sizeof(lzo_uint32) >= sizeof(unsigned));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
916 #if defined(__LZO_STRICT_16BIT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
917 r &= __lzo_assert(sizeof(lzo_uint) == 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
918 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
919 r &= __lzo_assert(sizeof(lzo_uint) >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
920 r &= __lzo_assert(sizeof(lzo_uint) >= sizeof(unsigned));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
921 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
922
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
923 #if defined(SIZEOF_UNSIGNED)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
924 r &= __lzo_assert(SIZEOF_UNSIGNED == sizeof(unsigned));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
925 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
926 #if defined(SIZEOF_UNSIGNED_LONG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
927 r &= __lzo_assert(SIZEOF_UNSIGNED_LONG == sizeof(unsigned long));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
928 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
929 #if defined(SIZEOF_UNSIGNED_SHORT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
930 r &= __lzo_assert(SIZEOF_UNSIGNED_SHORT == sizeof(unsigned short));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
931 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
932 #if !defined(__LZO_IN_MINILZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
933 #if defined(SIZEOF_SIZE_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
934 r &= __lzo_assert(SIZEOF_SIZE_T == sizeof(size_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
935 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
936 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
937
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
938 sanity = IS_UNSIGNED(unsigned short) && IS_UNSIGNED(unsigned) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
939 IS_UNSIGNED(unsigned long) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
940 IS_SIGNED(short) && IS_SIGNED(int) && IS_SIGNED(long);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
941 if (sanity)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
942 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
943 r &= __lzo_assert(IS_UNSIGNED(lzo_uint32));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
944 r &= __lzo_assert(IS_UNSIGNED(lzo_uint));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
945 r &= __lzo_assert(IS_SIGNED(lzo_int32));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
946 r &= __lzo_assert(IS_SIGNED(lzo_int));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
947
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
948 r &= __lzo_assert(INT_MAX == LZO_STYPE_MAX(sizeof(int)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
949 r &= __lzo_assert(UINT_MAX == LZO_UTYPE_MAX(sizeof(unsigned)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
950 r &= __lzo_assert(LONG_MAX == LZO_STYPE_MAX(sizeof(long)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
951 r &= __lzo_assert(ULONG_MAX == LZO_UTYPE_MAX(sizeof(unsigned long)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
952 r &= __lzo_assert(SHRT_MAX == LZO_STYPE_MAX(sizeof(short)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
953 r &= __lzo_assert(USHRT_MAX == LZO_UTYPE_MAX(sizeof(unsigned short)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
954 r &= __lzo_assert(LZO_UINT32_MAX == LZO_UTYPE_MAX(sizeof(lzo_uint32)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
955 r &= __lzo_assert(LZO_UINT_MAX == LZO_UTYPE_MAX(sizeof(lzo_uint)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
956 #if !defined(__LZO_IN_MINILZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
957 r &= __lzo_assert(SIZE_T_MAX == LZO_UTYPE_MAX(sizeof(size_t)));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
958 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
959 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
960
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
961 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
962 r &= __lzo_assert(LZO_BYTE(257) == 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
963 r &= __lzo_assert(LZO_USHORT(65537L) == 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
964 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
965
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
966 return r;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
967 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
968
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
969 static lzo_bool basic_ptr_check(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
970 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
971 lzo_bool r = 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
972 lzo_bool sanity;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
973
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
974 r &= __lzo_assert(sizeof(char *) >= sizeof(int));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
975 r &= __lzo_assert(sizeof(lzo_byte *) >= sizeof(char *));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
976
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
977 r &= __lzo_assert(sizeof(lzo_voidp) == sizeof(lzo_byte *));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
978 r &= __lzo_assert(sizeof(lzo_voidp) == sizeof(lzo_voidpp));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
979 r &= __lzo_assert(sizeof(lzo_voidp) == sizeof(lzo_bytepp));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
980 r &= __lzo_assert(sizeof(lzo_voidp) >= sizeof(lzo_uint));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
981
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
982 r &= __lzo_assert(sizeof(lzo_ptr_t) == sizeof(lzo_voidp));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
983 r &= __lzo_assert(sizeof(lzo_ptr_t) >= sizeof(lzo_uint));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
984
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
985 r &= __lzo_assert(sizeof(lzo_ptrdiff_t) >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
986 r &= __lzo_assert(sizeof(lzo_ptrdiff_t) >= sizeof(ptrdiff_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
987
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
988 #if defined(SIZEOF_CHAR_P)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
989 r &= __lzo_assert(SIZEOF_CHAR_P == sizeof(char *));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
990 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
991 #if defined(SIZEOF_PTRDIFF_T)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
992 r &= __lzo_assert(SIZEOF_PTRDIFF_T == sizeof(ptrdiff_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
993 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
994
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
995 sanity = IS_UNSIGNED(unsigned short) && IS_UNSIGNED(unsigned) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
996 IS_UNSIGNED(unsigned long) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
997 IS_SIGNED(short) && IS_SIGNED(int) && IS_SIGNED(long);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
998 if (sanity)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
999 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1000 r &= __lzo_assert(IS_UNSIGNED(lzo_ptr_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1001 r &= __lzo_assert(IS_UNSIGNED(lzo_moff_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1002 r &= __lzo_assert(IS_SIGNED(lzo_ptrdiff_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1003 r &= __lzo_assert(IS_SIGNED(lzo_sptr_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1004 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1005
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1006 return r;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1007 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1008
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1009 static lzo_bool ptr_check(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1010 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1011 lzo_bool r = 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1012 int i;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1013 char _wrkmem[10 * sizeof(lzo_byte *) + sizeof(lzo_align_t)];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1014 lzo_byte *wrkmem;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1015 lzo_bytepp dict;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1016 unsigned char x[4 * sizeof(lzo_align_t)];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1017 long d;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1018 lzo_align_t a;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1019
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1020 for (i = 0; i < (int) sizeof(x); i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1021 x[i] = LZO_BYTE(i);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1022
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1023 wrkmem = LZO_PTR_ALIGN_UP((lzo_byte *)_wrkmem,sizeof(lzo_align_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1024 dict = (lzo_bytepp) wrkmem;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1025
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1026 d = (long) ((const lzo_bytep) dict - (const lzo_bytep) _wrkmem);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1027 r &= __lzo_assert(d >= 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1028 r &= __lzo_assert(d < (long) sizeof(lzo_align_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1029
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1030 memset(&a,0xff,sizeof(a));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1031 r &= __lzo_assert(a.a_ushort == USHRT_MAX);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1032 r &= __lzo_assert(a.a_uint == UINT_MAX);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1033 r &= __lzo_assert(a.a_ulong == ULONG_MAX);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1034 r &= __lzo_assert(a.a_lzo_uint == LZO_UINT_MAX);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1035
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1036 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1037 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1038 for (i = 0; i < 8; i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1039 r &= __lzo_assert((const lzo_voidp) (&dict[i]) == (const lzo_voidp) (&wrkmem[i * sizeof(lzo_byte *)]));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1040 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1041
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1042 memset(&a,0,sizeof(a));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1043 r &= __lzo_assert(a.a_charp == NULL);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1044 r &= __lzo_assert(a.a_lzo_bytep == NULL);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1045 //r &= __lzo_assert(NULL == 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1046 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1047 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1048 for (i = 0; i < 10; i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1049 dict[i] = wrkmem;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1050 BZERO8_PTR(dict+1,sizeof(dict[0]),8);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1051 r &= __lzo_assert(dict[0] == wrkmem);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1052 for (i = 1; i < 9; i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1053 r &= __lzo_assert(dict[i] == NULL);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1054 r &= __lzo_assert(dict[9] == wrkmem);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1055 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1056
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1057 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1058 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1059 unsigned k = 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1060 const unsigned n = (unsigned) sizeof(lzo_uint32);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1061 lzo_byte *p0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1062 lzo_byte *p1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1063
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1064 k += __lzo_align_gap(&x[k],n);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1065 p0 = (lzo_bytep) &x[k];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1066 #if defined(PTR_LINEAR)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1067 r &= __lzo_assert((PTR_LINEAR(p0) & (n-1)) == 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1068 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1069 r &= __lzo_assert(n == 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1070 r &= __lzo_assert(PTR_ALIGNED_4(p0));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1071 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1072
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1073 r &= __lzo_assert(k >= 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1074 p1 = (lzo_bytep) &x[1];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1075 r &= __lzo_assert(PTR_GE(p0,p1));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1076
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1077 r &= __lzo_assert(k < 1+n);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1078 p1 = (lzo_bytep) &x[1+n];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1079 r &= __lzo_assert(PTR_LT(p0,p1));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1080
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1081 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1082 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1083 lzo_uint32 v0 = * (lzo_uint32 *) &x[k];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1084 lzo_uint32 v1 = * (lzo_uint32 *) &x[k+n];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1085
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1086 r &= __lzo_assert(v0 > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1087 r &= __lzo_assert(v1 > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1088 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1089 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1090
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1091 return r;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1092 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1093
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1094 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1095 _lzo_config_check(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1096 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1097 lzo_bool r = 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1098 int i;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1099 union {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1100 lzo_uint32 a;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1101 unsigned short b;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1102 lzo_uint32 aa[4];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1103 unsigned char x[4*sizeof(lzo_align_t)];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1104 } u;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1105
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1106 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1107 r &= __lzo_assert((const void *)&u == (const void *)&u.a);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1108 r &= __lzo_assert((const void *)&u == (const void *)&u.b);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1109 r &= __lzo_assert((const void *)&u == (const void *)&u.x[0]);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1110 r &= __lzo_assert((const void *)&u == (const void *)&u.aa[0]);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1111 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1112
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1113 r &= basic_integral_check();
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1114 r &= basic_ptr_check();
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1115 if (r != 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1116 return LZO_E_ERROR;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1117
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1118 u.a = 0; u.b = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1119 for (i = 0; i < (int) sizeof(u.x); i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1120 u.x[i] = LZO_BYTE(i);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1121
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1122 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1123 r &= __lzo_assert( (int) (unsigned char) ((char) -1) == 255);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1124 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1125
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1126 #if defined(LZO_BYTE_ORDER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1127 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1128 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1129 # if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1130 lzo_uint32 a = (lzo_uint32) (u.a & LZO_0xffffffffL);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1131 unsigned short b = (unsigned short) (u.b & 0xffff);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1132 r &= __lzo_assert(a == 0x03020100L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1133 r &= __lzo_assert(b == 0x0100);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1134 # elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1135 lzo_uint32 a = u.a >> (8 * sizeof(u.a) - 32);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1136 unsigned short b = u.b >> (8 * sizeof(u.b) - 16);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1137 r &= __lzo_assert(a == 0x00010203L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1138 r &= __lzo_assert(b == 0x0001);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1139 # else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1140 # error invalid LZO_BYTE_ORDER
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1141 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1142 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1143 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1144
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1145 #if defined(LZO_UNALIGNED_OK_2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1146 r &= __lzo_assert(sizeof(short) == 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1147 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1148 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1149 unsigned short b[4];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1150
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1151 for (i = 0; i < 4; i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1152 b[i] = * (const unsigned short *) &u.x[i];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1153
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1154 # if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1155 r &= __lzo_assert(b[0] == 0x0100);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1156 r &= __lzo_assert(b[1] == 0x0201);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1157 r &= __lzo_assert(b[2] == 0x0302);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1158 r &= __lzo_assert(b[3] == 0x0403);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1159 # elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1160 r &= __lzo_assert(b[0] == 0x0001);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1161 r &= __lzo_assert(b[1] == 0x0102);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1162 r &= __lzo_assert(b[2] == 0x0203);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1163 r &= __lzo_assert(b[3] == 0x0304);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1164 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1165 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1166 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1167
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1168 #if defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1169 r &= __lzo_assert(sizeof(lzo_uint32) == 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1170 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1171 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1172 lzo_uint32 a[4];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1173
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1174 for (i = 0; i < 4; i++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1175 a[i] = * (const lzo_uint32 *) &u.x[i];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1176
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1177 # if (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1178 r &= __lzo_assert(a[0] == 0x03020100L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1179 r &= __lzo_assert(a[1] == 0x04030201L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1180 r &= __lzo_assert(a[2] == 0x05040302L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1181 r &= __lzo_assert(a[3] == 0x06050403L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1182 # elif (LZO_BYTE_ORDER == LZO_BIG_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1183 r &= __lzo_assert(a[0] == 0x00010203L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1184 r &= __lzo_assert(a[1] == 0x01020304L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1185 r &= __lzo_assert(a[2] == 0x02030405L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1186 r &= __lzo_assert(a[3] == 0x03040506L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1187 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1188 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1189 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1190
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1191 #if defined(LZO_ALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1192 r &= __lzo_assert(sizeof(lzo_uint32) == 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1193 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1194
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1195 r &= __lzo_assert(lzo_sizeof_dict_t == sizeof(lzo_dict_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1196
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1197 #if defined(__LZO_IN_MINLZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1198 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1199 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1200 lzo_uint32 adler;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1201 adler = lzo_adler32(0, NULL, 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1202 adler = lzo_adler32(adler, lzo_copyright(), 200);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1203 r &= __lzo_assert(adler == 0x7ea34377L);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1204 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1205 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1206
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1207 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1208 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1209 r &= __lzo_assert(!schedule_insns_bug());
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1210 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1211
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1212 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1213 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1214 static int x[3];
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1215 static unsigned xn = 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1216 register unsigned j;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1217
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1218 for (j = 0; j < xn; j++)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1219 x[j] = (int)j - 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1220 r &= __lzo_assert(!strength_reduce_bug(x));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1221 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1222
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1223 if (r == 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1224 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1225 r &= ptr_check();
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1226 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1227
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1228 return r == 1 ? LZO_E_OK : LZO_E_ERROR;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1229 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1230
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1231 static lzo_bool schedule_insns_bug(void)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1232 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1233 #if defined(__LZO_CHECKER)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1234 return 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1235 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1236 const int clone[] = {1, 2, 0};
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1237 const int *q;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1238 q = clone;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1239 return (*q) ? 0 : 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1240 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1241 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1242
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1243 static lzo_bool strength_reduce_bug(int *x)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1244 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1245 return x[0] != -3 || x[1] != -2 || x[2] != -1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1246 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1247
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1248 int __lzo_init_done = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1249
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1250 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1251 __lzo_init2(unsigned v, int s1, int s2, int s3, int s4, int s5,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1252 int s6, int s7, int s8, int s9)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1253 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1254 int r;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1255
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1256 __lzo_init_done = 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1257
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1258 if (v == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1259 return LZO_E_ERROR;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1260
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1261 r = (s1 == -1 || s1 == (int) sizeof(short)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1262 (s2 == -1 || s2 == (int) sizeof(int)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1263 (s3 == -1 || s3 == (int) sizeof(long)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1264 (s4 == -1 || s4 == (int) sizeof(lzo_uint32)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1265 (s5 == -1 || s5 == (int) sizeof(lzo_uint)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1266 (s6 == -1 || s6 == (int) lzo_sizeof_dict_t) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1267 (s7 == -1 || s7 == (int) sizeof(char *)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1268 (s8 == -1 || s8 == (int) sizeof(lzo_voidp)) &&
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1269 (s9 == -1 || s9 == (int) sizeof(lzo_compress_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1270 if (!r)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1271 return LZO_E_ERROR;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1272
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1273 r = _lzo_config_check();
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1274 if (r != LZO_E_OK)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1275 return r;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1276
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1277 return r;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1278 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1279
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1280 #if !defined(__LZO_IN_MINILZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1281
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1282 LZO_EXTERN(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1283 __lzo_init(unsigned v,int s1,int s2,int s3,int s4,int s5,int s6,int s7);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1284
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1285 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1286 __lzo_init(unsigned v,int s1,int s2,int s3,int s4,int s5,int s6,int s7)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1287 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1288 if (v == 0 || v > 0x1010)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1289 return LZO_E_ERROR;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1290 return __lzo_init2(v,s1,s2,s3,s4,s5,-1,-1,s6,s7);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1291 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1292
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1293 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1294
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1295 #define do_compress _lzo1x_1_do_compress
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1296
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1297 #define LZO_NEED_DICT_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1298 #define D_BITS 14
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1299 #define D_INDEX1(d,p) d = DM((0x21*DX3(p,5,5,6)) >> 5)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1300 #define D_INDEX2(d,p) d = (d & (D_MASK & 0x7ff)) ^ (D_HIGH | 0x1f)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1301
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1302 #ifndef __LZO_CONFIG1X_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1303 #define __LZO_CONFIG1X_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1304
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1305 #if !defined(LZO1X) && !defined(LZO1Y) && !defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1306 # define LZO1X
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1307 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1308
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1309 #if !defined(__LZO_IN_MINILZO)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1310 #include <lzo1x.h>
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1311 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1312
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1313 #define LZO_EOF_CODE
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1314 #undef LZO_DETERMINISTIC
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1315
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1316 #define M1_MAX_OFFSET 0x0400
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1317 #ifndef M2_MAX_OFFSET
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1318 #define M2_MAX_OFFSET 0x0800
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1319 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1320 #define M3_MAX_OFFSET 0x4000
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1321 #define M4_MAX_OFFSET 0xbfff
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1322
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1323 #define MX_MAX_OFFSET (M1_MAX_OFFSET + M2_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1324
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1325 #define M1_MIN_LEN 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1326 #define M1_MAX_LEN 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1327 #define M2_MIN_LEN 3
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1328 #ifndef M2_MAX_LEN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1329 #define M2_MAX_LEN 8
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1330 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1331 #define M3_MIN_LEN 3
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1332 #define M3_MAX_LEN 33
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1333 #define M4_MIN_LEN 3
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1334 #define M4_MAX_LEN 9
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1335
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1336 #define M1_MARKER 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1337 #define M2_MARKER 64
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1338 #define M3_MARKER 32
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1339 #define M4_MARKER 16
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1340
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1341 #ifndef MIN_LOOKAHEAD
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1342 #define MIN_LOOKAHEAD (M2_MAX_LEN + 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1343 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1344
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1345 #if defined(LZO_NEED_DICT_H)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1346
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1347 #ifndef LZO_HASH
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1348 #define LZO_HASH LZO_HASH_LZO_INCREMENTAL_B
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1349 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1350 #define DL_MIN_LEN M2_MIN_LEN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1351
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1352 #ifndef __LZO_DICT_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1353 #define __LZO_DICT_H
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1354
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1355 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1356 extern "C" {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1357 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1358
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1359 #if !defined(D_BITS) && defined(DBITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1360 # define D_BITS DBITS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1361 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1362 #if !defined(D_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1363 # error D_BITS is not defined
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1364 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1365 #if (D_BITS < 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1366 # define D_SIZE LZO_SIZE(D_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1367 # define D_MASK LZO_MASK(D_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1368 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1369 # define D_SIZE LZO_USIZE(D_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1370 # define D_MASK LZO_UMASK(D_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1371 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1372 #define D_HIGH ((D_MASK >> 1) + 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1373
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1374 #if !defined(DD_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1375 # define DD_BITS 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1376 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1377 #define DD_SIZE LZO_SIZE(DD_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1378 #define DD_MASK LZO_MASK(DD_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1379
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1380 #if !defined(DL_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1381 # define DL_BITS (D_BITS - DD_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1382 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1383 #if (DL_BITS < 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1384 # define DL_SIZE LZO_SIZE(DL_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1385 # define DL_MASK LZO_MASK(DL_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1386 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1387 # define DL_SIZE LZO_USIZE(DL_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1388 # define DL_MASK LZO_UMASK(DL_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1389 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1390
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1391 #if (D_BITS != DL_BITS + DD_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1392 # error D_BITS does not match
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1393 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1394 #if (D_BITS < 8 || D_BITS > 18)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1395 # error invalid D_BITS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1396 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1397 #if (DL_BITS < 8 || DL_BITS > 20)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1398 # error invalid DL_BITS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1399 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1400 #if (DD_BITS < 0 || DD_BITS > 6)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1401 # error invalid DD_BITS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1402 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1403
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1404 #if !defined(DL_MIN_LEN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1405 # define DL_MIN_LEN 3
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1406 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1407 #if !defined(DL_SHIFT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1408 # define DL_SHIFT ((DL_BITS + (DL_MIN_LEN - 1)) / DL_MIN_LEN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1409 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1410
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1411 #define LZO_HASH_GZIP 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1412 #define LZO_HASH_GZIP_INCREMENTAL 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1413 #define LZO_HASH_LZO_INCREMENTAL_A 3
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1414 #define LZO_HASH_LZO_INCREMENTAL_B 4
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1415
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1416 #if !defined(LZO_HASH)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1417 # error choose a hashing strategy
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1418 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1419
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1420 #if (DL_MIN_LEN == 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1421 # define _DV2_A(p,shift1,shift2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1422 (((( (lzo_uint32)((p)[0]) << shift1) ^ (p)[1]) << shift2) ^ (p)[2])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1423 # define _DV2_B(p,shift1,shift2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1424 (((( (lzo_uint32)((p)[2]) << shift1) ^ (p)[1]) << shift2) ^ (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1425 # define _DV3_B(p,shift1,shift2,shift3) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1426 ((_DV2_B((p)+1,shift1,shift2) << (shift3)) ^ (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1427 #elif (DL_MIN_LEN == 2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1428 # define _DV2_A(p,shift1,shift2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1429 (( (lzo_uint32)(p[0]) << shift1) ^ p[1])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1430 # define _DV2_B(p,shift1,shift2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1431 (( (lzo_uint32)(p[1]) << shift1) ^ p[2])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1432 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1433 # error invalid DL_MIN_LEN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1434 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1435 #define _DV_A(p,shift) _DV2_A(p,shift,shift)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1436 #define _DV_B(p,shift) _DV2_B(p,shift,shift)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1437 #define DA2(p,s1,s2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1438 (((((lzo_uint32)((p)[2]) << (s2)) + (p)[1]) << (s1)) + (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1439 #define DS2(p,s1,s2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1440 (((((lzo_uint32)((p)[2]) << (s2)) - (p)[1]) << (s1)) - (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1441 #define DX2(p,s1,s2) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1442 (((((lzo_uint32)((p)[2]) << (s2)) ^ (p)[1]) << (s1)) ^ (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1443 #define DA3(p,s1,s2,s3) ((DA2((p)+1,s2,s3) << (s1)) + (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1444 #define DS3(p,s1,s2,s3) ((DS2((p)+1,s2,s3) << (s1)) - (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1445 #define DX3(p,s1,s2,s3) ((DX2((p)+1,s2,s3) << (s1)) ^ (p)[0])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1446 #define DMS(v,s) ((lzo_uint) (((v) & (D_MASK >> (s))) << (s)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1447 #define DM(v) DMS(v,0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1448
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1449 #if (LZO_HASH == LZO_HASH_GZIP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1450 # define _DINDEX(dv,p) (_DV_A((p),DL_SHIFT))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1451
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1452 #elif (LZO_HASH == LZO_HASH_GZIP_INCREMENTAL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1453 # define __LZO_HASH_INCREMENTAL
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1454 # define DVAL_FIRST(dv,p) dv = _DV_A((p),DL_SHIFT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1455 # define DVAL_NEXT(dv,p) dv = (((dv) << DL_SHIFT) ^ p[2])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1456 # define _DINDEX(dv,p) (dv)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1457 # define DVAL_LOOKAHEAD DL_MIN_LEN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1458
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1459 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_A)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1460 # define __LZO_HASH_INCREMENTAL
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1461 # define DVAL_FIRST(dv,p) dv = _DV_A((p),5)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1462 # define DVAL_NEXT(dv,p) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1463 dv ^= (lzo_uint32)(p[-1]) << (2*5); dv = (((dv) << 5) ^ p[2])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1464 # define _DINDEX(dv,p) ((0x9f5f * (dv)) >> 5)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1465 # define DVAL_LOOKAHEAD DL_MIN_LEN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1466
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1467 #elif (LZO_HASH == LZO_HASH_LZO_INCREMENTAL_B)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1468 # define __LZO_HASH_INCREMENTAL
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1469 # define DVAL_FIRST(dv,p) dv = _DV_B((p),5)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1470 # define DVAL_NEXT(dv,p) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1471 dv ^= p[-1]; dv = (((dv) >> 5) ^ ((lzo_uint32)(p[2]) << (2*5)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1472 # define _DINDEX(dv,p) ((0x9f5f * (dv)) >> 5)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1473 # define DVAL_LOOKAHEAD DL_MIN_LEN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1474
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1475 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1476 # error choose a hashing strategy
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1477 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1478
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1479 #ifndef DINDEX
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1480 #define DINDEX(dv,p) ((lzo_uint)((_DINDEX(dv,p)) & DL_MASK) << DD_BITS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1481 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1482 #if !defined(DINDEX1) && defined(D_INDEX1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1483 #define DINDEX1 D_INDEX1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1484 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1485 #if !defined(DINDEX2) && defined(D_INDEX2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1486 #define DINDEX2 D_INDEX2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1487 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1488
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1489 #if !defined(__LZO_HASH_INCREMENTAL)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1490 # define DVAL_FIRST(dv,p) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1491 # define DVAL_NEXT(dv,p) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1492 # define DVAL_LOOKAHEAD 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1493 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1494
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1495 #if !defined(DVAL_ASSERT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1496 #if defined(__LZO_HASH_INCREMENTAL) && !defined(NDEBUG)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1497 static void DVAL_ASSERT(lzo_uint32 dv, const lzo_byte *p)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1498 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1499 lzo_uint32 df;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1500 DVAL_FIRST(df,(p));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1501 assert(DINDEX(dv,p) == DINDEX(df,p));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1502 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1503 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1504 # define DVAL_ASSERT(dv,p) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1505 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1506 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1507
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1508 #if defined(LZO_DICT_USE_PTR)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1509 # define DENTRY(p,in) (p)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1510 # define GINDEX(m_pos,m_off,dict,dindex,in) m_pos = dict[dindex]
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1511 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1512 # define DENTRY(p,in) ((lzo_uint) ((p)-(in)))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1513 # define GINDEX(m_pos,m_off,dict,dindex,in) m_off = dict[dindex]
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1514 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1515
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1516 #if (DD_BITS == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1517
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1518 # define UPDATE_D(dict,drun,dv,p,in) dict[ DINDEX(dv,p) ] = DENTRY(p,in)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1519 # define UPDATE_I(dict,drun,index,p,in) dict[index] = DENTRY(p,in)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1520 # define UPDATE_P(ptr,drun,p,in) (ptr)[0] = DENTRY(p,in)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1521
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1522 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1523
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1524 # define UPDATE_D(dict,drun,dv,p,in) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1525 dict[ DINDEX(dv,p) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1526 # define UPDATE_I(dict,drun,index,p,in) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1527 dict[ (index) + drun++ ] = DENTRY(p,in); drun &= DD_MASK
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1528 # define UPDATE_P(ptr,drun,p,in) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1529 (ptr) [ drun++ ] = DENTRY(p,in); drun &= DD_MASK
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1530
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1531 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1532
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1533 #if defined(LZO_DICT_USE_PTR)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1534
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1535 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1536 (m_pos == NULL || (m_off = (lzo_moff_t) (ip - m_pos)) > max_offset)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1537
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1538 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1539 (BOUNDS_CHECKING_OFF_IN_EXPR( \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1540 (PTR_LT(m_pos,in) || \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1541 (m_off = (lzo_moff_t) PTR_DIFF(ip,m_pos)) <= 0 || \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1542 m_off > max_offset) ))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1543
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1544 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1545
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1546 #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1547 (m_off == 0 || \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1548 ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1549 (m_pos = (ip) - (m_off), 0) )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1550
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1551 #define LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,max_offset) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1552 ((lzo_moff_t) ((ip)-(in)) <= m_off || \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1553 ((m_off = (lzo_moff_t) ((ip)-(in)) - m_off) > max_offset) || \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1554 (m_pos = (ip) - (m_off), 0) )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1555
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1556 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1557
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1558 #if defined(LZO_DETERMINISTIC)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1559 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_DET
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1560 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1561 # define LZO_CHECK_MPOS LZO_CHECK_MPOS_NON_DET
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1562 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1563
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1564 #ifdef __cplusplus
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1565 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1566 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1567
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1568 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1569
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1570 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1571
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1572 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1573
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1574 #define DO_COMPRESS lzo1x_1_compress
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1575
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1576 static
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1577 lzo_uint do_compress ( const lzo_byte *in , lzo_uint in_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1578 lzo_byte *out, lzo_uint *out_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1579 lzo_voidp wrkmem )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1580 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1581 #if 0 && defined(__GNUC__) && defined(__i386__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1582 register const lzo_byte *ip __asm__("%esi");
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1583 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1584 register const lzo_byte *ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1585 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1586 lzo_byte *op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1587 const lzo_byte * const in_end = in + in_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1588 const lzo_byte * const ip_end = in + in_len - M2_MAX_LEN - 5;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1589 const lzo_byte *ii;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1590 lzo_dict_p const dict = (lzo_dict_p) wrkmem;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1591
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1592 op = out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1593 ip = in;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1594 ii = ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1595
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1596 ip += 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1597 for (;;)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1598 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1599 #if 0 && defined(__GNUC__) && defined(__i386__)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1600 register const lzo_byte *m_pos __asm__("%edi");
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1601 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1602 register const lzo_byte *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1603 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1604 lzo_moff_t m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1605 lzo_uint m_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1606 lzo_uint dindex;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1607
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1608 DINDEX1(dindex,ip);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1609 GINDEX(m_pos,m_off,dict,dindex,in);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1610 if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1611 goto literal;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1612 #if 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1613 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1614 goto try_match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1615 DINDEX2(dindex,ip);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1616 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1617 GINDEX(m_pos,m_off,dict,dindex,in);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1618 if (LZO_CHECK_MPOS_NON_DET(m_pos,m_off,in,ip,M4_MAX_OFFSET))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1619 goto literal;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1620 if (m_off <= M2_MAX_OFFSET || m_pos[3] == ip[3])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1621 goto try_match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1622 goto literal;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1623
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1624 try_match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1625 #if 1 && defined(LZO_UNALIGNED_OK_2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1626 if (* (const lzo_ushortp) m_pos != * (const lzo_ushortp) ip)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1627 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1628 if (m_pos[0] != ip[0] || m_pos[1] != ip[1])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1629 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1630 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1631 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1632 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1633 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1634 if (m_pos[2] == ip[2])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1635 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1636 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1637 if (m_off <= M2_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1638 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1639 if (lit <= 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1640 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1641 if (lit == 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1642 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1643 assert(op - 2 > out); op[-2] |= LZO_BYTE(3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1644 *op++ = *ii++; *op++ = *ii++; *op++ = *ii++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1645 goto code_match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1646 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1647 if (m_pos[3] == ip[3])
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1648 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1649 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1650 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1651 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1652 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1653 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1654 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1655 if (m_off <= M1_MAX_OFFSET && lit > 0 && lit <= 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1656 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1657 if (m_off <= M1_MAX_OFFSET && lit == 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1658 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1659 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1660 register lzo_uint t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1661
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1662 t = lit;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1663 assert(op - 2 > out); op[-2] |= LZO_BYTE(t);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1664 do *op++ = *ii++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1665 assert(ii == ip);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1666 m_off -= 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1667 *op++ = LZO_BYTE(M1_MARKER | ((m_off & 3) << 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1668 *op++ = LZO_BYTE(m_off >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1669 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1670 goto match_done;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1671 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1672 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1673 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1674 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1675
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1676 literal:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1677 UPDATE_I(dict,0,dindex,ip,in);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1678 ++ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1679 if (ip >= ip_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1680 break;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1681 continue;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1682
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1683 match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1684 UPDATE_I(dict,0,dindex,ip,in);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1685 if (ip - ii > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1686 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1687 register lzo_uint t = ip - ii;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1688
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1689 if (t <= 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1690 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1691 assert(op - 2 > out);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1692 op[-2] |= LZO_BYTE(t);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1693 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1694 else if (t <= 18)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1695 *op++ = LZO_BYTE(t - 3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1696 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1697 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1698 register lzo_uint tt = t - 18;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1699
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1700 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1701 while (tt > 255)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1702 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1703 tt -= 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1704 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1705 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1706 assert(tt > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1707 *op++ = LZO_BYTE(tt);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1708 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1709 do *op++ = *ii++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1710 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1711
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1712 assert(ii == ip);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1713 ip += 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1714 if (m_pos[3] != *ip++ || m_pos[4] != *ip++ || m_pos[5] != *ip++ ||
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1715 m_pos[6] != *ip++ || m_pos[7] != *ip++ || m_pos[8] != *ip++
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1716 #ifdef LZO1Y
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1717 || m_pos[ 9] != *ip++ || m_pos[10] != *ip++ || m_pos[11] != *ip++
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1718 || m_pos[12] != *ip++ || m_pos[13] != *ip++ || m_pos[14] != *ip++
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1719 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1720 )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1721 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1722 --ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1723 m_len = ip - ii;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1724 assert(m_len >= 3); assert(m_len <= M2_MAX_LEN);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1725
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1726 if (m_off <= M2_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1727 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1728 m_off -= 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1729 #if defined(LZO1X)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1730 *op++ = LZO_BYTE(((m_len - 1) << 5) | ((m_off & 7) << 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1731 *op++ = LZO_BYTE(m_off >> 3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1732 #elif defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1733 *op++ = LZO_BYTE(((m_len + 1) << 4) | ((m_off & 3) << 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1734 *op++ = LZO_BYTE(m_off >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1735 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1736 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1737 else if (m_off <= M3_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1738 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1739 m_off -= 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1740 *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1741 goto m3_m4_offset;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1742 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1743 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1744 #if defined(LZO1X)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1745 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1746 m_off -= 0x4000;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1747 assert(m_off > 0); assert(m_off <= 0x7fff);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1748 *op++ = LZO_BYTE(M4_MARKER |
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1749 ((m_off & 0x4000) >> 11) | (m_len - 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1750 goto m3_m4_offset;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1751 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1752 #elif defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1753 goto m4_match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1754 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1755 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1756 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1757 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1758 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1759 const lzo_byte *end = in_end;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1760 const lzo_byte *m = m_pos + M2_MAX_LEN + 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1761 while (ip < end && *m == *ip)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1762 m++, ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1763 m_len = (ip - ii);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1764 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1765 assert(m_len > M2_MAX_LEN);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1766
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1767 if (m_off <= M3_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1768 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1769 m_off -= 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1770 if (m_len <= 33)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1771 *op++ = LZO_BYTE(M3_MARKER | (m_len - 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1772 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1773 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1774 m_len -= 33;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1775 *op++ = M3_MARKER | 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1776 goto m3_m4_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1777 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1778 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1779 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1780 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1781 #if defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1782 m4_match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1783 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1784 m_off -= 0x4000;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1785 assert(m_off > 0); assert(m_off <= 0x7fff);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1786 if (m_len <= M4_MAX_LEN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1787 *op++ = LZO_BYTE(M4_MARKER |
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1788 ((m_off & 0x4000) >> 11) | (m_len - 2));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1789 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1790 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1791 m_len -= M4_MAX_LEN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1792 *op++ = LZO_BYTE(M4_MARKER | ((m_off & 0x4000) >> 11));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1793 m3_m4_len:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1794 while (m_len > 255)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1795 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1796 m_len -= 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1797 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1798 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1799 assert(m_len > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1800 *op++ = LZO_BYTE(m_len);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1801 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1802 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1803
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1804 m3_m4_offset:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1805 *op++ = LZO_BYTE((m_off & 63) << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1806 *op++ = LZO_BYTE(m_off >> 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1807 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1808
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1809 #if 0
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1810 match_done:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1811 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1812 ii = ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1813 if (ip >= ip_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1814 break;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1815 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1816
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1817 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1818 return (lzo_uint) (in_end - ii);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1819 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1820
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1821 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1822 DO_COMPRESS ( const lzo_byte *in , lzo_uint in_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1823 lzo_byte *out, lzo_uint *out_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1824 lzo_voidp wrkmem )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1825 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1826 lzo_byte *op = out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1827 lzo_uint t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1828
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1829 #if defined(__LZO_QUERY_COMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1830 if (__LZO_IS_COMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1831 return __LZO_QUERY_COMPRESS(in,in_len,out,out_len,wrkmem,D_SIZE,lzo_sizeof(lzo_dict_t));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1832 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1833
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1834 if (in_len <= M2_MAX_LEN + 5)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1835 t = in_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1836 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1837 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1838 t = do_compress(in,in_len,op,out_len,wrkmem);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1839 op += *out_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1840 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1841
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1842 if (t > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1843 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1844 const lzo_byte *ii = in + in_len - t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1845
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1846 if (op == out && t <= 238)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1847 *op++ = LZO_BYTE(17 + t);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1848 else if (t <= 3)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1849 op[-2] |= LZO_BYTE(t);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1850 else if (t <= 18)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1851 *op++ = LZO_BYTE(t - 3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1852 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1853 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1854 lzo_uint tt = t - 18;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1855
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1856 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1857 while (tt > 255)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1858 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1859 tt -= 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1860 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1861 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1862 assert(tt > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1863 *op++ = LZO_BYTE(tt);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1864 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1865 do *op++ = *ii++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1866 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1867
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1868 *op++ = M4_MARKER | 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1869 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1870 *op++ = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1871
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1872 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1873 return LZO_E_OK;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1874 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1875
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1876 #undef do_compress
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1877 #undef DO_COMPRESS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1878 #undef LZO_HASH
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1879
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1880 #undef LZO_TEST_DECOMPRESS_OVERRUN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1881 #undef LZO_TEST_DECOMPRESS_OVERRUN_INPUT
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1882 #undef LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1883 #undef LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1884 #undef DO_DECOMPRESS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1885 #define DO_DECOMPRESS lzo1x_decompress
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1886
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1887 #if defined(LZO_TEST_DECOMPRESS_OVERRUN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1888 # if !defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1889 # define LZO_TEST_DECOMPRESS_OVERRUN_INPUT 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1890 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1891 # if !defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1892 # define LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1893 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1894 # if !defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1895 # define LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1896 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1897 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1898
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1899 #undef TEST_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1900 #undef TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1901 #undef TEST_LOOKBEHIND
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1902 #undef NEED_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1903 #undef NEED_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1904 #undef HAVE_TEST_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1905 #undef HAVE_TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1906 #undef HAVE_NEED_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1907 #undef HAVE_NEED_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1908 #undef HAVE_ANY_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1909 #undef HAVE_ANY_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1910
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1911 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1912 # if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1913 # define TEST_IP (ip < ip_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1914 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1915 # if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1916 # define NEED_IP(x) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1917 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1918 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1919 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1920
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1921 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1922 # if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1923 # define TEST_OP (op <= op_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1924 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1925 # if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1926 # undef TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1927 # define NEED_OP(x) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1928 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1929 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1930 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1931
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1932 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1933 # define TEST_LOOKBEHIND(m_pos,out) if (m_pos < out) goto lookbehind_overrun
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1934 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1935 # define TEST_LOOKBEHIND(m_pos,op) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1936 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1937
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1938 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1939 # define TEST_IP (ip < ip_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1940 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1941
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1942 #if defined(TEST_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1943 # define HAVE_TEST_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1944 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1945 # define TEST_IP 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1946 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1947 #if defined(TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1948 # define HAVE_TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1949 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1950 # define TEST_OP 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1951 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1952
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1953 #if defined(NEED_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1954 # define HAVE_NEED_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1955 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1956 # define NEED_IP(x) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1957 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1958 #if defined(NEED_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1959 # define HAVE_NEED_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1960 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1961 # define NEED_OP(x) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1962 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1963
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1964 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1965 # define HAVE_ANY_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1966 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1967 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1968 # define HAVE_ANY_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1969 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1970
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1971 #if defined(DO_DECOMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1972 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1973 DO_DECOMPRESS ( const lzo_byte *in , lzo_uint in_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1974 lzo_byte *out, lzo_uint *out_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1975 lzo_voidp wrkmem )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1976 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1977 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1978 register lzo_byte *op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1979 register const lzo_byte *ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1980 register lzo_uint t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1981 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1982 lzo_uint m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1983 const lzo_byte *dict_end;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1984 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1985 register const lzo_byte *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1986 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1987
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1988 const lzo_byte * const ip_end = in + in_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1989 #if defined(HAVE_ANY_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1990 lzo_byte * const op_end = out + *out_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1991 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1992 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1993 lzo_uint last_m_off = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1994 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1995
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1996 LZO_UNUSED(wrkmem);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1997
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1998 #if defined(__LZO_QUERY_DECOMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
1999 if (__LZO_IS_DECOMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2000 return __LZO_QUERY_DECOMPRESS(in,in_len,out,out_len,wrkmem,0,0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2001 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2002
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2003 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2004 if (dict)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2005 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2006 if (dict_len > M4_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2007 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2008 dict += dict_len - M4_MAX_OFFSET;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2009 dict_len = M4_MAX_OFFSET;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2010 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2011 dict_end = dict + dict_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2012 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2013 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2014 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2015 dict_len = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2016 dict_end = NULL;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2017 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2018 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2019
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2020 *out_len = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2021
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2022 op = out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2023 ip = in;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2024
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2025 if (*ip > 17)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2026 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2027 t = *ip++ - 17;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2028 if (t < 4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2029 goto match_next;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2030 assert(t > 0); NEED_OP(t); NEED_IP(t+1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2031 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2032 goto first_literal_run;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2033 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2034
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2035 while (TEST_IP && TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2036 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2037 t = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2038 if (t >= 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2039 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2040 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2041 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2042 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2043 while (*ip == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2044 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2045 t += 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2046 ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2047 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2048 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2049 t += 15 + *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2050 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2051 assert(t > 0); NEED_OP(t+3); NEED_IP(t+4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2052 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2053 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2054 if (PTR_ALIGNED2_4(op,ip))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2055 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2056 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2057 * (lzo_uint32p) op = * (const lzo_uint32p) ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2058 op += 4; ip += 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2059 if (--t > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2060 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2061 if (t >= 4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2062 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2063 do {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2064 * (lzo_uint32p) op = * (const lzo_uint32p) ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2065 op += 4; ip += 4; t -= 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2066 } while (t >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2067 if (t > 0) do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2068 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2069 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2070 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2071 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2072 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2073 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2074 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2075 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2076 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2077 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2078 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2079 *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2080 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2081 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2082 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2083
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2084 first_literal_run:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2085
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2086 t = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2087 if (t >= 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2088 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2089 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2090 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2091 m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2092 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2093 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2094 m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2095 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2096 NEED_OP(3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2097 t = 3; COPY_DICT(t,m_off)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2098 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2099 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2100 t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2101 m_pos = op - t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2102 last_m_off = t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2103 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2104 m_pos = op - (1 + M2_MAX_OFFSET);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2105 m_pos -= t >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2106 m_pos -= *ip++ << 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2107 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2108 TEST_LOOKBEHIND(m_pos,out); NEED_OP(3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2109 *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2110 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2111 goto match_done;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2112
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2113 while (TEST_IP && TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2114 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2115 match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2116 if (t >= 64)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2117 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2118 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2119 #if defined(LZO1X)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2120 m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2121 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2122 #elif defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2123 m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2124 t = (t >> 4) - 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2125 #elif defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2126 m_off = t & 0x1f;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2127 if (m_off >= 0x1c)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2128 m_off = last_m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2129 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2130 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2131 m_off = 1 + (m_off << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2132 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2133 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2134 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2135 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2136 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2137 #if defined(LZO1X)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2138 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2139 m_pos -= (t >> 2) & 7;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2140 m_pos -= *ip++ << 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2141 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2142 #elif defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2143 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2144 m_pos -= (t >> 2) & 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2145 m_pos -= *ip++ << 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2146 t = (t >> 4) - 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2147 #elif defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2148 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2149 lzo_uint off = t & 0x1f;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2150 m_pos = op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2151 if (off >= 0x1c)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2152 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2153 assert(last_m_off > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2154 m_pos -= last_m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2155 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2156 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2157 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2158 off = 1 + (off << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2159 m_pos -= off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2160 last_m_off = off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2161 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2162 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2163 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2164 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2165 TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2166 goto copy_match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2167 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2168 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2169 else if (t >= 32)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2170 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2171 t &= 31;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2172 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2173 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2174 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2175 while (*ip == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2176 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2177 t += 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2178 ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2179 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2180 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2181 t += 31 + *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2182 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2183 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2184 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2185 m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2186 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2187 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2188 m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2189 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2190 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2191 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2192 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2193 lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2194 m_pos = op - off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2195 last_m_off = off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2196 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2197 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2198 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2199 m_pos -= (* (const lzo_ushortp) ip) >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2200 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2201 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2202 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2203 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2204 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2205 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2206 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2207 else if (t >= 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2208 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2209 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2210 m_off = (t & 8) << 11;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2211 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2212 m_pos = op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2213 m_pos -= (t & 8) << 11;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2214 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2215 t &= 7;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2216 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2217 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2218 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2219 while (*ip == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2220 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2221 t += 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2222 ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2223 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2224 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2225 t += 7 + *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2226 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2227 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2228 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2229 m_off += (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2230 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2231 m_off += (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2232 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2233 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2234 if (m_off == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2235 goto eof_found;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2236 m_off += 0x4000;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2237 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2238 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2239 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2240 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2241 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2242 m_pos -= (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2243 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2244 m_pos -= (* (const lzo_ushortp) ip) >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2245 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2246 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2247 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2248 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2249 if (m_pos == op)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2250 goto eof_found;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2251 m_pos -= 0x4000;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2252 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2253 last_m_off = op - m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2254 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2255 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2256 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2257 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2258 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2259 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2260 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2261 m_off = 1 + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2262 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2263 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2264 m_off = 1 + (t >> 2) + (*ip++ << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2265 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2266 NEED_OP(2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2267 t = 2; COPY_DICT(t,m_off)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2268 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2269 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2270 t = 1 + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2271 m_pos = op - t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2272 last_m_off = t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2273 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2274 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2275 m_pos -= t >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2276 m_pos -= *ip++ << 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2277 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2278 TEST_LOOKBEHIND(m_pos,out); NEED_OP(2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2279 *op++ = *m_pos++; *op++ = *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2280 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2281 goto match_done;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2282 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2283
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2284 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2285
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2286 NEED_OP(t+3-1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2287 t += 3-1; COPY_DICT(t,m_off)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2288
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2289 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2290
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2291 TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2292 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2293 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2294 if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2295 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2296 assert((op - m_pos) >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2297 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2298 if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2299 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2300 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2301 * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2302 op += 4; m_pos += 4; t -= 4 - (3 - 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2303 do {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2304 * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2305 op += 4; m_pos += 4; t -= 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2306 } while (t >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2307 if (t > 0) do *op++ = *m_pos++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2308 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2309 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2310 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2311 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2312 copy_match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2313 *op++ = *m_pos++; *op++ = *m_pos++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2314 do *op++ = *m_pos++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2315 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2316
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2317 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2318
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2319 match_done:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2320 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2321 t = ip[-1] & 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2322 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2323 t = ip[-2] & 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2324 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2325 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2326 break;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2327
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2328 match_next:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2329 assert(t > 0); NEED_OP(t); NEED_IP(t+1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2330 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2331 t = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2332 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2333 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2334
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2335 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2336 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2337 return LZO_E_EOF_NOT_FOUND;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2338 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2339
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2340 eof_found:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2341 assert(t == 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2342 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2343 return (ip == ip_end ? LZO_E_OK :
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2344 (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2345
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2346 #if defined(HAVE_NEED_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2347 input_overrun:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2348 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2349 return LZO_E_INPUT_OVERRUN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2350 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2351
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2352 #if defined(HAVE_NEED_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2353 output_overrun:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2354 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2355 return LZO_E_OUTPUT_OVERRUN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2356 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2357
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2358 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2359 lookbehind_overrun:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2360 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2361 return LZO_E_LOOKBEHIND_OVERRUN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2362 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2363 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2364
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2365 #define LZO_TEST_DECOMPRESS_OVERRUN
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2366 #undef DO_DECOMPRESS
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2367 #define DO_DECOMPRESS lzo1x_decompress_safe
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2368
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2369 #if defined(LZO_TEST_DECOMPRESS_OVERRUN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2370 # if !defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2371 # define LZO_TEST_DECOMPRESS_OVERRUN_INPUT 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2372 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2373 # if !defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2374 # define LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT 2
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2375 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2376 # if !defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2377 # define LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2378 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2379 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2380
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2381 #undef TEST_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2382 #undef TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2383 #undef TEST_LOOKBEHIND
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2384 #undef NEED_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2385 #undef NEED_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2386 #undef HAVE_TEST_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2387 #undef HAVE_TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2388 #undef HAVE_NEED_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2389 #undef HAVE_NEED_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2390 #undef HAVE_ANY_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2391 #undef HAVE_ANY_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2392
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2393 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_INPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2394 # if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2395 # define TEST_IP (ip < ip_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2396 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2397 # if (LZO_TEST_DECOMPRESS_OVERRUN_INPUT >= 2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2398 # define NEED_IP(x) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2399 if ((lzo_uint)(ip_end - ip) < (lzo_uint)(x)) goto input_overrun
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2400 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2401 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2402
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2403 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2404 # if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 1)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2405 # define TEST_OP (op <= op_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2406 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2407 # if (LZO_TEST_DECOMPRESS_OVERRUN_OUTPUT >= 2)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2408 # undef TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2409 # define NEED_OP(x) \
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2410 if ((lzo_uint)(op_end - op) < (lzo_uint)(x)) goto output_overrun
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2411 # endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2412 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2413
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2414 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2415 # define TEST_LOOKBEHIND(m_pos,out) if (m_pos < out) goto lookbehind_overrun
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2416 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2417 # define TEST_LOOKBEHIND(m_pos,op) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2418 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2419
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2420 #if !defined(LZO_EOF_CODE) && !defined(TEST_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2421 # define TEST_IP (ip < ip_end)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2422 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2423
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2424 #if defined(TEST_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2425 # define HAVE_TEST_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2426 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2427 # define TEST_IP 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2428 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2429 #if defined(TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2430 # define HAVE_TEST_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2431 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2432 # define TEST_OP 1
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2433 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2434
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2435 #if defined(NEED_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2436 # define HAVE_NEED_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2437 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2438 # define NEED_IP(x) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2439 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2440 #if defined(NEED_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2441 # define HAVE_NEED_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2442 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2443 # define NEED_OP(x) ((void) 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2444 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2445
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2446 #if defined(HAVE_TEST_IP) || defined(HAVE_NEED_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2447 # define HAVE_ANY_IP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2448 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2449 #if defined(HAVE_TEST_OP) || defined(HAVE_NEED_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2450 # define HAVE_ANY_OP
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2451 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2452
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2453 #if defined(DO_DECOMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2454 LZO_PUBLIC(int)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2455 DO_DECOMPRESS ( const lzo_byte *in , lzo_uint in_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2456 lzo_byte *out, lzo_uint *out_len,
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2457 lzo_voidp wrkmem )
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2458 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2459 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2460 register lzo_byte *op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2461 register const lzo_byte *ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2462 register lzo_uint t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2463 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2464 lzo_uint m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2465 const lzo_byte *dict_end;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2466 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2467 register const lzo_byte *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2468 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2469
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2470 const lzo_byte * const ip_end = in + in_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2471 #if defined(HAVE_ANY_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2472 lzo_byte * const op_end = out + *out_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2473 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2474 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2475 lzo_uint last_m_off = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2476 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2477
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2478 LZO_UNUSED(wrkmem);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2479
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2480 #if defined(__LZO_QUERY_DECOMPRESS)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2481 if (__LZO_IS_DECOMPRESS_QUERY(in,in_len,out,out_len,wrkmem))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2482 return __LZO_QUERY_DECOMPRESS(in,in_len,out,out_len,wrkmem,0,0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2483 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2484
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2485 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2486 if (dict)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2487 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2488 if (dict_len > M4_MAX_OFFSET)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2489 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2490 dict += dict_len - M4_MAX_OFFSET;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2491 dict_len = M4_MAX_OFFSET;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2492 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2493 dict_end = dict + dict_len;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2494 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2495 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2496 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2497 dict_len = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2498 dict_end = NULL;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2499 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2500 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2501
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2502 *out_len = 0;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2503
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2504 op = out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2505 ip = in;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2506
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2507 if (*ip > 17)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2508 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2509 t = *ip++ - 17;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2510 if (t < 4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2511 goto match_next;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2512 assert(t > 0); NEED_OP(t); NEED_IP(t+1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2513 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2514 goto first_literal_run;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2515 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2516
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2517 while (TEST_IP && TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2518 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2519 t = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2520 if (t >= 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2521 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2522 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2523 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2524 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2525 while (*ip == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2526 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2527 t += 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2528 ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2529 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2530 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2531 t += 15 + *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2532 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2533 assert(t > 0); NEED_OP(t+3); NEED_IP(t+4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2534 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2535 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2536 if (PTR_ALIGNED2_4(op,ip))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2537 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2538 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2539 * (lzo_uint32p) op = * (const lzo_uint32p) ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2540 op += 4; ip += 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2541 if (--t > 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2542 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2543 if (t >= 4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2544 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2545 do {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2546 * (lzo_uint32p) op = * (const lzo_uint32p) ip;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2547 op += 4; ip += 4; t -= 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2548 } while (t >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2549 if (t > 0) do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2550 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2551 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2552 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2553 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2554 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2555 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2556 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2557 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2558 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2559 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2560 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2561 *op++ = *ip++; *op++ = *ip++; *op++ = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2562 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2563 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2564 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2565
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2566 first_literal_run:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2567
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2568 t = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2569 if (t >= 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2570 goto match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2571 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2572 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2573 m_off = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2574 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2575 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2576 m_off = (1 + M2_MAX_OFFSET) + (t >> 2) + (*ip++ << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2577 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2578 NEED_OP(3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2579 t = 3; COPY_DICT(t,m_off)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2580 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2581 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2582 t = (1 + M2_MAX_OFFSET) + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2583 m_pos = op - t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2584 last_m_off = t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2585 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2586 m_pos = op - (1 + M2_MAX_OFFSET);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2587 m_pos -= t >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2588 m_pos -= *ip++ << 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2589 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2590 TEST_LOOKBEHIND(m_pos,out); NEED_OP(3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2591 *op++ = *m_pos++; *op++ = *m_pos++; *op++ = *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2592 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2593 goto match_done;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2594
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2595 while (TEST_IP && TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2596 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2597 match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2598 if (t >= 64)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2599 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2600 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2601 #if defined(LZO1X)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2602 m_off = 1 + ((t >> 2) & 7) + (*ip++ << 3);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2603 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2604 #elif defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2605 m_off = 1 + ((t >> 2) & 3) + (*ip++ << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2606 t = (t >> 4) - 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2607 #elif defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2608 m_off = t & 0x1f;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2609 if (m_off >= 0x1c)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2610 m_off = last_m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2611 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2612 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2613 m_off = 1 + (m_off << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2614 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2615 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2616 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2617 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2618 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2619 #if defined(LZO1X)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2620 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2621 m_pos -= (t >> 2) & 7;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2622 m_pos -= *ip++ << 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2623 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2624 #elif defined(LZO1Y)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2625 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2626 m_pos -= (t >> 2) & 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2627 m_pos -= *ip++ << 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2628 t = (t >> 4) - 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2629 #elif defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2630 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2631 lzo_uint off = t & 0x1f;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2632 m_pos = op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2633 if (off >= 0x1c)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2634 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2635 assert(last_m_off > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2636 m_pos -= last_m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2637 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2638 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2639 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2640 off = 1 + (off << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2641 m_pos -= off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2642 last_m_off = off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2643 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2644 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2645 t = (t >> 5) - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2646 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2647 TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2648 goto copy_match;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2649 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2650 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2651 else if (t >= 32)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2652 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2653 t &= 31;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2654 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2655 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2656 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2657 while (*ip == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2658 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2659 t += 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2660 ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2661 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2662 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2663 t += 31 + *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2664 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2665 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2666 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2667 m_off = 1 + (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2668 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2669 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2670 m_off = 1 + (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2671 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2672 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2673 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2674 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2675 lzo_uint off = 1 + (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2676 m_pos = op - off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2677 last_m_off = off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2678 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2679 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2680 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2681 m_pos -= (* (const lzo_ushortp) ip) >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2682 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2683 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2684 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2685 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2686 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2687 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2688 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2689 else if (t >= 16)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2690 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2691 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2692 m_off = (t & 8) << 11;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2693 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2694 m_pos = op;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2695 m_pos -= (t & 8) << 11;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2696 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2697 t &= 7;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2698 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2699 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2700 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2701 while (*ip == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2702 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2703 t += 255;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2704 ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2705 NEED_IP(1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2706 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2707 t += 7 + *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2708 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2709 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2710 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2711 m_off += (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2712 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2713 m_off += (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2714 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2715 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2716 if (m_off == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2717 goto eof_found;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2718 m_off += 0x4000;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2719 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2720 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2721 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2722 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2723 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2724 m_pos -= (ip[0] << 6) + (ip[1] >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2725 #elif defined(LZO_UNALIGNED_OK_2) && (LZO_BYTE_ORDER == LZO_LITTLE_ENDIAN)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2726 m_pos -= (* (const lzo_ushortp) ip) >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2727 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2728 m_pos -= (ip[0] >> 2) + (ip[1] << 6);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2729 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2730 ip += 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2731 if (m_pos == op)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2732 goto eof_found;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2733 m_pos -= 0x4000;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2734 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2735 last_m_off = op - m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2736 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2737 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2738 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2739 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2740 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2741 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2742 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2743 m_off = 1 + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2744 last_m_off = m_off;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2745 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2746 m_off = 1 + (t >> 2) + (*ip++ << 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2747 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2748 NEED_OP(2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2749 t = 2; COPY_DICT(t,m_off)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2750 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2751 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2752 t = 1 + (t << 6) + (*ip++ >> 2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2753 m_pos = op - t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2754 last_m_off = t;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2755 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2756 m_pos = op - 1;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2757 m_pos -= t >> 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2758 m_pos -= *ip++ << 2;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2759 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2760 TEST_LOOKBEHIND(m_pos,out); NEED_OP(2);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2761 *op++ = *m_pos++; *op++ = *m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2762 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2763 goto match_done;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2764 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2765
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2766 #if defined(COPY_DICT)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2767
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2768 NEED_OP(t+3-1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2769 t += 3-1; COPY_DICT(t,m_off)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2770
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2771 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2772
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2773 TEST_LOOKBEHIND(m_pos,out); assert(t > 0); NEED_OP(t+3-1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2774 #if defined(LZO_UNALIGNED_OK_4) || defined(LZO_ALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2775 #if !defined(LZO_UNALIGNED_OK_4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2776 if (t >= 2 * 4 - (3 - 1) && PTR_ALIGNED2_4(op,m_pos))
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2777 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2778 assert((op - m_pos) >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2779 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2780 if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2781 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2782 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2783 * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2784 op += 4; m_pos += 4; t -= 4 - (3 - 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2785 do {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2786 * (lzo_uint32p) op = * (const lzo_uint32p) m_pos;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2787 op += 4; m_pos += 4; t -= 4;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2788 } while (t >= 4);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2789 if (t > 0) do *op++ = *m_pos++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2790 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2791 else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2792 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2793 {
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2794 copy_match:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2795 *op++ = *m_pos++; *op++ = *m_pos++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2796 do *op++ = *m_pos++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2797 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2798
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2799 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2800
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2801 match_done:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2802 #if defined(LZO1Z)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2803 t = ip[-1] & 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2804 #else
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2805 t = ip[-2] & 3;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2806 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2807 if (t == 0)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2808 break;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2809
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2810 match_next:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2811 assert(t > 0); NEED_OP(t); NEED_IP(t+1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2812 do *op++ = *ip++; while (--t > 0);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2813 t = *ip++;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2814 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2815 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2816
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2817 #if defined(HAVE_TEST_IP) || defined(HAVE_TEST_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2818 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2819 return LZO_E_EOF_NOT_FOUND;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2820 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2821
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2822 eof_found:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2823 assert(t == 1);
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2824 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2825 return (ip == ip_end ? LZO_E_OK :
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2826 (ip < ip_end ? LZO_E_INPUT_NOT_CONSUMED : LZO_E_INPUT_OVERRUN));
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2827
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2828 #if defined(HAVE_NEED_IP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2829 input_overrun:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2830 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2831 return LZO_E_INPUT_OVERRUN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2832 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2833
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2834 #if defined(HAVE_NEED_OP)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2835 output_overrun:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2836 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2837 return LZO_E_OUTPUT_OVERRUN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2838 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2839
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2840 #if defined(LZO_TEST_DECOMPRESS_OVERRUN_LOOKBEHIND)
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2841 lookbehind_overrun:
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2842 *out_len = op - out;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2843 return LZO_E_LOOKBEHIND_OVERRUN;
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2844 #endif
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2845 }
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2846
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2847 /***** End of minilzo.c *****/
b081763865d4 used by NuppelVideo
alex
parents:
diff changeset
2848