31 #define OUTBUF_PADDED 1
33 #define INBUF_PADDED 1
54 #define GETB(c) (*(c).in++)
56 #define GETB(c) get_byte(&(c))
70 if (cnt >= INT_MAX - 1000) {
90 if (cnt > c->
in_end - src) {
98 #if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
105 memcpy(dst, src, cnt);
139 if (*outlen <= 0 || *inlen <= 0) {
166 back = (
GETB(c) << 3) + ((x >> 2) & 7) + 1;
170 back = (
GETB(c) << 6) + (x >> 2) + 1;
173 back = (1 << 14) + ((x & 8) << 11);
175 back += (
GETB(c) << 6) + (x >> 2);
176 if (back == (1 << 14)) {
189 back = (1 << 11) + (
GETB(c) << 2) + (x >> 2) + 1;
192 back = (
GETB(c) << 2) + (x >> 2) + 1;
209 #include <lzo/lzo1x.h>
211 #define MAXSZ (10*1024*1024)
215 #define BENCHMARK_LIBLZO_SAFE 0
216 #define BENCHMARK_LIBLZO_UNSAFE 0
218 int main(
int argc,
char *argv[]) {
219 FILE *
in = fopen(argv[1],
"rb");
220 int comp_level = argc > 2 ? atoi(argv[2]) : 0;
224 size_t s = fread(orig, 1, MAXSZ, in);
226 long tmp[LZO1X_MEM_COMPRESS];
230 if (comp_level == 0) {
231 lzo1x_1_compress(orig, s, comp, &clen, tmp);
232 }
else if (comp_level == 11) {
233 lzo1x_1_11_compress(orig, s, comp, &clen, tmp);
234 }
else if (comp_level == 12) {
235 lzo1x_1_12_compress(orig, s, comp, &clen, tmp);
236 }
else if (comp_level == 15) {
237 lzo1x_1_15_compress(orig, s, comp, &clen, tmp);
239 lzo1x_999_compress(orig, s, comp, &clen, tmp);
240 for (i = 0; i < 300; i++) {
242 inlen = clen; outlen = MAXSZ;
243 #if BENCHMARK_LIBLZO_SAFE
244 if (lzo1x_decompress_safe(comp, inlen, decomp, &outlen, NULL))
245 #elif BENCHMARK_LIBLZO_UNSAFE
246 if (lzo1x_decompress(comp, inlen, decomp, &outlen, NULL))
253 if (memcmp(orig, decomp, s))