chd 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +30 -0
  3. data/chd.gemspec +29 -0
  4. data/ext/chd.c +1008 -0
  5. data/ext/extconf.rb +60 -0
  6. data/lib/chd/cd.rb +272 -0
  7. data/lib/chd/metadata.rb +196 -0
  8. data/lib/chd/version.rb +4 -0
  9. data/lib/chd.rb +21 -0
  10. data/libchdr/CMakeLists.txt +104 -0
  11. data/libchdr/LICENSE.txt +24 -0
  12. data/libchdr/README.md +7 -0
  13. data/libchdr/deps/lzma-19.00/CMakeLists.txt +33 -0
  14. data/libchdr/deps/lzma-19.00/LICENSE +3 -0
  15. data/libchdr/deps/lzma-19.00/include/7zTypes.h +375 -0
  16. data/libchdr/deps/lzma-19.00/include/Alloc.h +51 -0
  17. data/libchdr/deps/lzma-19.00/include/Bra.h +64 -0
  18. data/libchdr/deps/lzma-19.00/include/Compiler.h +33 -0
  19. data/libchdr/deps/lzma-19.00/include/CpuArch.h +336 -0
  20. data/libchdr/deps/lzma-19.00/include/Delta.h +19 -0
  21. data/libchdr/deps/lzma-19.00/include/LzFind.h +121 -0
  22. data/libchdr/deps/lzma-19.00/include/LzHash.h +57 -0
  23. data/libchdr/deps/lzma-19.00/include/Lzma86.h +111 -0
  24. data/libchdr/deps/lzma-19.00/include/LzmaDec.h +234 -0
  25. data/libchdr/deps/lzma-19.00/include/LzmaEnc.h +76 -0
  26. data/libchdr/deps/lzma-19.00/include/LzmaLib.h +131 -0
  27. data/libchdr/deps/lzma-19.00/include/Precomp.h +10 -0
  28. data/libchdr/deps/lzma-19.00/include/Sort.h +18 -0
  29. data/libchdr/deps/lzma-19.00/lzma-history.txt +446 -0
  30. data/libchdr/deps/lzma-19.00/lzma.txt +328 -0
  31. data/libchdr/deps/lzma-19.00/lzma.vcxproj +543 -0
  32. data/libchdr/deps/lzma-19.00/lzma.vcxproj.filters +17 -0
  33. data/libchdr/deps/lzma-19.00/src/Alloc.c +455 -0
  34. data/libchdr/deps/lzma-19.00/src/Bra86.c +82 -0
  35. data/libchdr/deps/lzma-19.00/src/BraIA64.c +53 -0
  36. data/libchdr/deps/lzma-19.00/src/CpuArch.c +218 -0
  37. data/libchdr/deps/lzma-19.00/src/Delta.c +64 -0
  38. data/libchdr/deps/lzma-19.00/src/LzFind.c +1127 -0
  39. data/libchdr/deps/lzma-19.00/src/Lzma86Dec.c +54 -0
  40. data/libchdr/deps/lzma-19.00/src/LzmaDec.c +1185 -0
  41. data/libchdr/deps/lzma-19.00/src/LzmaEnc.c +1330 -0
  42. data/libchdr/deps/lzma-19.00/src/Sort.c +141 -0
  43. data/libchdr/deps/zlib-1.2.11/CMakeLists.txt +29 -0
  44. data/libchdr/deps/zlib-1.2.11/ChangeLog +1515 -0
  45. data/libchdr/deps/zlib-1.2.11/FAQ +368 -0
  46. data/libchdr/deps/zlib-1.2.11/INDEX +68 -0
  47. data/libchdr/deps/zlib-1.2.11/Makefile +5 -0
  48. data/libchdr/deps/zlib-1.2.11/Makefile.in +410 -0
  49. data/libchdr/deps/zlib-1.2.11/README +115 -0
  50. data/libchdr/deps/zlib-1.2.11/adler32.c +186 -0
  51. data/libchdr/deps/zlib-1.2.11/compress.c +86 -0
  52. data/libchdr/deps/zlib-1.2.11/configure +921 -0
  53. data/libchdr/deps/zlib-1.2.11/crc32.c +442 -0
  54. data/libchdr/deps/zlib-1.2.11/crc32.h +441 -0
  55. data/libchdr/deps/zlib-1.2.11/deflate.c +2163 -0
  56. data/libchdr/deps/zlib-1.2.11/deflate.h +349 -0
  57. data/libchdr/deps/zlib-1.2.11/doc/algorithm.txt +209 -0
  58. data/libchdr/deps/zlib-1.2.11/doc/rfc1950.txt +619 -0
  59. data/libchdr/deps/zlib-1.2.11/doc/rfc1951.txt +955 -0
  60. data/libchdr/deps/zlib-1.2.11/doc/rfc1952.txt +675 -0
  61. data/libchdr/deps/zlib-1.2.11/doc/txtvsbin.txt +107 -0
  62. data/libchdr/deps/zlib-1.2.11/gzclose.c +25 -0
  63. data/libchdr/deps/zlib-1.2.11/gzguts.h +218 -0
  64. data/libchdr/deps/zlib-1.2.11/gzlib.c +637 -0
  65. data/libchdr/deps/zlib-1.2.11/gzread.c +654 -0
  66. data/libchdr/deps/zlib-1.2.11/gzwrite.c +665 -0
  67. data/libchdr/deps/zlib-1.2.11/infback.c +640 -0
  68. data/libchdr/deps/zlib-1.2.11/inffast.c +323 -0
  69. data/libchdr/deps/zlib-1.2.11/inffast.h +11 -0
  70. data/libchdr/deps/zlib-1.2.11/inffixed.h +94 -0
  71. data/libchdr/deps/zlib-1.2.11/inflate.c +1561 -0
  72. data/libchdr/deps/zlib-1.2.11/inflate.h +125 -0
  73. data/libchdr/deps/zlib-1.2.11/inftrees.c +304 -0
  74. data/libchdr/deps/zlib-1.2.11/inftrees.h +62 -0
  75. data/libchdr/deps/zlib-1.2.11/make_vms.com +867 -0
  76. data/libchdr/deps/zlib-1.2.11/treebuild.xml +116 -0
  77. data/libchdr/deps/zlib-1.2.11/trees.c +1203 -0
  78. data/libchdr/deps/zlib-1.2.11/trees.h +128 -0
  79. data/libchdr/deps/zlib-1.2.11/uncompr.c +93 -0
  80. data/libchdr/deps/zlib-1.2.11/zconf.h +534 -0
  81. data/libchdr/deps/zlib-1.2.11/zconf.h.cmakein +536 -0
  82. data/libchdr/deps/zlib-1.2.11/zconf.h.in +534 -0
  83. data/libchdr/deps/zlib-1.2.11/zlib.3 +149 -0
  84. data/libchdr/deps/zlib-1.2.11/zlib.3.pdf +0 -0
  85. data/libchdr/deps/zlib-1.2.11/zlib.h +1912 -0
  86. data/libchdr/deps/zlib-1.2.11/zlib.map +94 -0
  87. data/libchdr/deps/zlib-1.2.11/zlib.pc.cmakein +13 -0
  88. data/libchdr/deps/zlib-1.2.11/zlib.pc.in +13 -0
  89. data/libchdr/deps/zlib-1.2.11/zlib2ansi +152 -0
  90. data/libchdr/deps/zlib-1.2.11/zutil.c +325 -0
  91. data/libchdr/deps/zlib-1.2.11/zutil.h +271 -0
  92. data/libchdr/include/dr_libs/dr_flac.h +12280 -0
  93. data/libchdr/include/libchdr/bitstream.h +43 -0
  94. data/libchdr/include/libchdr/cdrom.h +110 -0
  95. data/libchdr/include/libchdr/chd.h +427 -0
  96. data/libchdr/include/libchdr/chdconfig.h +10 -0
  97. data/libchdr/include/libchdr/coretypes.h +60 -0
  98. data/libchdr/include/libchdr/flac.h +50 -0
  99. data/libchdr/include/libchdr/huffman.h +90 -0
  100. data/libchdr/pkg-config.pc.in +10 -0
  101. data/libchdr/src/libchdr_bitstream.c +125 -0
  102. data/libchdr/src/libchdr_cdrom.c +415 -0
  103. data/libchdr/src/libchdr_chd.c +2744 -0
  104. data/libchdr/src/libchdr_flac.c +302 -0
  105. data/libchdr/src/libchdr_huffman.c +545 -0
  106. data/libchdr/src/link.T +5 -0
  107. data/libchdr/tests/CMakeLists.txt +2 -0
  108. data/libchdr/tests/benchmark.c +52 -0
  109. metadata +183 -0
@@ -0,0 +1,336 @@
1
+ /* CpuArch.h -- CPU specific code
2
+ 2018-02-18 : Igor Pavlov : Public domain */
3
+
4
+ #ifndef __CPU_ARCH_H
5
+ #define __CPU_ARCH_H
6
+
7
+ #include "7zTypes.h"
8
+
9
+ EXTERN_C_BEGIN
10
+
11
+ /*
12
+ MY_CPU_LE means that CPU is LITTLE ENDIAN.
13
+ MY_CPU_BE means that CPU is BIG ENDIAN.
14
+ If MY_CPU_LE and MY_CPU_BE are not defined, we don't know about ENDIANNESS of platform.
15
+
16
+ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses.
17
+ */
18
+
19
+ #if defined(_M_X64) \
20
+ || defined(_M_AMD64) \
21
+ || defined(__x86_64__) \
22
+ || defined(__AMD64__) \
23
+ || defined(__amd64__)
24
+ #define MY_CPU_AMD64
25
+ #ifdef __ILP32__
26
+ #define MY_CPU_NAME "x32"
27
+ #else
28
+ #define MY_CPU_NAME "x64"
29
+ #endif
30
+ #define MY_CPU_64BIT
31
+ #endif
32
+
33
+
34
+ #if defined(_M_IX86) \
35
+ || defined(__i386__)
36
+ #define MY_CPU_X86
37
+ #define MY_CPU_NAME "x86"
38
+ #define MY_CPU_32BIT
39
+ #endif
40
+
41
+
42
+ #if defined(_M_ARM64) \
43
+ || defined(__AARCH64EL__) \
44
+ || defined(__AARCH64EB__) \
45
+ || defined(__aarch64__)
46
+ #define MY_CPU_ARM64
47
+ #define MY_CPU_NAME "arm64"
48
+ #define MY_CPU_64BIT
49
+ #endif
50
+
51
+
52
+ #if defined(_M_ARM) \
53
+ || defined(_M_ARM_NT) \
54
+ || defined(_M_ARMT) \
55
+ || defined(__arm__) \
56
+ || defined(__thumb__) \
57
+ || defined(__ARMEL__) \
58
+ || defined(__ARMEB__) \
59
+ || defined(__THUMBEL__) \
60
+ || defined(__THUMBEB__)
61
+ #define MY_CPU_ARM
62
+ #define MY_CPU_NAME "arm"
63
+ #define MY_CPU_32BIT
64
+ #endif
65
+
66
+
67
+ #if defined(_M_IA64) \
68
+ || defined(__ia64__)
69
+ #define MY_CPU_IA64
70
+ #define MY_CPU_NAME "ia64"
71
+ #define MY_CPU_64BIT
72
+ #endif
73
+
74
+
75
+ #if defined(__mips64) \
76
+ || defined(__mips64__) \
77
+ || (defined(__mips) && (__mips == 64 || __mips == 4 || __mips == 3))
78
+ #define MY_CPU_NAME "mips64"
79
+ #define MY_CPU_64BIT
80
+ #elif defined(__mips__)
81
+ #define MY_CPU_NAME "mips"
82
+ /* #define MY_CPU_32BIT */
83
+ #endif
84
+
85
+
86
+ #if defined(__ppc64__) \
87
+ || defined(__powerpc64__)
88
+ #ifdef __ILP32__
89
+ #define MY_CPU_NAME "ppc64-32"
90
+ #else
91
+ #define MY_CPU_NAME "ppc64"
92
+ #endif
93
+ #define MY_CPU_64BIT
94
+ #elif defined(__ppc__) \
95
+ || defined(__powerpc__)
96
+ #define MY_CPU_NAME "ppc"
97
+ #define MY_CPU_32BIT
98
+ #endif
99
+
100
+
101
+ #if defined(__sparc64__)
102
+ #define MY_CPU_NAME "sparc64"
103
+ #define MY_CPU_64BIT
104
+ #elif defined(__sparc__)
105
+ #define MY_CPU_NAME "sparc"
106
+ /* #define MY_CPU_32BIT */
107
+ #endif
108
+
109
+
110
+ #if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)
111
+ #define MY_CPU_X86_OR_AMD64
112
+ #endif
113
+
114
+
115
+ #ifdef _WIN32
116
+
117
+ #ifdef MY_CPU_ARM
118
+ #define MY_CPU_ARM_LE
119
+ #endif
120
+
121
+ #ifdef MY_CPU_ARM64
122
+ #define MY_CPU_ARM64_LE
123
+ #endif
124
+
125
+ #ifdef _M_IA64
126
+ #define MY_CPU_IA64_LE
127
+ #endif
128
+
129
+ #endif
130
+
131
+
132
+ #if defined(MY_CPU_X86_OR_AMD64) \
133
+ || defined(MY_CPU_ARM_LE) \
134
+ || defined(MY_CPU_ARM64_LE) \
135
+ || defined(MY_CPU_IA64_LE) \
136
+ || defined(__LITTLE_ENDIAN__) \
137
+ || defined(__ARMEL__) \
138
+ || defined(__THUMBEL__) \
139
+ || defined(__AARCH64EL__) \
140
+ || defined(__MIPSEL__) \
141
+ || defined(__MIPSEL) \
142
+ || defined(_MIPSEL) \
143
+ || defined(__BFIN__) \
144
+ || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
145
+ #define MY_CPU_LE
146
+ #endif
147
+
148
+ #if defined(__BIG_ENDIAN__) \
149
+ || defined(__ARMEB__) \
150
+ || defined(__THUMBEB__) \
151
+ || defined(__AARCH64EB__) \
152
+ || defined(__MIPSEB__) \
153
+ || defined(__MIPSEB) \
154
+ || defined(_MIPSEB) \
155
+ || defined(__m68k__) \
156
+ || defined(__s390__) \
157
+ || defined(__s390x__) \
158
+ || defined(__zarch__) \
159
+ || (defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__))
160
+ #define MY_CPU_BE
161
+ #endif
162
+
163
+
164
+ #if defined(MY_CPU_LE) && defined(MY_CPU_BE)
165
+ #error Stop_Compiling_Bad_Endian
166
+ #endif
167
+
168
+
169
+ #if defined(MY_CPU_32BIT) && defined(MY_CPU_64BIT)
170
+ #error Stop_Compiling_Bad_32_64_BIT
171
+ #endif
172
+
173
+
174
+ #ifndef MY_CPU_NAME
175
+ #ifdef MY_CPU_LE
176
+ #define MY_CPU_NAME "LE"
177
+ #elif defined(MY_CPU_BE)
178
+ #define MY_CPU_NAME "BE"
179
+ #else
180
+ /*
181
+ #define MY_CPU_NAME ""
182
+ */
183
+ #endif
184
+ #endif
185
+
186
+
187
+
188
+
189
+
190
+ #ifdef MY_CPU_LE
191
+ #if defined(MY_CPU_X86_OR_AMD64) \
192
+ || defined(MY_CPU_ARM64) \
193
+ || defined(__ARM_FEATURE_UNALIGNED)
194
+ #define MY_CPU_LE_UNALIGN
195
+ #endif
196
+ #endif
197
+
198
+
199
+ #ifdef MY_CPU_LE_UNALIGN
200
+
201
+ #define GetUi16(p) (*(const UInt16 *)(const void *)(p))
202
+ #define GetUi32(p) (*(const UInt32 *)(const void *)(p))
203
+ #define GetUi64(p) (*(const UInt64 *)(const void *)(p))
204
+
205
+ #define SetUi16(p, v) { *(UInt16 *)(p) = (v); }
206
+ #define SetUi32(p, v) { *(UInt32 *)(p) = (v); }
207
+ #define SetUi64(p, v) { *(UInt64 *)(p) = (v); }
208
+
209
+ #else
210
+
211
+ #define GetUi16(p) ( (UInt16) ( \
212
+ ((const Byte *)(p))[0] | \
213
+ ((UInt16)((const Byte *)(p))[1] << 8) ))
214
+
215
+ #define GetUi32(p) ( \
216
+ ((const Byte *)(p))[0] | \
217
+ ((UInt32)((const Byte *)(p))[1] << 8) | \
218
+ ((UInt32)((const Byte *)(p))[2] << 16) | \
219
+ ((UInt32)((const Byte *)(p))[3] << 24))
220
+
221
+ #define GetUi64(p) (GetUi32(p) | ((UInt64)GetUi32(((const Byte *)(p)) + 4) << 32))
222
+
223
+ #define SetUi16(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
224
+ _ppp_[0] = (Byte)_vvv_; \
225
+ _ppp_[1] = (Byte)(_vvv_ >> 8); }
226
+
227
+ #define SetUi32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
228
+ _ppp_[0] = (Byte)_vvv_; \
229
+ _ppp_[1] = (Byte)(_vvv_ >> 8); \
230
+ _ppp_[2] = (Byte)(_vvv_ >> 16); \
231
+ _ppp_[3] = (Byte)(_vvv_ >> 24); }
232
+
233
+ #define SetUi64(p, v) { Byte *_ppp2_ = (Byte *)(p); UInt64 _vvv2_ = (v); \
234
+ SetUi32(_ppp2_ , (UInt32)_vvv2_); \
235
+ SetUi32(_ppp2_ + 4, (UInt32)(_vvv2_ >> 32)); }
236
+
237
+ #endif
238
+
239
+ #ifdef __has_builtin
240
+ #define MY__has_builtin(x) __has_builtin(x)
241
+ #else
242
+ #define MY__has_builtin(x) 0
243
+ #endif
244
+
245
+ #if defined(MY_CPU_LE_UNALIGN) && /* defined(_WIN64) && */ (_MSC_VER >= 1300)
246
+
247
+ /* Note: we use bswap instruction, that is unsupported in 386 cpu */
248
+
249
+ #include <stdlib.h>
250
+
251
+ #pragma intrinsic(_byteswap_ushort)
252
+ #pragma intrinsic(_byteswap_ulong)
253
+ #pragma intrinsic(_byteswap_uint64)
254
+
255
+ /* #define GetBe16(p) _byteswap_ushort(*(const UInt16 *)(const Byte *)(p)) */
256
+ #define GetBe32(p) _byteswap_ulong(*(const UInt32 *)(const Byte *)(p))
257
+ #define GetBe64(p) _byteswap_uint64(*(const UInt64 *)(const Byte *)(p))
258
+
259
+ #define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = _byteswap_ulong(v)
260
+
261
+ #elif defined(MY_CPU_LE_UNALIGN) && ( \
262
+ (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
263
+ || (defined(__clang__) && MY__has_builtin(__builtin_bswap16)) )
264
+
265
+ /* #define GetBe16(p) __builtin_bswap16(*(const UInt16 *)(const Byte *)(p)) */
266
+ #define GetBe32(p) __builtin_bswap32(*(const UInt32 *)(const Byte *)(p))
267
+ #define GetBe64(p) __builtin_bswap64(*(const UInt64 *)(const Byte *)(p))
268
+
269
+ #define SetBe32(p, v) (*(UInt32 *)(void *)(p)) = __builtin_bswap32(v)
270
+
271
+ #else
272
+
273
+ #define GetBe32(p) ( \
274
+ ((UInt32)((const Byte *)(p))[0] << 24) | \
275
+ ((UInt32)((const Byte *)(p))[1] << 16) | \
276
+ ((UInt32)((const Byte *)(p))[2] << 8) | \
277
+ ((const Byte *)(p))[3] )
278
+
279
+ #define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
280
+
281
+ #define SetBe32(p, v) { Byte *_ppp_ = (Byte *)(p); UInt32 _vvv_ = (v); \
282
+ _ppp_[0] = (Byte)(_vvv_ >> 24); \
283
+ _ppp_[1] = (Byte)(_vvv_ >> 16); \
284
+ _ppp_[2] = (Byte)(_vvv_ >> 8); \
285
+ _ppp_[3] = (Byte)_vvv_; }
286
+
287
+ #endif
288
+
289
+
290
+ #ifndef GetBe16
291
+
292
+ #define GetBe16(p) ( (UInt16) ( \
293
+ ((UInt16)((const Byte *)(p))[0] << 8) | \
294
+ ((const Byte *)(p))[1] ))
295
+
296
+ #endif
297
+
298
+
299
+
300
+ #ifdef MY_CPU_X86_OR_AMD64
301
+
302
+ typedef struct
303
+ {
304
+ UInt32 maxFunc;
305
+ UInt32 vendor[3];
306
+ UInt32 ver;
307
+ UInt32 b;
308
+ UInt32 c;
309
+ UInt32 d;
310
+ } Cx86cpuid;
311
+
312
+ enum
313
+ {
314
+ CPU_FIRM_INTEL,
315
+ CPU_FIRM_AMD,
316
+ CPU_FIRM_VIA
317
+ };
318
+
319
+ void MyCPUID(UInt32 function, UInt32 *a, UInt32 *b, UInt32 *c, UInt32 *d);
320
+
321
+ BoolInt x86cpuid_CheckAndRead(Cx86cpuid *p);
322
+ int x86cpuid_GetFirm(const Cx86cpuid *p);
323
+
324
+ #define x86cpuid_GetFamily(ver) (((ver >> 16) & 0xFF0) | ((ver >> 8) & 0xF))
325
+ #define x86cpuid_GetModel(ver) (((ver >> 12) & 0xF0) | ((ver >> 4) & 0xF))
326
+ #define x86cpuid_GetStepping(ver) (ver & 0xF)
327
+
328
+ BoolInt CPU_Is_InOrder();
329
+ BoolInt CPU_Is_Aes_Supported();
330
+ BoolInt CPU_IsSupported_PageGB();
331
+
332
+ #endif
333
+
334
+ EXTERN_C_END
335
+
336
+ #endif
@@ -0,0 +1,19 @@
1
+ /* Delta.h -- Delta converter
2
+ 2013-01-18 : Igor Pavlov : Public domain */
3
+
4
+ #ifndef __DELTA_H
5
+ #define __DELTA_H
6
+
7
+ #include "7zTypes.h"
8
+
9
+ EXTERN_C_BEGIN
10
+
11
+ #define DELTA_STATE_SIZE 256
12
+
13
+ void Delta_Init(Byte *state);
14
+ void Delta_Encode(Byte *state, unsigned delta, Byte *data, SizeT size);
15
+ void Delta_Decode(Byte *state, unsigned delta, Byte *data, SizeT size);
16
+
17
+ EXTERN_C_END
18
+
19
+ #endif
@@ -0,0 +1,121 @@
1
+ /* LzFind.h -- Match finder for LZ algorithms
2
+ 2017-06-10 : Igor Pavlov : Public domain */
3
+
4
+ #ifndef __LZ_FIND_H
5
+ #define __LZ_FIND_H
6
+
7
+ #include "7zTypes.h"
8
+
9
+ EXTERN_C_BEGIN
10
+
11
+ typedef UInt32 CLzRef;
12
+
13
+ typedef struct _CMatchFinder
14
+ {
15
+ Byte *buffer;
16
+ UInt32 pos;
17
+ UInt32 posLimit;
18
+ UInt32 streamPos;
19
+ UInt32 lenLimit;
20
+
21
+ UInt32 cyclicBufferPos;
22
+ UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
23
+
24
+ Byte streamEndWasReached;
25
+ Byte btMode;
26
+ Byte bigHash;
27
+ Byte directInput;
28
+
29
+ UInt32 matchMaxLen;
30
+ CLzRef *hash;
31
+ CLzRef *son;
32
+ UInt32 hashMask;
33
+ UInt32 cutValue;
34
+
35
+ Byte *bufferBase;
36
+ ISeqInStream *stream;
37
+
38
+ UInt32 blockSize;
39
+ UInt32 keepSizeBefore;
40
+ UInt32 keepSizeAfter;
41
+
42
+ UInt32 numHashBytes;
43
+ size_t directInputRem;
44
+ UInt32 historySize;
45
+ UInt32 fixedHashSize;
46
+ UInt32 hashSizeSum;
47
+ SRes result;
48
+ UInt32 crc[256];
49
+ size_t numRefs;
50
+
51
+ UInt64 expectedDataSize;
52
+ } CMatchFinder;
53
+
54
+ #define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
55
+
56
+ #define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
57
+
58
+ #define Inline_MatchFinder_IsFinishedOK(p) \
59
+ ((p)->streamEndWasReached \
60
+ && (p)->streamPos == (p)->pos \
61
+ && (!(p)->directInput || (p)->directInputRem == 0))
62
+
63
+ int MatchFinder_NeedMove(CMatchFinder *p);
64
+ Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
65
+ void MatchFinder_MoveBlock(CMatchFinder *p);
66
+ void MatchFinder_ReadIfRequired(CMatchFinder *p);
67
+
68
+ void MatchFinder_Construct(CMatchFinder *p);
69
+
70
+ /* Conditions:
71
+ historySize <= 3 GB
72
+ keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
73
+ */
74
+ int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
75
+ UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
76
+ ISzAllocPtr alloc);
77
+ void MatchFinder_Free(CMatchFinder *p, ISzAllocPtr alloc);
78
+ void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, size_t numItems);
79
+ void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
80
+
81
+ UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
82
+ UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
83
+ UInt32 *distances, UInt32 maxLen);
84
+
85
+ /*
86
+ Conditions:
87
+ Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
88
+ Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
89
+ */
90
+
91
+ typedef void (*Mf_Init_Func)(void *object);
92
+ typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
93
+ typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
94
+ typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
95
+ typedef void (*Mf_Skip_Func)(void *object, UInt32);
96
+
97
+ typedef struct _IMatchFinder
98
+ {
99
+ Mf_Init_Func Init;
100
+ Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
101
+ Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
102
+ Mf_GetMatches_Func GetMatches;
103
+ Mf_Skip_Func Skip;
104
+ } IMatchFinder;
105
+
106
+ void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
107
+
108
+ void MatchFinder_Init_LowHash(CMatchFinder *p);
109
+ void MatchFinder_Init_HighHash(CMatchFinder *p);
110
+ void MatchFinder_Init_3(CMatchFinder *p, int readData);
111
+ void MatchFinder_Init(CMatchFinder *p);
112
+
113
+ UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
114
+ UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
115
+
116
+ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
117
+ void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
118
+
119
+ EXTERN_C_END
120
+
121
+ #endif
@@ -0,0 +1,57 @@
1
+ /* LzHash.h -- HASH functions for LZ algorithms
2
+ 2015-04-12 : Igor Pavlov : Public domain */
3
+
4
+ #ifndef __LZ_HASH_H
5
+ #define __LZ_HASH_H
6
+
7
+ #define kHash2Size (1 << 10)
8
+ #define kHash3Size (1 << 16)
9
+ #define kHash4Size (1 << 20)
10
+
11
+ #define kFix3HashSize (kHash2Size)
12
+ #define kFix4HashSize (kHash2Size + kHash3Size)
13
+ #define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
14
+
15
+ #define HASH2_CALC hv = cur[0] | ((UInt32)cur[1] << 8);
16
+
17
+ #define HASH3_CALC { \
18
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
19
+ h2 = temp & (kHash2Size - 1); \
20
+ hv = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
21
+
22
+ #define HASH4_CALC { \
23
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
24
+ h2 = temp & (kHash2Size - 1); \
25
+ temp ^= ((UInt32)cur[2] << 8); \
26
+ h3 = temp & (kHash3Size - 1); \
27
+ hv = (temp ^ (p->crc[cur[3]] << 5)) & p->hashMask; }
28
+
29
+ #define HASH5_CALC { \
30
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
31
+ h2 = temp & (kHash2Size - 1); \
32
+ temp ^= ((UInt32)cur[2] << 8); \
33
+ h3 = temp & (kHash3Size - 1); \
34
+ temp ^= (p->crc[cur[3]] << 5); \
35
+ h4 = temp & (kHash4Size - 1); \
36
+ hv = (temp ^ (p->crc[cur[4]] << 3)) & p->hashMask; }
37
+
38
+ /* #define HASH_ZIP_CALC hv = ((cur[0] | ((UInt32)cur[1] << 8)) ^ p->crc[cur[2]]) & 0xFFFF; */
39
+ #define HASH_ZIP_CALC hv = ((cur[2] | ((UInt32)cur[0] << 8)) ^ p->crc[cur[1]]) & 0xFFFF;
40
+
41
+
42
+ #define MT_HASH2_CALC \
43
+ h2 = (p->crc[cur[0]] ^ cur[1]) & (kHash2Size - 1);
44
+
45
+ #define MT_HASH3_CALC { \
46
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
47
+ h2 = temp & (kHash2Size - 1); \
48
+ h3 = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
49
+
50
+ #define MT_HASH4_CALC { \
51
+ UInt32 temp = p->crc[cur[0]] ^ cur[1]; \
52
+ h2 = temp & (kHash2Size - 1); \
53
+ temp ^= ((UInt32)cur[2] << 8); \
54
+ h3 = temp & (kHash3Size - 1); \
55
+ h4 = (temp ^ (p->crc[cur[3]] << 5)) & (kHash4Size - 1); }
56
+
57
+ #endif
@@ -0,0 +1,111 @@
1
+ /* Lzma86.h -- LZMA + x86 (BCJ) Filter
2
+ 2013-01-18 : Igor Pavlov : Public domain */
3
+
4
+ #ifndef __LZMA86_H
5
+ #define __LZMA86_H
6
+
7
+ #include "7zTypes.h"
8
+
9
+ EXTERN_C_BEGIN
10
+
11
+ #define LZMA86_SIZE_OFFSET (1 + 5)
12
+ #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
13
+
14
+ /*
15
+ It's an example for LZMA + x86 Filter use.
16
+ You can use .lzma86 extension, if you write that stream to file.
17
+ .lzma86 header adds one additional byte to standard .lzma header.
18
+ .lzma86 header (14 bytes):
19
+ Offset Size Description
20
+ 0 1 = 0 - no filter, pure LZMA
21
+ = 1 - x86 filter + LZMA
22
+ 1 1 lc, lp and pb in encoded form
23
+ 2 4 dictSize (little endian)
24
+ 6 8 uncompressed size (little endian)
25
+
26
+
27
+ Lzma86_Encode
28
+ -------------
29
+ level - compression level: 0 <= level <= 9, the default value for "level" is 5.
30
+
31
+ dictSize - The dictionary size in bytes. The maximum value is
32
+ 128 MB = (1 << 27) bytes for 32-bit version
33
+ 1 GB = (1 << 30) bytes for 64-bit version
34
+ The default value is 16 MB = (1 << 24) bytes, for level = 5.
35
+ It's recommended to use the dictionary that is larger than 4 KB and
36
+ that can be calculated as (1 << N) or (3 << N) sizes.
37
+ For better compression ratio dictSize must be >= inSize.
38
+
39
+ filterMode:
40
+ SZ_FILTER_NO - no Filter
41
+ SZ_FILTER_YES - x86 Filter
42
+ SZ_FILTER_AUTO - it tries both alternatives to select best.
43
+ Encoder will use 2 or 3 passes:
44
+ 2 passes when FILTER_NO provides better compression.
45
+ 3 passes when FILTER_YES provides better compression.
46
+
47
+ Lzma86Encode allocates Data with MyAlloc functions.
48
+ RAM Requirements for compressing:
49
+ RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize
50
+ filterMode FilterBlockSize
51
+ SZ_FILTER_NO 0
52
+ SZ_FILTER_YES inSize
53
+ SZ_FILTER_AUTO inSize
54
+
55
+
56
+ Return code:
57
+ SZ_OK - OK
58
+ SZ_ERROR_MEM - Memory allocation error
59
+ SZ_ERROR_PARAM - Incorrect paramater
60
+ SZ_ERROR_OUTPUT_EOF - output buffer overflow
61
+ SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
62
+ */
63
+
64
+ enum ESzFilterMode
65
+ {
66
+ SZ_FILTER_NO,
67
+ SZ_FILTER_YES,
68
+ SZ_FILTER_AUTO
69
+ };
70
+
71
+ SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
72
+ int level, UInt32 dictSize, int filterMode);
73
+
74
+
75
+ /*
76
+ Lzma86_GetUnpackSize:
77
+ In:
78
+ src - input data
79
+ srcLen - input data size
80
+ Out:
81
+ unpackSize - size of uncompressed stream
82
+ Return code:
83
+ SZ_OK - OK
84
+ SZ_ERROR_INPUT_EOF - Error in headers
85
+ */
86
+
87
+ SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);
88
+
89
+ /*
90
+ Lzma86_Decode:
91
+ In:
92
+ dest - output data
93
+ destLen - output data size
94
+ src - input data
95
+ srcLen - input data size
96
+ Out:
97
+ destLen - processed output size
98
+ srcLen - processed input size
99
+ Return code:
100
+ SZ_OK - OK
101
+ SZ_ERROR_DATA - Data error
102
+ SZ_ERROR_MEM - Memory allocation error
103
+ SZ_ERROR_UNSUPPORTED - unsupported file
104
+ SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
105
+ */
106
+
107
+ SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);
108
+
109
+ EXTERN_C_END
110
+
111
+ #endif