wok-next diff fusecloop/stuff/fusecloop.u @ rev 19408

fusecloop/create_compressed_fs: add zopfli support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Sep 20 10:46:56 2016 +0200 (2016-09-20)
parents 624197d091b7
children 792674d97726
line diff
     1.1 --- a/fusecloop/stuff/fusecloop.u	Sat Feb 13 18:55:56 2016 +0100
     1.2 +++ b/fusecloop/stuff/fusecloop.u	Tue Sep 20 10:46:56 2016 +0200
     1.3 @@ -620,13 +620,15 @@
     1.4  +}
     1.5  --- create_compressed_fs.c
     1.6  +++ create_compressed_fs.c
     1.7 -@@ -0,0 +1,203 @@
     1.8 +@@ -0,0 +1,223 @@
     1.9  +#ifdef FIND_BEST_COMPRESSION
    1.10  +#include <compress.h>
    1.11  +extern "C" {
    1.12  +#include <stdlib.h>
    1.13  +#include <string.h>
    1.14  +
    1.15 ++static shrink_t level;
    1.16 ++static int pass, iter;
    1.17  +static int best_compress(unsigned char *compressed,
    1.18  +			 unsigned long *compressed_len,
    1.19  +			 unsigned char *uncompressed,
    1.20 @@ -646,13 +648,14 @@
    1.21  +	}
    1.22  +	buf[0] = compressed;
    1.23  +	buf[1] = buffer;
    1.24 -+	for (i = j = 0; i <= 10; i++) {
    1.25 ++	for (i = j = 0; i <= 11 && (pass == 0 || i < pass); i++) {
    1.26  +		llen = len = *compressed_len;
    1.27 -+		if (i == 10) 
    1.28 -+			err = (compress_zlib(shrink_extreme, buf[j],
    1.29 ++		if (i >= 10) {
    1.30 ++			level.level = (i == 10) ? shrink_extra : shrink_insane;
    1.31 ++			err = (compress_zlib(level, buf[j],
    1.32  +		     		len, uncompressed,
    1.33  +		     		uncompressed_len)) ? Z_OK : Z_DATA_ERROR;
    1.34 -+		else {
    1.35 ++		} else {
    1.36  +			err = compress2(buf[j], &llen, uncompressed,
    1.37  +				     uncompressed_len, i);
    1.38  +			len = llen;
    1.39 @@ -744,9 +747,26 @@
    1.40  +	md5hash *hash;
    1.41  +#endif
    1.42  +	
    1.43 ++#ifdef FIND_BEST_COMPRESSION
    1.44 ++	while (argc > 1) {
    1.45 ++		if (argv[1][0] == '-') {
    1.46 ++			int *p = &pass;
    1.47 ++			switch (argv[1][1]) {
    1.48 ++			case 'i' : p = &iter;
    1.49 ++			case 'n' : *p = atoi(argv[2]);
    1.50 ++				argc -= 2;
    1.51 ++				argv += 2;
    1.52 ++				continue;
    1.53 ++			}
    1.54 ++		}
    1.55 ++		argc--;
    1.56 ++		if (argv[1][0] < '0' || argv[1][0] > '9')
    1.57 ++			quit("Usage : create_compressed_fs [-n <pass>][ -i <iter>] [block size] < input > output");
    1.58 ++#else
    1.59  +	if (argc > 1) {
    1.60  +		if (argv[1][0] < '0' || argv[1][0] > '9')
    1.61  +			quit("Usage : create_compressed_fs [block size] < input > output");
    1.62 ++#endif
    1.63  +		block_size = atoi(argv[1]);
    1.64  +	}
    1.65  +	if (block_size < 4096)