Skip to content

Add usage for secondary compressor for iccodec #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions lib/icapp.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ char *codstr(unsigned codecid) { return ""; }
void tpsizeset(unsigned _tpbsize) {}
void tpmodeset(unsigned _tpmode) {}
int lzidget(char *scmd) { return 0; }
unsigned* getAvailableLzs() { return NULL; }
#endif

#ifdef _QCOMPRESS
Expand Down Expand Up @@ -2049,11 +2050,26 @@ unsigned bench64(unsigned char *in, unsigned n, unsigned char *out, unsigned cha
return l;
}

const char* printLzs(char buf[256]) {
buf[0] = 0;
for (unsigned* lzs = getAvailableLzs(); lzs && *lzs != ICC_LAST; ++lzs){
strcat(buf, codstr(*lzs));
strcat(buf, " ");
}
return buf;
}

typedef struct len_t { unsigned id,cnt; uint64_t len; } len_t;
#define CMPSA(_a_,_b_, _t_, _v_) (((((_t_ *)_a_)->_v_) > (((_t_ *)_b_)->_v_)) - ((((_t_ *)_a_)->_v_) < (((_t_ *)_b_)->_v_)))
static int cmpsna(const void *a, const void *b) { return CMPSA(a, b, len_t, len); }
#ifdef _LZ4
static const char zDefault[] = "lz4,1";
#else
static const char zDefault[] = "memcpy";
#endif

void usage(char *pgm) {
char lzs[256];
fprintf(stderr, "\nIcApp Copyright (c) 2013-2023 Powturbo %s\n", __DATE__);
fprintf(stderr, "Usage: %s [options] [file]\n", pgm);
//fprintf(stderr, " -b#s # = blocksize (default filesize,). max=1GB\n");
Expand All @@ -2063,6 +2079,8 @@ void usage(char *pgm) {
fprintf(stderr, " -i#/-j# # = Minimum de/compression iterations per run (default=auto)\n");
fprintf(stderr, " -I#/-J# # = Number of de/compression runs (default=3)\n");
fprintf(stderr, " -e# # = function ids separated by ',' or ranges '#-#' (default='1-%d')\n", ID_MEMCPY);
fprintf(stderr, " -Es s = secondary compressor with level separated by ',' (default %s)\n", zDefault);
fprintf(stderr, " available compressors: %s\n", printLzs(lzs));
fprintf(stderr, "File format:\n");
fprintf(stderr, " -F[Xx[k][H]][.d]\n");
fprintf(stderr, " X = file format:\n");
Expand Down Expand Up @@ -2206,7 +2224,7 @@ int main(int argc, char* argv[]) { //testrazor();
}
}
#ifdef _LZTURBO
beini();
beini();
#endif
if(argc - optind < 1) {
usage(argv[0]);
Expand All @@ -2215,11 +2233,7 @@ int main(int argc, char* argv[]) { //testrazor();
isa = cpuisa();
cpuini(0); if(verbose>1) printf("detected simd id=%x, %s\n\n", cpuini(0), cpustr(cpuini(0)));
char _scmd[33];
#ifdef _LZ4
strcpy(_scmd, "lz4,1");
#else
strcpy(_scmd, "memcpy");
#endif
strcpy(_scmd, zDefault);
if(!scmd) scmd = _scmd;
while(isspace(*scmd)) scmd++;
char *q;
Expand Down
31 changes: 31 additions & 0 deletions lib/iccodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,35 @@ extern int bwtx, forcelzp;
//------------------------------------------------------------------------------------------------------------------------------
#define powof2(n) !((n)&((n)-1))

static unsigned availableLzs[] = {
#ifdef _LZTURBO
ICC_LZTURBO,
#endif
#ifdef _LZ4
ICC_LZ4,
#endif
#ifdef _ZLIB
ICC_ZLIB,
#endif
#ifdef _ZSTD
ICC_ZSTD,
#endif
#ifdef _FSE
ICC_FSE,
#endif
#ifdef _FSEHUF
ICC_FSEH,
#endif
#ifdef _LZTURBO // _TURBOANX is enabled by _LZTURBO
ICC_LZTANS,
#endif
#ifdef _TURBORC
ICC_TURBORC,
#endif
ICC_MEMCPY,
ICC_LAST
};

char *_codstr[] = { "none", "lzturbo", "lz4", "zlib", "zstd", "fse", "fsehuf", "turboanx", "turborc", "memcpy", NULL };
char *codstr(unsigned cid) { return (cid < ICC_LAST)?_codstr[cid]:""; }

Expand All @@ -54,6 +83,8 @@ int lzidget(char *scmd) {
if(!_codstr[i]) die("compressor '%s' not implemented\n", scmd);
return i;
}
unsigned* getAvailableLzs() { return availableLzs; }

#ifdef _LZTURBO
#define _TURBOANX
#include "../lz/ans.h"
Expand Down
1 change: 1 addition & 0 deletions lib/include_/iccodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ void tpmodeset(unsigned _tpmode);
void tpsizeset(unsigned _tpsize);
int lzidget(char *scmd);
char *codstr(unsigned cid);
unsigned* getAvailableLzs(); // ICC_LAST will be the last entry

#ifdef __cplusplus
}
Expand Down