Skip to content

Commit 7647a93

Browse files
committed
Add usage for secondary compressor for iccodec
1 parent 06d6aad commit 7647a93

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

lib/icapp.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ char *codstr(unsigned codecid) { return ""; }
787787
void tpsizeset(unsigned _tpbsize) {}
788788
void tpmodeset(unsigned _tpmode) {}
789789
int lzidget(char *scmd) { return 0; }
790+
unsigned* getAvailableLzs() { return NULL; }
790791
#endif
791792

792793
#ifdef _QCOMPRESS
@@ -2049,11 +2050,26 @@ unsigned bench64(unsigned char *in, unsigned n, unsigned char *out, unsigned cha
20492050
return l;
20502051
}
20512052

2053+
const char* printLzs(char buf[256]) {
2054+
buf[0] = 0;
2055+
for (unsigned* lzs = getAvailableLzs(); lzs && *lzs != ICC_LAST; ++lzs){
2056+
strcat(buf, codstr(*lzs));
2057+
strcat(buf, " ");
2058+
}
2059+
return buf;
2060+
}
2061+
20522062
typedef struct len_t { unsigned id,cnt; uint64_t len; } len_t;
20532063
#define CMPSA(_a_,_b_, _t_, _v_) (((((_t_ *)_a_)->_v_) > (((_t_ *)_b_)->_v_)) - ((((_t_ *)_a_)->_v_) < (((_t_ *)_b_)->_v_)))
20542064
static int cmpsna(const void *a, const void *b) { return CMPSA(a, b, len_t, len); }
2065+
#ifdef _LZ4
2066+
static const char zDefault[] = "lz4,1";
2067+
#else
2068+
static const char zDefault[] = "memcpy";
2069+
#endif
20552070

20562071
void usage(char *pgm) {
2072+
char lzs[256];
20572073
fprintf(stderr, "\nIcApp Copyright (c) 2013-2023 Powturbo %s\n", __DATE__);
20582074
fprintf(stderr, "Usage: %s [options] [file]\n", pgm);
20592075
//fprintf(stderr, " -b#s # = blocksize (default filesize,). max=1GB\n");
@@ -2063,6 +2079,8 @@ void usage(char *pgm) {
20632079
fprintf(stderr, " -i#/-j# # = Minimum de/compression iterations per run (default=auto)\n");
20642080
fprintf(stderr, " -I#/-J# # = Number of de/compression runs (default=3)\n");
20652081
fprintf(stderr, " -e# # = function ids separated by ',' or ranges '#-#' (default='1-%d')\n", ID_MEMCPY);
2082+
fprintf(stderr, " -Es s = secondary compressor with level separated by ',' (default %s)\n", zDefault);
2083+
fprintf(stderr, " available compressors: %s\n", printLzs(lzs));
20662084
fprintf(stderr, "File format:\n");
20672085
fprintf(stderr, " -F[Xx[k][H]][.d]\n");
20682086
fprintf(stderr, " X = file format:\n");
@@ -2214,13 +2232,7 @@ int main(int argc, char* argv[]) { //testrazor();
22142232
}
22152233
isa = cpuisa();
22162234
cpuini(0); if(verbose>1) printf("detected simd id=%x, %s\n\n", cpuini(0), cpustr(cpuini(0)));
2217-
char _scmd[33];
2218-
#ifdef _LZ4
2219-
strcpy(_scmd, "lz4,1");
2220-
#else
2221-
strcpy(_scmd, "memcpy");
2222-
#endif
2223-
if(!scmd) scmd = _scmd;
2235+
if(!scmd) scmd = zDefault;
22242236
while(isspace(*scmd)) scmd++;
22252237
char *q;
22262238
int i;

lib/iccodec.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,35 @@ extern int bwtx, forcelzp;
4444
//------------------------------------------------------------------------------------------------------------------------------
4545
#define powof2(n) !((n)&((n)-1))
4646

47+
static unsigned availableLzs[] = {
48+
#ifdef _LZTURBO
49+
ICC_LZTURBO,
50+
#endif
51+
#ifdef _LZ4
52+
ICC_LZ4,
53+
#endif
54+
#ifdef _ZLIB
55+
ICC_ZLIB,
56+
#endif
57+
#ifdef _ZSTD
58+
ICC_ZSTD,
59+
#endif
60+
#ifdef _FSE
61+
ICC_FSE,
62+
#endif
63+
#ifdef _FSEHUF
64+
ICC_FSEH,
65+
#endif
66+
#ifdef _LZTURBO // _TURBOANX is enabled by _LZTURBO
67+
ICC_LZTANS,
68+
#endif
69+
#ifdef _TURBORC
70+
ICC_TURBORC,
71+
#endif
72+
ICC_MEMCPY,
73+
ICC_LAST
74+
};
75+
4776
char *_codstr[] = { "none", "lzturbo", "lz4", "zlib", "zstd", "fse", "fsehuf", "turboanx", "turborc", "memcpy", NULL };
4877
char *codstr(unsigned cid) { return (cid < ICC_LAST)?_codstr[cid]:""; }
4978

@@ -54,6 +83,8 @@ int lzidget(char *scmd) {
5483
if(!_codstr[i]) die("compressor '%s' not implemented\n", scmd);
5584
return i;
5685
}
86+
unsigned* getAvailableLzs() { return availableLzs; }
87+
5788
#ifdef _LZTURBO
5889
#define _TURBOANX
5990
#include "../lz/ans.h"

lib/include_/iccodec.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ void tpmodeset(unsigned _tpmode);
108108
void tpsizeset(unsigned _tpsize);
109109
int lzidget(char *scmd);
110110
char *codstr(unsigned cid);
111+
unsigned* getAvailableLzs(); // ICC_LAST will be the last entry
111112

112113
#ifdef __cplusplus
113114
}

0 commit comments

Comments
 (0)