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;
95 if (cnt > c->
in_end - src) {
103 #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
110 memcpy(dst, src, cnt);
115 static inline void memcpy_backptr(uint8_t *dst,
int back,
int cnt);
126 register uint8_t *dst = c->
out;
144 const uint8_t *src = &dst[-back];
146 memset(dst, *src, cnt);
150 COPY2(dst + 2, src + 2);
156 COPY2(dst + 2, src + 2);
157 COPY2(dst + 4, src + 4);
158 COPY2(dst + 6, src + 6);
166 while (cnt > blocklen) {
167 memcpy(dst, src, blocklen);
172 memcpy(dst, src, cnt);
185 if (!*outlen || !*inlen) {
194 c.
in_end = (
const uint8_t *)in + *inlen;
196 c.
out_end = (uint8_t *)out + * outlen;
211 back = (
GETB(c) << 3) + ((x >> 2) & 7) + 1;
215 back = (
GETB(c) << 6) + (x >> 2) + 1;
218 back = (1 << 14) + ((x & 8) << 11);
220 back += (
GETB(c) << 6) + (x >> 2);
221 if (back == (1 << 14)) {
234 back = (1 << 11) + (
GETB(c) << 2) + (x >> 2) + 1;
237 back = (
GETB(c) << 2) + (x >> 2) + 1;
254 #include <lzo/lzo1x.h>
256 #define MAXSZ (10*1024*1024)
260 #define BENCHMARK_LIBLZO_SAFE 0
261 #define BENCHMARK_LIBLZO_UNSAFE 0
263 int main(
int argc,
char *argv[]) {
264 FILE *in = fopen(argv[1],
"rb");
268 size_t s = fread(orig, 1, MAXSZ, in);
270 long tmp[LZO1X_MEM_COMPRESS];
274 lzo1x_999_compress(orig, s, comp, &clen, tmp);
275 for (i = 0; i < 300; i++) {
277 inlen = clen; outlen = MAXSZ;
278 #if BENCHMARK_LIBLZO_SAFE
279 if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen,
NULL))
280 #elif BENCHMARK_LIBLZO_UNSAFE
281 if (lzo1x_decompress(comp, inlen, decomp, &outlen,
NULL))
288 if (memcmp(orig, decomp, s))