1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/other-licenses/7zstub/src/DOC/lzma.txt Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,630 @@ 1.4 +LZMA SDK 4.40 1.5 +------------- 1.6 + 1.7 +LZMA SDK Copyright (C) 1999-2006 Igor Pavlov 1.8 + 1.9 +LZMA SDK provides the documentation, samples, header files, libraries, 1.10 +and tools you need to develop applications that use LZMA compression. 1.11 + 1.12 +LZMA is default and general compression method of 7z format 1.13 +in 7-Zip compression program (www.7-zip.org). LZMA provides high 1.14 +compression ratio and very fast decompression. 1.15 + 1.16 +LZMA is an improved version of famous LZ77 compression algorithm. 1.17 +It was improved in way of maximum increasing of compression ratio, 1.18 +keeping high decompression speed and low memory requirements for 1.19 +decompressing. 1.20 + 1.21 + 1.22 + 1.23 +LICENSE 1.24 +------- 1.25 + 1.26 +LZMA SDK is available under any of the following licenses: 1.27 + 1.28 +1) GNU Lesser General Public License (GNU LGPL) 1.29 +2) Common Public License (CPL) 1.30 +3) Simplified license for unmodified code (read SPECIAL EXCEPTION) 1.31 +4) Proprietary license 1.32 + 1.33 +It means that you can select one of these four options and follow rules of that license. 1.34 + 1.35 + 1.36 +1,2) GNU LGPL and CPL licenses are pretty similar and both these 1.37 +licenses are classified as 1.38 + - "Free software licenses" at http://www.gnu.org/ 1.39 + - "OSI-approved" at http://www.opensource.org/ 1.40 + 1.41 + 1.42 +3) SPECIAL EXCEPTION 1.43 + 1.44 +Igor Pavlov, as the author of this code, expressly permits you 1.45 +to statically or dynamically link your code (or bind by name) 1.46 +to the files from LZMA SDK without subjecting your linked 1.47 +code to the terms of the CPL or GNU LGPL. 1.48 +Any modifications or additions to files from LZMA SDK, however, 1.49 +are subject to the GNU LGPL or CPL terms. 1.50 + 1.51 +SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code, 1.52 +while you keep LZMA SDK code unmodified. 1.53 + 1.54 + 1.55 +SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits 1.56 +you to use this code under the same terms and conditions contained in the License 1.57 +Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov. 1.58 + 1.59 +SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version 1.60 +of LZMA SDK as update for previous versions. 1.61 + 1.62 + 1.63 +SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits 1.64 +you to use code of the following files: 1.65 +BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp, 1.66 +LzmaAlone.cs, LzmaAlone.java 1.67 +as public domain code. 1.68 + 1.69 + 1.70 +4) Proprietary license 1.71 + 1.72 +LZMA SDK also can be available under a proprietary license which 1.73 +can include: 1.74 + 1.75 +1) Right to modify code without subjecting modified code to the 1.76 +terms of the CPL or GNU LGPL 1.77 +2) Technical support for code 1.78 + 1.79 +To request such proprietary license or any additional consultations, 1.80 +send email message from that page: 1.81 +http://www.7-zip.org/support.html 1.82 + 1.83 + 1.84 +You should have received a copy of the GNU Lesser General Public 1.85 +License along with this library; if not, write to the Free Software 1.86 +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 1.87 + 1.88 +You should have received a copy of the Common Public License 1.89 +along with this library. 1.90 + 1.91 + 1.92 +LZMA SDK Contents 1.93 +----------------- 1.94 + 1.95 +LZMA SDK includes: 1.96 + 1.97 + - C++ source code of LZMA compressing and decompressing 1.98 + - ANSI-C compatible source code for LZMA decompressing 1.99 + - C# source code for LZMA compressing and decompressing 1.100 + - Java source code for LZMA compressing and decompressing 1.101 + - Compiled file->file LZMA compressing/decompressing program for Windows system 1.102 + 1.103 +ANSI-C LZMA decompression code was ported from original C++ sources to C. 1.104 +Also it was simplified and optimized for code size. 1.105 +But it is fully compatible with LZMA from 7-Zip. 1.106 + 1.107 + 1.108 +UNIX/Linux version 1.109 +------------------ 1.110 +To compile C++ version of file->file LZMA, go to directory 1.111 +C/7zip/Compress/LZMA_Alone 1.112 +and type "make" or "make clean all" to recompile all. 1.113 + 1.114 +In some UNIX/Linux versions you must compile LZMA with static libraries. 1.115 +To compile with static libraries, change string in makefile 1.116 +LIB = -lm 1.117 +to string 1.118 +LIB = -lm -static 1.119 + 1.120 + 1.121 +Files 1.122 +--------------------- 1.123 +C - C / CPP source code 1.124 +CS - C# source code 1.125 +Java - Java source code 1.126 +lzma.txt - LZMA SDK description (this file) 1.127 +7zFormat.txt - 7z Format description 1.128 +7zC.txt - 7z ANSI-C Decoder description (this file) 1.129 +methods.txt - Compression method IDs for .7z 1.130 +LGPL.txt - GNU Lesser General Public License 1.131 +CPL.html - Common Public License 1.132 +lzma.exe - Compiled file->file LZMA encoder/decoder for Windows 1.133 +history.txt - history of the LZMA SDK 1.134 + 1.135 + 1.136 +Source code structure 1.137 +--------------------- 1.138 + 1.139 +C - C / CPP files 1.140 + Common - common files for C++ projects 1.141 + Windows - common files for Windows related code 1.142 + 7zip - files related to 7-Zip Project 1.143 + Common - common files for 7-Zip 1.144 + Compress - files related to compression/decompression 1.145 + LZ - files related to LZ (Lempel-Ziv) compression algorithm 1.146 + BinTree - Binary Tree Match Finder for LZ algorithm 1.147 + HashChain - Hash Chain Match Finder for LZ algorithm 1.148 + Patricia - Patricia Match Finder for LZ algorithm 1.149 + RangeCoder - Range Coder (special code of compression/decompression) 1.150 + LZMA - LZMA compression/decompression on C++ 1.151 + LZMA_Alone - file->file LZMA compression/decompression 1.152 + LZMA_C - ANSI-C compatible LZMA decompressor 1.153 + LzmaDecode.h - interface for LZMA decoding on ANSI-C 1.154 + LzmaDecode.c - LZMA decoding on ANSI-C (new fastest version) 1.155 + LzmaDecodeSize.c - LZMA decoding on ANSI-C (old size-optimized version) 1.156 + LzmaTest.c - test application that decodes LZMA encoded file 1.157 + LzmaTypes.h - basic types for LZMA Decoder 1.158 + LzmaStateDecode.h - interface for LZMA decoding (State version) 1.159 + LzmaStateDecode.c - LZMA decoding on ANSI-C (State version) 1.160 + LzmaStateTest.c - test application (State version) 1.161 + Branch - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code 1.162 + Archive - files related to archiving 1.163 + 7z_C - 7z ANSI-C Decoder 1.164 + 1.165 +CS - C# files 1.166 + 7zip 1.167 + Common - some common files for 7-Zip 1.168 + Compress - files related to compression/decompression 1.169 + LZ - files related to LZ (Lempel-Ziv) compression algorithm 1.170 + LZMA - LZMA compression/decompression 1.171 + LzmaAlone - file->file LZMA compression/decompression 1.172 + RangeCoder - Range Coder (special code of compression/decompression) 1.173 + 1.174 +Java - Java files 1.175 + SevenZip 1.176 + Compression - files related to compression/decompression 1.177 + LZ - files related to LZ (Lempel-Ziv) compression algorithm 1.178 + LZMA - LZMA compression/decompression 1.179 + RangeCoder - Range Coder (special code of compression/decompression) 1.180 + 1.181 +C/C++ source code of LZMA SDK is part of 7-Zip project. 1.182 + 1.183 +You can find ANSI-C LZMA decompressing code at folder 1.184 + C/7zip/Compress/LZMA_C 1.185 +7-Zip doesn't use that ANSI-C LZMA code and that code was developed 1.186 +specially for this SDK. And files from LZMA_C do not need files from 1.187 +other directories of SDK for compiling. 1.188 + 1.189 +7-Zip source code can be downloaded from 7-Zip's SourceForge page: 1.190 + 1.191 + http://sourceforge.net/projects/sevenzip/ 1.192 + 1.193 + 1.194 +LZMA features 1.195 +------------- 1.196 + - Variable dictionary size (up to 1 GB) 1.197 + - Estimated compressing speed: about 1 MB/s on 1 GHz CPU 1.198 + - Estimated decompressing speed: 1.199 + - 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon 1.200 + - 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC 1.201 + - Small memory requirements for decompressing (8-32 KB + DictionarySize) 1.202 + - Small code size for decompressing: 2-8 KB (depending from 1.203 + speed optimizations) 1.204 + 1.205 +LZMA decoder uses only integer operations and can be 1.206 +implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions). 1.207 + 1.208 +Some critical operations that affect to speed of LZMA decompression: 1.209 + 1) 32*16 bit integer multiply 1.210 + 2) Misspredicted branches (penalty mostly depends from pipeline length) 1.211 + 3) 32-bit shift and arithmetic operations 1.212 + 1.213 +Speed of LZMA decompressing mostly depends from CPU speed. 1.214 +Memory speed has no big meaning. But if your CPU has small data cache, 1.215 +overall weight of memory speed will slightly increase. 1.216 + 1.217 + 1.218 +How To Use 1.219 +---------- 1.220 + 1.221 +Using LZMA encoder/decoder executable 1.222 +-------------------------------------- 1.223 + 1.224 +Usage: LZMA <e|d> inputFile outputFile [<switches>...] 1.225 + 1.226 + e: encode file 1.227 + 1.228 + d: decode file 1.229 + 1.230 + b: Benchmark. There are two tests: compressing and decompressing 1.231 + with LZMA method. Benchmark shows rating in MIPS (million 1.232 + instructions per second). Rating value is calculated from 1.233 + measured speed and it is normalized with AMD Athlon 64 X2 CPU 1.234 + results. Also Benchmark checks possible hardware errors (RAM 1.235 + errors in most cases). Benchmark uses these settings: 1.236 + (-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you 1.237 + can change number of iterations. Example for 30 iterations: 1.238 + LZMA b 30 1.239 + Default number of iterations is 10. 1.240 + 1.241 +<Switches> 1.242 + 1.243 + 1.244 + -a{N}: set compression mode 0 = fast, 1 = normal 1.245 + default: 1 (normal) 1.246 + 1.247 + d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB) 1.248 + The maximum value for dictionary size is 1 GB = 2^30 bytes. 1.249 + Dictionary size is calculated as DictionarySize = 2^N bytes. 1.250 + For decompressing file compressed by LZMA method with dictionary 1.251 + size D = 2^N you need about D bytes of memory (RAM). 1.252 + 1.253 + -fb{N}: set number of fast bytes - [5, 273], default: 128 1.254 + Usually big number gives a little bit better compression ratio 1.255 + and slower compression process. 1.256 + 1.257 + -lc{N}: set number of literal context bits - [0, 8], default: 3 1.258 + Sometimes lc=4 gives gain for big files. 1.259 + 1.260 + -lp{N}: set number of literal pos bits - [0, 4], default: 0 1.261 + lp switch is intended for periodical data when period is 1.262 + equal 2^N. For example, for 32-bit (4 bytes) 1.263 + periodical data you can use lp=2. Often it's better to set lc0, 1.264 + if you change lp switch. 1.265 + 1.266 + -pb{N}: set number of pos bits - [0, 4], default: 2 1.267 + pb switch is intended for periodical data 1.268 + when period is equal 2^N. 1.269 + 1.270 + -mf{MF_ID}: set Match Finder. Default: bt4. 1.271 + Algorithms from hc* group doesn't provide good compression 1.272 + ratio, but they often works pretty fast in combination with 1.273 + fast mode (-a0). 1.274 + 1.275 + Memory requirements depend from dictionary size 1.276 + (parameter "d" in table below). 1.277 + 1.278 + MF_ID Memory Description 1.279 + 1.280 + bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing. 1.281 + bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing. 1.282 + bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing. 1.283 + hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing. 1.284 + 1.285 + -eos: write End Of Stream marker. By default LZMA doesn't write 1.286 + eos marker, since LZMA decoder knows uncompressed size 1.287 + stored in .lzma file header. 1.288 + 1.289 + -si: Read data from stdin (it will write End Of Stream marker). 1.290 + -so: Write data to stdout 1.291 + 1.292 + 1.293 +Examples: 1.294 + 1.295 +1) LZMA e file.bin file.lzma -d16 -lc0 1.296 + 1.297 +compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K) 1.298 +and 0 literal context bits. -lc0 allows to reduce memory requirements 1.299 +for decompression. 1.300 + 1.301 + 1.302 +2) LZMA e file.bin file.lzma -lc0 -lp2 1.303 + 1.304 +compresses file.bin to file.lzma with settings suitable 1.305 +for 32-bit periodical data (for example, ARM or MIPS code). 1.306 + 1.307 +3) LZMA d file.lzma file.bin 1.308 + 1.309 +decompresses file.lzma to file.bin. 1.310 + 1.311 + 1.312 +Compression ratio hints 1.313 +----------------------- 1.314 + 1.315 +Recommendations 1.316 +--------------- 1.317 + 1.318 +To increase compression ratio for LZMA compressing it's desirable 1.319 +to have aligned data (if it's possible) and also it's desirable to locate 1.320 +data in such order, where code is grouped in one place and data is 1.321 +grouped in other place (it's better than such mixing: code, data, code, 1.322 +data, ...). 1.323 + 1.324 + 1.325 +Using Filters 1.326 +------------- 1.327 +You can increase compression ratio for some data types, using 1.328 +special filters before compressing. For example, it's possible to 1.329 +increase compression ratio on 5-10% for code for those CPU ISAs: 1.330 +x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC. 1.331 + 1.332 +You can find C/C++ source code of such filters in folder "7zip/Compress/Branch" 1.333 + 1.334 +You can check compression ratio gain of these filters with such 1.335 +7-Zip commands (example for ARM code): 1.336 +No filter: 1.337 + 7z a a1.7z a.bin -m0=lzma 1.338 + 1.339 +With filter for little-endian ARM code: 1.340 + 7z a a2.7z a.bin -m0=bc_arm -m1=lzma 1.341 + 1.342 +With filter for big-endian ARM code (using additional Swap4 filter): 1.343 + 7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma 1.344 + 1.345 +It works in such manner: 1.346 +Compressing = Filter_encoding + LZMA_encoding 1.347 +Decompressing = LZMA_decoding + Filter_decoding 1.348 + 1.349 +Compressing and decompressing speed of such filters is very high, 1.350 +so it will not increase decompressing time too much. 1.351 +Moreover, it reduces decompression time for LZMA_decoding, 1.352 +since compression ratio with filtering is higher. 1.353 + 1.354 +These filters convert CALL (calling procedure) instructions 1.355 +from relative offsets to absolute addresses, so such data becomes more 1.356 +compressible. Source code of these CALL filters is pretty simple 1.357 +(about 20 lines of C++), so you can convert it from C++ version yourself. 1.358 + 1.359 +For some ISAs (for example, for MIPS) it's impossible to get gain from such filter. 1.360 + 1.361 + 1.362 +LZMA compressed file format 1.363 +--------------------------- 1.364 +Offset Size Description 1.365 + 0 1 Special LZMA properties for compressed data 1.366 + 1 4 Dictionary size (little endian) 1.367 + 5 8 Uncompressed size (little endian). -1 means unknown size 1.368 + 13 Compressed data 1.369 + 1.370 + 1.371 +ANSI-C LZMA Decoder 1.372 +~~~~~~~~~~~~~~~~~~~ 1.373 + 1.374 +To compile ANSI-C LZMA Decoder you can use one of the following files sets: 1.375 +1) LzmaDecode.h + LzmaDecode.c + LzmaTest.c (fastest version) 1.376 +2) LzmaDecode.h + LzmaDecodeSize.c + LzmaTest.c (old size-optimized version) 1.377 +3) LzmaStateDecode.h + LzmaStateDecode.c + LzmaStateTest.c (zlib-like interface) 1.378 + 1.379 + 1.380 +Memory requirements for LZMA decoding 1.381 +------------------------------------- 1.382 + 1.383 +LZMA decoder doesn't allocate memory itself, so you must 1.384 +allocate memory and send it to LZMA. 1.385 + 1.386 +Stack usage of LZMA decoding function for local variables is not 1.387 +larger than 200 bytes. 1.388 + 1.389 +How To decompress data 1.390 +---------------------- 1.391 + 1.392 +LZMA Decoder (ANSI-C version) now supports 5 interfaces: 1.393 +1) Single-call Decompressing 1.394 +2) Single-call Decompressing with input stream callback 1.395 +3) Multi-call Decompressing with output buffer 1.396 +4) Multi-call Decompressing with input callback and output buffer 1.397 +5) Multi-call State Decompressing (zlib-like interface) 1.398 + 1.399 +Variant-5 is similar to Variant-4, but Variant-5 doesn't use callback functions. 1.400 + 1.401 +Decompressing steps 1.402 +------------------- 1.403 + 1.404 +1) read LZMA properties (5 bytes): 1.405 + unsigned char properties[LZMA_PROPERTIES_SIZE]; 1.406 + 1.407 +2) read uncompressed size (8 bytes, little-endian) 1.408 + 1.409 +3) Decode properties: 1.410 + 1.411 + CLzmaDecoderState state; /* it's 24-140 bytes structure, if int is 32-bit */ 1.412 + 1.413 + if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) 1.414 + return PrintError(rs, "Incorrect stream properties"); 1.415 + 1.416 +4) Allocate memory block for internal Structures: 1.417 + 1.418 + state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb)); 1.419 + if (state.Probs == 0) 1.420 + return PrintError(rs, kCantAllocateMessage); 1.421 + 1.422 + LZMA decoder uses array of CProb variables as internal structure. 1.423 + By default, CProb is unsigned_short. But you can define _LZMA_PROB32 to make 1.424 + it unsigned_int. It can increase speed on some 32-bit CPUs, but memory 1.425 + usage will be doubled in that case. 1.426 + 1.427 + 1.428 +5) Main Decompressing 1.429 + 1.430 +You must use one of the following interfaces: 1.431 + 1.432 +5.1 Single-call Decompressing 1.433 +----------------------------- 1.434 +When to use: RAM->RAM decompressing 1.435 +Compile files: LzmaDecode.h, LzmaDecode.c 1.436 +Compile defines: no defines 1.437 +Memory Requirements: 1.438 + - Input buffer: compressed size 1.439 + - Output buffer: uncompressed size 1.440 + - LZMA Internal Structures (~16 KB for default settings) 1.441 + 1.442 +Interface: 1.443 + int res = LzmaDecode(&state, 1.444 + inStream, compressedSize, &inProcessed, 1.445 + outStream, outSize, &outProcessed); 1.446 + 1.447 + 1.448 +5.2 Single-call Decompressing with input stream callback 1.449 +-------------------------------------------------------- 1.450 +When to use: File->RAM or Flash->RAM decompressing. 1.451 +Compile files: LzmaDecode.h, LzmaDecode.c 1.452 +Compile defines: _LZMA_IN_CB 1.453 +Memory Requirements: 1.454 + - Buffer for input stream: any size (for example, 16 KB) 1.455 + - Output buffer: uncompressed size 1.456 + - LZMA Internal Structures (~16 KB for default settings) 1.457 + 1.458 +Interface: 1.459 + typedef struct _CBuffer 1.460 + { 1.461 + ILzmaInCallback InCallback; 1.462 + FILE *File; 1.463 + unsigned char Buffer[kInBufferSize]; 1.464 + } CBuffer; 1.465 + 1.466 + int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size) 1.467 + { 1.468 + CBuffer *bo = (CBuffer *)object; 1.469 + *buffer = bo->Buffer; 1.470 + *size = MyReadFile(bo->File, bo->Buffer, kInBufferSize); 1.471 + return LZMA_RESULT_OK; 1.472 + } 1.473 + 1.474 + CBuffer g_InBuffer; 1.475 + 1.476 + g_InBuffer.File = inFile; 1.477 + g_InBuffer.InCallback.Read = LzmaReadCompressed; 1.478 + int res = LzmaDecode(&state, 1.479 + &g_InBuffer.InCallback, 1.480 + outStream, outSize, &outProcessed); 1.481 + 1.482 + 1.483 +5.3 Multi-call decompressing with output buffer 1.484 +----------------------------------------------- 1.485 +When to use: RAM->File decompressing 1.486 +Compile files: LzmaDecode.h, LzmaDecode.c 1.487 +Compile defines: _LZMA_OUT_READ 1.488 +Memory Requirements: 1.489 + - Input buffer: compressed size 1.490 + - Buffer for output stream: any size (for example, 16 KB) 1.491 + - LZMA Internal Structures (~16 KB for default settings) 1.492 + - LZMA dictionary (dictionary size is encoded in stream properties) 1.493 + 1.494 +Interface: 1.495 + 1.496 + state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize); 1.497 + 1.498 + LzmaDecoderInit(&state); 1.499 + do 1.500 + { 1.501 + LzmaDecode(&state, 1.502 + inBuffer, inAvail, &inProcessed, 1.503 + g_OutBuffer, outAvail, &outProcessed); 1.504 + inAvail -= inProcessed; 1.505 + inBuffer += inProcessed; 1.506 + } 1.507 + while you need more bytes 1.508 + 1.509 + see LzmaTest.c for more details. 1.510 + 1.511 + 1.512 +5.4 Multi-call decompressing with input callback and output buffer 1.513 +------------------------------------------------------------------ 1.514 +When to use: File->File decompressing 1.515 +Compile files: LzmaDecode.h, LzmaDecode.c 1.516 +Compile defines: _LZMA_IN_CB, _LZMA_OUT_READ 1.517 +Memory Requirements: 1.518 + - Buffer for input stream: any size (for example, 16 KB) 1.519 + - Buffer for output stream: any size (for example, 16 KB) 1.520 + - LZMA Internal Structures (~16 KB for default settings) 1.521 + - LZMA dictionary (dictionary size is encoded in stream properties) 1.522 + 1.523 +Interface: 1.524 + 1.525 + state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize); 1.526 + 1.527 + LzmaDecoderInit(&state); 1.528 + do 1.529 + { 1.530 + LzmaDecode(&state, 1.531 + &bo.InCallback, 1.532 + g_OutBuffer, outAvail, &outProcessed); 1.533 + } 1.534 + while you need more bytes 1.535 + 1.536 + see LzmaTest.c for more details: 1.537 + 1.538 + 1.539 +5.5 Multi-call State Decompressing (zlib-like interface) 1.540 +------------------------------------------------------------------ 1.541 +When to use: file->file decompressing 1.542 +Compile files: LzmaStateDecode.h, LzmaStateDecode.c 1.543 +Compile defines: 1.544 +Memory Requirements: 1.545 + - Buffer for input stream: any size (for example, 16 KB) 1.546 + - Buffer for output stream: any size (for example, 16 KB) 1.547 + - LZMA Internal Structures (~16 KB for default settings) 1.548 + - LZMA dictionary (dictionary size is encoded in stream properties) 1.549 + 1.550 +Interface: 1.551 + 1.552 + state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize); 1.553 + 1.554 + 1.555 + LzmaDecoderInit(&state); 1.556 + do 1.557 + { 1.558 + res = LzmaDecode(&state, 1.559 + inBuffer, inAvail, &inProcessed, 1.560 + g_OutBuffer, outAvail, &outProcessed, 1.561 + finishDecoding); 1.562 + inAvail -= inProcessed; 1.563 + inBuffer += inProcessed; 1.564 + } 1.565 + while you need more bytes 1.566 + 1.567 + see LzmaStateTest.c for more details: 1.568 + 1.569 + 1.570 +6) Free all allocated blocks 1.571 + 1.572 + 1.573 +Note 1.574 +---- 1.575 +LzmaDecodeSize.c is size-optimized version of LzmaDecode.c. 1.576 +But compiled code of LzmaDecodeSize.c can be larger than 1.577 +compiled code of LzmaDecode.c. So it's better to use 1.578 +LzmaDecode.c in most cases. 1.579 + 1.580 + 1.581 +EXIT codes 1.582 +----------- 1.583 + 1.584 +LZMA decoder can return one of the following codes: 1.585 + 1.586 +#define LZMA_RESULT_OK 0 1.587 +#define LZMA_RESULT_DATA_ERROR 1 1.588 + 1.589 +If you use callback function for input data and you return some 1.590 +error code, LZMA Decoder also returns that code. 1.591 + 1.592 + 1.593 + 1.594 +LZMA Defines 1.595 +------------ 1.596 + 1.597 +_LZMA_IN_CB - Use callback for input data 1.598 + 1.599 +_LZMA_OUT_READ - Use read function for output data 1.600 + 1.601 +_LZMA_LOC_OPT - Enable local speed optimizations inside code. 1.602 + _LZMA_LOC_OPT is only for LzmaDecodeSize.c (size-optimized version). 1.603 + _LZMA_LOC_OPT doesn't affect LzmaDecode.c (speed-optimized version) 1.604 + and LzmaStateDecode.c 1.605 + 1.606 +_LZMA_PROB32 - It can increase speed on some 32-bit CPUs, 1.607 + but memory usage will be doubled in that case 1.608 + 1.609 +_LZMA_UINT32_IS_ULONG - Define it if int is 16-bit on your compiler 1.610 + and long is 32-bit. 1.611 + 1.612 +_LZMA_SYSTEM_SIZE_T - Define it if you want to use system's size_t. 1.613 + You can use it to enable 64-bit sizes supporting 1.614 + 1.615 + 1.616 + 1.617 +C++ LZMA Encoder/Decoder 1.618 +~~~~~~~~~~~~~~~~~~~~~~~~ 1.619 +C++ LZMA code use COM-like interfaces. So if you want to use it, 1.620 +you can study basics of COM/OLE. 1.621 + 1.622 +By default, LZMA Encoder contains all Match Finders. 1.623 +But for compressing it's enough to have just one of them. 1.624 +So for reducing size of compressing code you can define: 1.625 + #define COMPRESS_MF_BT 1.626 + #define COMPRESS_MF_BT4 1.627 +and it will use only bt4 match finder. 1.628 + 1.629 + 1.630 +--- 1.631 + 1.632 +http://www.7-zip.org 1.633 +http://www.7-zip.org/support.html