30 #define OUTBUF_PADDED 1
32 #define INBUF_PADDED 1
51 #define GETB(c) (*(c).in++)
53 #define GETB(c) get_byte(&(c))
65 while (!(x =
get_byte(c))) cnt += 255;
72 #define BUILTIN_MEMCPY
73 #ifdef UNALIGNED_LOADSTORE
74 #define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s);
75 #define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s);
76 #elif defined(BUILTIN_MEMCPY)
77 #define COPY2(d, s) memcpy(d, s, 2);
78 #define COPY4(d, s) memcpy(d, s, 4);
80 #define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1];
81 #define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3];
89 register const uint8_t *src = c->
in;
90 register uint8_t *dst = c->
out;
91 if (cnt > c->
in_end - src) {
99 #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
106 memcpy(dst, src, cnt);
111 static inline void memcpy_backptr(uint8_t *dst,
int back,
int cnt);
122 register uint8_t *dst = c->
out;
136 const uint8_t *src = &dst[-back];
138 memset(dst, *src, cnt);
142 COPY2(dst + 2, src + 2);
148 COPY2(dst + 2, src + 2);
149 COPY2(dst + 4, src + 4);
150 COPY2(dst + 6, src + 6);
158 while (cnt > blocklen) {
159 memcpy(dst, src, blocklen);
164 memcpy(dst, src, cnt);
177 if (!*outlen || !*inlen) {
186 c.
in_end = (
const uint8_t *)in + *inlen;
188 c.
out_end = (uint8_t *)out + * outlen;
203 back = (
GETB(c) << 3) + ((x >> 2) & 7) + 1;
207 back = (
GETB(c) << 6) + (x >> 2) + 1;
210 back = (1 << 14) + ((x & 8) << 11);
212 back += (
GETB(c) << 6) + (x >> 2);
213 if (back == (1 << 14)) {
226 back = (1 << 11) + (
GETB(c) << 2) + (x >> 2) + 1;
229 back = (
GETB(c) << 2) + (x >> 2) + 1;
246 #include <lzo/lzo1x.h>
248 #define MAXSZ (10*1024*1024)
252 #define BENCHMARK_LIBLZO_SAFE 0
253 #define BENCHMARK_LIBLZO_UNSAFE 0
255 int main(
int argc,
char *argv[]) {
256 FILE *in = fopen(argv[1],
"rb");
260 size_t s = fread(orig, 1, MAXSZ, in);
262 long tmp[LZO1X_MEM_COMPRESS];
266 lzo1x_999_compress(orig, s, comp, &clen, tmp);
267 for (i = 0; i < 300; i++) {
269 inlen = clen; outlen = MAXSZ;
270 #if BENCHMARK_LIBLZO_SAFE
271 if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen,
NULL))
272 #elif BENCHMARK_LIBLZO_UNSAFE
273 if (lzo1x_decompress(comp, inlen, decomp, &outlen,
NULL))
280 if (memcmp(orig, decomp, s))