-
Notifications
You must be signed in to change notification settings - Fork 35
/
plugin.cc
executable file
·3164 lines (2774 loc) · 114 KB
/
plugin.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
Copyright (C) powturbo 2013-2023
GPL v2 License
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- homepage : https://sites.google.com/site/powturbo/
- github : https://github.com/powturbo
- twitter : https://twitter.com/powturbo
- email : powturbo [_AT_] gmail [_DOT_] com
**/
// TurboBench: plugin.cc - compressor plugins
enum {
#define _MEMCPY 1
P_LMCPY, // must be 0
P_MCPY, // must be 1
#ifndef _AOM
#define _AOM 0
#endif
P_AOM,
#ifndef _BPC
#define _BPC 0
#endif
P_BPC,
#ifndef _BRIEFLZ
#define _BRIEFLZ 0
#endif
P_BRIEFLZ,
#ifndef _BROTLI
#define _BROTLI 0
#endif
P_BROTLI,
#ifndef _BZIP2
#define _BZIP2 0
#endif
P_BZIP2,
#ifndef _BZIP3
#define _BZIP3 0
#endif
P_BZIP3,
#ifndef _CHAMELEON
#define _CHAMELEON 0
#endif
P_CHAMELEON,
#ifndef _C_BLOSC2
#define _C_BLOSC2 0
#endif
P_C_BLOSC2,
#ifndef _CSC
#define _CSC 0
#endif
P_CSC,
#ifndef _DAALA
#define _DAALA 0
#endif
P_DAALA,
#ifndef _DENSITY
#define _DENSITY 0
#endif
P_DENSITY,
#ifndef _DOBOZ
#define _DOBOZ 0
#endif
P_DOBOZ,
#ifndef _FASTLZ
#define _FASTLZ 0
#endif
P_FASTLZ,
#ifndef _FLZMA2
#define _FLZMA2 0
#endif
P_FLZMA2,
#ifndef _GIPFELI
#define _GIPFELI 0
#endif
P_GIPFELI,
#ifndef _GLZA
#define _GLZA 0
#endif
P_GLZA,
#ifndef _HEATSHRINK
#define _HEATSHRINK 0
#endif
P_HEATSHRINK,
#ifndef _ISA_L
#define _ISA_L 0
#endif
P_ISA_L,
#ifndef _LIBBSC
#define _LIBBSC 0
#endif
P_LIBBSC,
P_LIBBSCC, //QLFC
P_ST, //st
P_LIBBSCBWT, //bwt
#ifndef _DIVBWT
#define _DIVBWT 0
#endif
P_DIVBWT, //bwt
#ifndef _LIBDEFLATE
#define _LIBDEFLATE 0
#endif
P_LIBDEFLATE,
#ifndef _LIBLZF
#define _LIBLZF 0
#endif
P_LIBLZF,
#ifndef _LIBLZG
#define _LIBLZG 0
#endif
P_LIBLZG,
#ifndef _SLZ
#define _SLZ 0
#endif
P_SLZ,
#ifndef _ZPAQ
#define _ZPAQ 0
#endif
P_ZPAQ,
#ifndef _LZ4
#define _LZ4 0
#endif
P_LZ4,
#ifndef _LZ4ULTRA
#define _LZ4ULTRA 0
#endif
P_LZ4ULTRA,
#ifndef _LZAV
#define _LZAV 0
#endif
P_LZAV,
#ifndef _LZFSE
#define _LZFSE 0
#endif
P_LZFSE,
#ifndef _LZFSEA
#define _LZFSEA 0
#endif
P_LZFSEA,
#ifndef _LZHAM
#define _LZHAM 0
#endif
P_LZHAM,
#ifndef _LIZARD
#define _LIZARD 0
#endif
P_LIZARD,
#ifndef _LZJODY
#define _LZJODY 0
#endif
P_LZJODY,
#ifndef _LZLIB
#define _LZLIB 0
#endif
P_LZLIB,
#ifndef _LZMA
#define _LZMA 0
#endif
P_LZMA,
#ifndef _LZMAT
#define _LZMAT 0
#endif
P_LZMAT,
#ifndef _LZO
#define _LZO 0
#endif
P_LZO1b, P_LZO1c, P_LZO1f, P_LZO1x, P_LZO1y, P_LZO1z, P_LZO2a,
#ifndef _LZOMA
#define _LZOMA 0
#endif
P_LZOMA,
#ifndef _LZSA
#define _LZSA 0
#endif
P_LZSA,
#ifndef _LZSSE
#define _LZSSE 0
#endif
P_LZSSE2,
P_LZSSE4,
P_LZSSE8,
#ifndef _MINIZ
#define _MINIZ 0
#endif
P_MINIZ,
#ifndef _MSCOMPRESS
#define _MSCOMPRESS 0
#endif
P_MSCOMPRESS,
#ifndef _NAKA
#define _NAKA 0
#endif
P_NAKA,
#ifndef _PITHY
#define _PITHY 0
#endif
P_PITHY,
#ifndef _QUICKLZ
#define _QUICKLZ 0
#endif
P_QUICKLZ,
#ifndef _QCOMPRESS
#define _QCOMPRESS 0
#endif
P_QCOMPRESS32,
P_QCOMPRESS64,
#ifndef _SHRINKER
#define _SHRINKER 0
#endif
P_SHRINKER,
#ifndef _PYSAP
#define _PYSAP 0
#endif
P_PYSAP,
#ifndef _OODLE
#define _OODLE 0
#endif
#ifndef _OODLESRC
#define _OODLESRC 0
#endif
P_OODLE,
#ifndef _SHOCO
#define _SHOCO 0
#endif
P_SHOCO,
#ifndef _SMAZ
#define _SMAZ 0
#endif
P_SMAZ,
#ifndef _SNAPPY
#define _SNAPPY 0
#endif
P_SNAPPY,
#ifndef _SNAPPY_C
#define _SNAPPY_C 0
#endif
P_SNAPPY_C,
#ifndef _SMALLZ4
#define _SMALLZ4 0
#endif
P_SMALLZ4,
#ifndef _TCOBS
#define _TCOBS 0
#endif
P_TCOBS,
#ifndef _TORNADO
#define _TORNADO 0
#endif
P_TORNADO,
#ifndef _UNISHOX2
#define _UNISHOX2 0
#endif
P_UNISHOX2,
#ifndef _UNISHOX3
#define _UNISHOX3 0
#endif
P_UNISHOX3,
#ifndef _WFLZ
#define _WFLZ 0
#endif
P_WFLZ,
#ifndef _YALZ77
#define _YALZ77 0
#endif
P_YALZ77,
#ifndef _YAPPY
#define _YAPPY 0
#endif
P_YAPPY,
#ifndef _ZLIB
#define _ZLIB 0
#endif
P_ZLIB,
P_ZRLE,
P_ZLIBH,
#ifndef _ZLIB_NG
#define _ZLIB_NG 0
#endif
P_ZLIB_NG,
#ifndef _ZLING
#define _ZLING 0
#endif
P_ZLING,
#ifndef _ZOPFLI
#define _ZOPFLI 0
#endif
P_ZOPFLI,
#ifndef _ZSTD
#define _ZSTD 0
#endif
P_ZSTD,
#ifndef _FSE
#define _FSE 0
#endif
P_FSE,
#ifndef _FSEHUF
#define _FSEHUF 0
#endif
P_FSEH,
// --------- Encoding -------------------
#ifndef _TURBORLE
#define _TURBORLE 0
#endif
P_RLES,
P_RLET,
#ifndef _MRLE
#define _MRLE 0
#endif
P_RLEM,
#ifndef _HRLE
#define _HRLE 0
#endif
P_HRLE,
P_HRLESH,
P_HRLEMMTF,
P_HRLEXMMTF,
P_HRLELE,
P_HRLEM,
P_HRLEU,
//---------- Transform ------------------
#ifndef _BRC
#define _BRC 0
#endif
P_BRC,
// --------- Entropy coders -------------
#ifndef _FASTAC
#define _FASTAC 0
#endif
P_FASTAC,
#ifndef _FASTARI
#define _FASTARI 0
#endif
P_FASTARI,
#ifndef _FASTHF
#define _FASTHF 0
#endif
P_FASTHF,
#ifndef _FREQTAB
#define _FREQTAB 0
#endif
P_FREQTAB,
#ifndef _FSC
#define _FSC 0
#endif
P_FSC,
#ifndef _FPC
#define _FPC 0
#endif
P_FPC,
#ifndef _FQZ0
#define _FQZ0 0
#endif
P_FQZ0,
#ifndef _JAC
#define _JAC 0
#endif
P_JAC,
#ifndef _FPAQC
#define _FPAQC 0
#endif
P_FPAQC,
#ifndef _MARLIN
#define _MARLIN 0
#endif
P_MARLIN,
#ifndef _NIBRANS
#define _NIBRANS 0
#endif
P_NIBRANS,
#ifndef _PPMDEC
#define _PPMDEC 0
#endif
P_PPMDEC,
#ifndef _RECIPARITH
#define _RECIPARITH 0
#endif
P_RECIPARITH,
#ifndef _SHRC
#define _SHRC 0
#endif
P_SHRC,
#ifndef _VECRC
#define _VECRC 0
#endif
P_SHRCV,
#ifndef _SUBOTIN
#define _SUBOTIN 0
#endif
P_SUBOTIN,
#ifndef _SSERC
#define _SSERC 0
#endif
P_SSERC,
#ifndef _GANS
#define _GANS 0
#endif
P_GANSR,
P_GANSW,
#ifndef _POLHF
#define _POLHF 0
#endif
P_POLHF,
P_TORNADOHF,
#ifndef _TURBORC
#define _TURBORC 0
#endif
P_TURBORC,
#ifndef _XPACK
#define _XPACK 0
#endif
P_XPACK,
P_MYCODEC, // User plugin
#ifdef _LZTURBO
#include "../dev/x/beplug.h"
#endif
};
//-------------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "conf.h"
#include "plugin.h"
#if _AOM
#include "EC/aom_/aom.h"
#endif
#if _C_BLOSC2
#ifdef C_C_BLOSC2LZ
#include "c-blosc2/blosclz.h"
#else
#include "c-blosc2/include/blosc2.h"
#endif
#endif
#if _BPC
#include "BitPlaneComp/src/BPCompressor.hh"
#endif
#if _BRIEFLZ
#include "brieflz/include/brieflz.h"
#endif
#if _LIBBSC
#include "libbsc/libbsc/libbsc.h"
#include "libbsc/libbsc/st/st.h"
#include "libbsc/libbsc/lzp/lzp.h"
#endif
#if _LIBDEFLATE
#include "libdeflate/libdeflate.h"
#endif
#if _BZIP2
#include "bzip2/bzlib.h"
#endif
#if _BROTLI
#include "brotli/c/include/brotli/encode.h"
#include "brotli/c/include/brotli/decode.h"
#endif
#if _LZMA
#include "lzma/C/Alloc.h"
#include "lzma/C/LzmaEnc.h"
#include "lzma/C/LzmaDec.h"
#endif
#if _CSC
#define __7Z_TYPES_H
#include "CSC/src/libcsc/csc_enc.h"
#include "CSC/src/libcsc/csc_dec.h"
struct MemISeqInStream {
ISeqInStream s;
unsigned char *in;
size_t inlen;
};
struct MemISeqOutStream {
ISeqOutStream s;
unsigned char *out;
size_t outlen;
};
static int cscread(MemISeqInStream *si, void *in, size_t *inlen) {
if(*inlen > si->inlen) *inlen = si->inlen;
memcpy(in, si->in, *inlen);
si->in += *inlen;
si->inlen -= *inlen;
return 0;
}
static size_t cscwrite(MemISeqOutStream *so, const void *out, size_t outlen) {
memcpy(so->out, out, outlen);
so->out += outlen;
so->outlen += outlen;
return outlen;
}
#endif
#if _DAALA
#include "EC/daala_/daala.h"
#endif
#if _DOBOZ
#include "doboz/Source/Doboz/Compressor.h"
#include "doboz/Source/Doboz/Decompressor.h"
#endif
#if _FLZMA2
#define __LZMA_ENC_H
#define __LZMA_DEC_H
#include "fast-lzma2/lzma2_enc.h"
#include "fast-lzma2/lzma2_dec.h"
#endif
#if _GIPFELI
#include "gipfeli/gipfeli.h"
#endif
#if _GLZA
#include "glza/GLZAcomp.h"
#include "glza/GLZAdecode.h"
#endif
#if _HEATSHRINK
#include "heatshrink_/heatshrink.h"
#endif
#if _ISA_L
#ifdef HAVE_IGZIP
#include <isa-l.h>
#else
#include "isa-l/include/igzip_lib.h"
#endif
#endif
#if _LIBLZG
#include "liblzg/src/include/lzg.h"
#endif
#if _ZPAQ
#include "zpaq/libzpaq.h"
void libzpaq::error(const char* msg) {
fprintf(stderr, "zpaq error: %s\n", msg);
exit(1);
}
static unsigned char *zin,*zin_,*zout;
#define _putc(_ch_, _out_) *_out_++ = (_ch_)
#define _getc(_in_, _ep_) (_in_<_ep_?*_in_++:-1)
class In: public libzpaq::Reader {
public:
int get() { return _getc(zin, zin_); }
} zmemin;
class Out: public libzpaq::Writer {
public:
void put(int c) { _putc(c, zout); }
} zmemout;
#endif
#if _LZ4
#include "lz4/lib/lz4.h"
#include "lz4/lib/lz4hc.h"
#include "lz4/lib/lz4frame.h"
#endif
#if _LZAV
#include "lzav/lzav.h"
#endif
#if _LIZARD
#include "lizard/lib/lizard_compress.h" //v2.0
#include "lizard/lib/lizard_decompress.h"
#endif
#if _LZFSEA
#include <compression.h>
#endif
#if _LZHAM
#include "lzham_codec_devel/include/lzham.h"
#endif
#if _LZLIB
#include "lzlib_/bbexample.h"
struct Lzma_options
{
int dictionary_size; /* 4 KiB .. 512 MiB */
int match_len_limit; /* 5 .. 273 */
};
/* Mapping from gzip/bzip2 style 1..9 compression modes
to the corresponding LZMA compression modes. */
const struct Lzma_options option_mapping[] =
{
{ 65535, 16 }, /* -0 (65535,16 chooses fast encoder) */
{ 1 << 20, 5 }, /* -1 */
{ 3 << 19, 6 }, /* -2 */
{ 1 << 21, 8 }, /* -3 */
{ 3 << 20, 12 }, /* -4 */
{ 1 << 22, 20 }, /* -5 */
{ 1 << 23, 36 }, /* -6 */
{ 1 << 24, 68 }, /* -7 */
{ 3 << 23, 132 }, /* -8 */
{ 1 << 25, 273 } }; /* -9 */
struct Lzma_options encoder_options;
#endif
#if _LZMAT
#include "lzmat/lzmat.h"
#endif
#if _LZO
#include "lzo/include/lzo/lzo1b.h"
#include "lzo/include/lzo/lzo1c.h"
#include "lzo/include/lzo/lzo1f.h"
#include "lzo/include/lzo/lzo1x.h"
#include "lzo/include/lzo/lzo1y.h"
#include "lzo/include/lzo/lzo1z.h"
#include "lzo/include/lzo/lzo2a.h"
#endif
#if _LZOMA
#include "lzoma_/lzoma.h"
#endif
#if _LZSA
#include "lzsa/src/shrink_inmem.h"
#include "lzsa/src/expand_inmem.h"
#define LZSA_FLAG_FAVOR_RATIO (1<<0) /**< 1 to compress with the best ratio, 0 to trade some compression ratio for extra decompression speed */
#define LZSA_FLAG_RAW_BLOCK (1<<1) /**< 1 to emit raw block */
#endif
#if _LZSSE
#include "LZSSE/lzsse2/lzsse2.h"
#include "LZSSE/lzsse4/lzsse4.h"
#include "LZSSE/lzsse8/lzsse8.h"
#endif
#if _MSCOMPRESS
#include "ms-compress/include/mscomp.h"
#endif
#if _LZSS
#include "lzss/lzss.h"
#endif
#if _NAKA
#include "nakamichi/nakamichi.h"
#endif
#if _PITHY
#include "pithy/pithy.h"
#endif
#if _QUICKLZ
#include "quicklz_/quicklz-c.h"
#endif
#if _PYSAP
#include "pysap/pysapcompress/hpa101saptype.h"
#include "pysap/pysapcompress/hpa104CsObject.h"
#include "pysap/pysapcompress/hpa106cslzc.h"
#include "pysap/pysapcompress/hpa107cslzh.h"
#include "pysap/pysapcompress/hpa105CsObjInt.h"
#undef max
#undef min
#endif
#if _QCOMPRESS
#include "q_compress/q_compress.h"
typedef FfiVec (*fauto_compress_i32)(int *nums, unsigned len, unsigned level);
typedef FfiVec (*fauto_compress_i64)(long long *nums, unsigned len, unsigned level);
typedef void (*ffree_compressed)(FfiVec ffi_vec);
typedef FfiVec (*fauto_decompress_i32)( unsigned char *compressed, unsigned len );
typedef void (*ffree_i32)(FfiVec c_vec);
typedef FfiVec (*fauto_decompress_i64)( unsigned char *compressed, unsigned len );
typedef void (*ffree_i64)(FfiVec c_vec);
static fauto_compress_i32 auto_compress_i32_;
static fauto_compress_i64 auto_compress_i64_;
static ffree_compressed free_compressed_;
static fauto_decompress_i32 auto_decompress_i32_;
static fauto_decompress_i64 auto_decompress_i64_;
static ffree_i32 free_i32_;
static ffree_i64 free_i64_;
#endif
#if _SHRINKER
#include "shrinker/Shrinker.h"
#endif
#if _SHOCO
#include "shoco/shoco.h"
#endif
#if _SNAPPY
#include "snappy/snappy.h"
#endif
#if _TCOBS
#include "tcobs/Cv2/tcobs.h"
#endif
#if _TORNADO
#include "tornado_/tormem.h"
#endif
#if _TURBORC
#include "Turbo-Range-Coder/include/turborc.h"
#include "Turbo-Range-Coder/include/anscdf.h"
//#include "Turbo-Range-Coder/rcutil.h"
#endif
#if _WFLZ
#include "wflz/wfLZ.h"
#endif
#if _WIMLIB
#include "../wimlib/include/wimlib.h"
#endif
#if _XPACK
#include "xpack/libxpack.h"
#endif
#if _YALZ77
#include "yalz77/lz77.h"
#endif
#if _YAPPY
#include "yappy/yappy.hpp"
#endif
#if _ZLIB || _SLZ
#if _ZLIBLIB
#include <zlib.h>
// #elif defined(ZLIB_NG) // zlib-ng.a compatible mode : "./configure --zlib-compat" (see zlib-ng/INSTALL)
//#include "zlib/zlib.h"
#elif defined(ZLIB_INTEL)
#include "zlib_intel/zlib.h"
#else
#include "zlib/zlib.h"
#endif
#endif
#if _ZLING
#include "libzling/src/libzling.h"
#include "libzling_/libzling_utils_mem.h"
#endif
#ifdef _LZTURBO
#include "../dev/x/beplugi.h"
#endif
//-----------------------------
#if _BRC
#include "Behemoth-Rank-Coding/brc.hpp"
int vsrc_forwards(unsigned char * src, unsigned char * dst, size_t src_size);
int vsrc_reverse(unsigned char * src, unsigned char * dst, size_t src_size);
#endif
#if __cplusplus
extern "C" {
#endif
#if _BZIP3
#include "bzip3/include/libbz3.h"
#endif
#if _CHAMELEON
#include "chameleon/Chameleon2.h"
#endif
#if _DENSITY
#include "density/src/density_api.h"
#endif
#if _FASTLZ
#include "FastLZ/fastlz.h"
#endif
#if _LIBLZF
#include "liblzf/lzf.h"
#endif
#if _SLZ
#include "libslz/src/slz.h"
#endif
#if _LZFSE
#include "lzfse/src/lzfse.h"
#endif
#if _LZJODY
#include "lzjody/lzjody.h"
#endif
#if _MINIZ
typedef unsigned long mz_ulong;
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
#endif
#if _OODLE
#ifndef _WIN32
#include <dlfcn.h>
#endif
typedef struct OodleLZ_CompressOptions {
char dummy[255];
};
#define __cdecl
typedef long long (__cdecl *fOodleLZ_Compress)(int codec, void *in, long long inlen, void *out, int lev, void *options, void *dict, void *p6, void *tmp, long long tmplen);
typedef long long (__cdecl *fOodleLZ_Decompress)(void *in, long long inlen, void *out, long long outlen, int crc, int p5, long long verb, void *dic, long long diclen, void *p9, long long p10, void *p11, long long p12, int p13);
typedef struct OodleLZ_CompressOptions *(__cdecl *fOodleLZ_CompressOptions_GetDefault)(int compid, int level);
static fOodleLZ_Compress OodleLZ_Compress_;
static fOodleLZ_Decompress OodleLZ_Decompress_;
static fOodleLZ_CompressOptions_GetDefault OodleLZ_CompressOptions_GetDefault_;
#endif
#if _SNAPPY_C
#include "snappy-c/snappy.h"
struct snappy_env env;
#endif
#if _SMALLZ4
#include "smallz4/smallz4.h"
#include "smallz4/smallz4cat.c"
#endif
#if _SMAZ
#include "smaz/smaz.h"
#endif
#if _UNISHOX2
int unishox2_compressx( const char *in, int inlen, char *out, int lev);
int unishox2_decompressx(const char *in, int inlen, char *out, int lev);
#endif
#if _UNISHOX3
#include "unishox2/Unishox3_Alpha/unishox3.h"
#endif
#if _ZLIB_NG
#include "zlib-ng/zconf-ng.h"
//#include "zlib-ng_/zlib-ng.h"
#define Z_EXTERN
#define Z_EXPORT
Z_EXTERN Z_EXPORT const char *zlibng_version(void);
Z_EXTERN Z_EXPORT int32_t zng_compress2(uint8_t *dest, size_t *destLen, const uint8_t *source, size_t sourceLen, int32_t level);
Z_EXTERN Z_EXPORT int32_t zng_uncompress(uint8_t *dest, size_t *destLen, const uint8_t *source, size_t sourceLen);
#endif
#if _ZOPFLI
#include "zopfli/src/zopfli/zopfli.h"
#endif
#if __cplusplus
}
#endif
//------------------------------------ Encoding -----------------------------------
#if _GANS
#include "EC/rans.h"
#endif
#if _SSERC
#include "EC/sserangecoding/sserangecoder.h"
#define SSE_BITS 12
static int ssercini;
unsigned ssercenc(unsigned char *_in, unsigned inlen, unsigned char *_out) {
sserangecoder::uint8_vec in(inlen), out;
sserangecoder::uint32_vec sym_freq(256);
memcpy(&in[0], _in, inlen);
if(!ssercini) sserangecoder::vrange_init(), ssercini++;
for(uint32_t i = 0; i < inlen; i++) sym_freq[_in[i]]++;
unsigned a = 256; while(a > 1 && !sym_freq[a-1]) a--;
sserangecoder::uint32_vec scaled_cum_prob(a+1);
if(!sserangecoder::vrange_create_cum_probs(scaled_cum_prob, sym_freq)) return -1;
unsigned char *op = _out;
*op++ = a - 1;
for(int i = 0; i < a; i++) ctou16(op) = scaled_cum_prob[i], op +=2;
sserangecoder::vrange_encode(in, out, scaled_cum_prob);
memcpy(op, &out[0], out.size());
op += out.size();
return op - _out;
}
unsigned ssercdec(unsigned char *in, unsigned inlen, unsigned char *out, unsigned outlen) {
unsigned char *ip = in;
unsigned a = 1 + (*ip++);
if(!ssercini) sserangecoder::vrange_init(),ssercini++;
sserangecoder::uint32_vec scaled_cum_prob(a+1);
unsigned cum = 0,i;
for(i = 0; i < a; i++) scaled_cum_prob[i] = ctou16(ip), ip+=2;
scaled_cum_prob[a] = (1<<SSE_BITS);
sserangecoder::uint32_vec dec_table(a);
sserangecoder::vrange_init_table(a, scaled_cum_prob, dec_table);
if(!sserangecoder::vrange_decode(ip, (in+inlen) - ip, out, outlen, &dec_table[0])) return -1; //for(int i=0; i < 100; i++) printf("%c", out[i]);
return outlen;
}
#endif
#if _TURBORLE
#include "Turbo-Run-Length-Encoding/include/trle.h"
#endif
#if _MRLE
#include "Turbo-Run-Length-Encoding/ext/mrle.h"
#endif
#if _TB64
#include "TurboBase64/turbob64.h"
#endif
#if _SB64
//#include "base64simd/encode/lookup.sse.cpp"
//#include "base64simd/decode/decode.sse.cpp"
#endif
#if _B64
#include "base64/include/libbase64.h"
#endif
#if _FB64
#include "fastbase64/include/chromiumbase64.h"
#include "fastbase64/include/scalarbase64.h"
#include "fastbase64/include/linuxbase64.h"
#ifdef AVX2_ON
#include "fastbase64/include/fastavxbase64.h"
#include "fastbase64/include/klompavxbase64.h"
#endif
#ifdef HAVE_AVX512BW
#include "fastbase64/include/fastavxbase64.h"
#endif // HAVE_AVX512BW
#endif
#if __ARM_NEON
int neon_base64_decode(char *out, const char *src, size_t srclen);
#endif
#if _HRLE
#include "hypersonic-rle-kit/src/rle.h"
#endif
#if __cplusplus
extern "C" {
#endif
#if _LZ4ULTRA
#define LZ4ULTRA_FLAG_FAVOR_RATIO (1<<0) /**< 1 to compress with the best ratio, 0 to trade some compression ratio for extra decompression speed */
#define LZ4ULTRA_FLAG_RAW_BLOCK (1<<1) /**< 1 to emit raw block */
#define LZ4ULTRA_FLAG_INDEP_BLOCKS (1<<2) /**< 1 if blocks are independent, 0 if using inter-block back references */
#define LZ4ULTRA_FLAG_LEGACY_FRAMES (1<<3) /**< 1 if using the legacy frames format, 0 if using the modern lz4 frame format */
//#include "lz4ultra/src/lib.h"
//#include "lz4ultra/src/shrink_inmem.h"
//#include "lz4ultra/src/expand_inmem.h"
size_t lz4ultra_compress_inmem(const unsigned char *pInputData, unsigned char *pOutBuffer, size_t nInputSize, size_t nMaxOutBufferSize, unsigned int nFlags, int nBlockMaxCode);
size_t lz4ultra_decompress_inmem(const unsigned char *pFileData, unsigned char *pOutBuffer, size_t nFileSize, size_t nMaxOutBufferSize, unsigned int nFlags);
#endif
#if __cplusplus
}
#endif
//------------------------------------ Transform ----------------------------------
#if _LIBBSC
#include "libbsc/libbsc/bwt/bwt.h"
#include "libbsc/libbsc/coder/coder.h"
#endif
#if _DIVBWT
#include "Turbo-Range-Coder/libdivsufsort/include/divsufsort.h"