]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-sdk.txt
MdeModulePkg LzmaDecompressLib: Update LZMA to new 16.04 version
[mirror_edk2.git] / MdeModulePkg / Library / LzmaCustomDecompressLib / Sdk / DOC / lzma-sdk.txt
diff --git a/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-sdk.txt b/MdeModulePkg/Library/LzmaCustomDecompressLib/Sdk/DOC/lzma-sdk.txt
new file mode 100644 (file)
index 0000000..86fef24
--- /dev/null
@@ -0,0 +1,357 @@
+LZMA SDK 16.04\r
+--------------\r
+\r
+LZMA SDK provides the documentation, samples, header files,\r
+libraries, and tools you need to develop applications that \r
+use 7z / LZMA / LZMA2 / XZ compression.\r
+\r
+LZMA is an improved version of famous LZ77 compression algorithm. \r
+It was improved in way of maximum increasing of compression ratio,\r
+keeping high decompression speed and low memory requirements for \r
+decompressing.\r
+\r
+LZMA2 is a LZMA based compression method. LZMA2 provides better \r
+multithreading support for compression than LZMA and some other improvements.\r
+\r
+7z is a file format for data compression and file archiving.\r
+7z is a main file format for 7-Zip compression program (www.7-zip.org).\r
+7z format supports different compression methods: LZMA, LZMA2 and others.\r
+7z also supports AES-256 based encryption.\r
+\r
+XZ is a file format for data compression that uses LZMA2 compression.\r
+XZ format provides additional features: SHA/CRC check, filters for \r
+improved compression ratio, splitting to blocks and streams,\r
+\r
+\r
+\r
+LICENSE\r
+-------\r
+\r
+LZMA SDK is written and placed in the public domain by Igor Pavlov.\r
+\r
+Some code in LZMA SDK is based on public domain code from another developers:\r
+  1) PPMd var.H (2001): Dmitry Shkarin\r
+  2) SHA-256: Wei Dai (Crypto++ library)\r
+\r
+Anyone is free to copy, modify, publish, use, compile, sell, or distribute the \r
+original LZMA SDK code, either in source code form or as a compiled binary, for \r
+any purpose, commercial or non-commercial, and by any means.\r
+\r
+LZMA SDK code is compatible with open source licenses, for example, you can \r
+include it to GNU GPL or GNU LGPL code.\r
+\r
+\r
+LZMA SDK Contents\r
+-----------------\r
+\r
+  Source code:\r
+\r
+    - C / C++ / C# / Java   - LZMA compression and decompression\r
+    - C / C++               - LZMA2 compression and decompression\r
+    - C / C++               - XZ compression and decompression\r
+    - C                     - 7z decompression\r
+    -     C++               - 7z compression and decompression\r
+    - C                     - small SFXs for installers (7z decompression)\r
+    -     C++               - SFXs and SFXs for installers (7z decompression)\r
+\r
+  Precomiled binaries:\r
+\r
+    - console programs for lzma / 7z / xz compression and decompression\r
+    - SFX modules for installers.\r
+\r
+\r
+UNIX/Linux version \r
+------------------\r
+To compile C++ version of file->file LZMA encoding, go to directory\r
+CPP/7zip/Bundles/LzmaCon\r
+and call make to recompile it:\r
+  make -f makefile.gcc clean all\r
+\r
+In some UNIX/Linux versions you must compile LZMA with static libraries.\r
+To compile with static libraries, you can use \r
+LIB = -lm -static\r
+\r
+Also you can use p7zip (port of 7-Zip for POSIX systems like Unix or Linux):\r
+  \r
+  http://p7zip.sourceforge.net/\r
+\r
+\r
+Files\r
+-----\r
+\r
+DOC/7zC.txt          - 7z ANSI-C Decoder description\r
+DOC/7zFormat.txt     - 7z Format description\r
+DOC/installer.txt    - information about 7-Zip for installers\r
+DOC/lzma.txt         - LZMA compression description\r
+DOC/lzma-sdk.txt     - LZMA SDK description (this file)\r
+DOC/lzma-history.txt - history of LZMA SDK\r
+DOC/lzma-specification.txt - Specification of LZMA\r
+DOC/Methods.txt      - Compression method IDs for .7z\r
+\r
+bin/installer/   - example script to create installer that uses SFX module,\r
+\r
+bin/7zdec.exe    - simplified 7z archive decoder\r
+bin/7zr.exe      - 7-Zip console program (reduced version)\r
+bin/x64/7zr.exe  - 7-Zip console program (reduced version) (x64 version)\r
+bin/lzma.exe     - file->file LZMA encoder/decoder for Windows\r
+bin/7zS2.sfx     - small SFX module for installers (GUI version)\r
+bin/7zS2con.sfx  - small SFX module for installers (Console version)\r
+bin/7zSD.sfx     - SFX module for installers.\r
+\r
+\r
+7zDec.exe\r
+---------\r
+7zDec.exe is simplified 7z archive decoder.\r
+It supports only LZMA, LZMA2, and PPMd methods.\r
+7zDec decodes whole solid block from 7z archive to RAM.\r
+The RAM consumption can be high.\r
+\r
+\r
+\r
+\r
+Source code structure\r
+---------------------\r
+\r
+\r
+Asm/ - asm files (optimized code for CRC calculation and Intel-AES encryption)\r
+\r
+C/  - C files (compression / decompression and other)\r
+  Util/\r
+    7z       - 7z decoder program (decoding 7z files)\r
+    Lzma     - LZMA program (file->file LZMA encoder/decoder).\r
+    LzmaLib  - LZMA library (.DLL for Windows)\r
+    SfxSetup - small SFX module for installers \r
+\r
+CPP/ -- CPP files\r
+\r
+  Common  - common files for C++ projects\r
+  Windows - common files for Windows related code\r
+\r
+  7zip    - files related to 7-Zip\r
+\r
+    Archive - files related to archiving\r
+\r
+      Common   - common files for archive handling\r
+      7z       - 7z C++ Encoder/Decoder\r
+\r
+    Bundles  - Modules that are bundles of other modules (files)\r
+  \r
+      Alone7z       - 7zr.exe: Standalone 7-Zip console program (reduced version)\r
+      Format7zExtractR  - 7zxr.dll: Reduced version of 7z DLL: extracting from 7z/LZMA/BCJ/BCJ2.\r
+      Format7zR         - 7zr.dll:  Reduced version of 7z DLL: extracting/compressing to 7z/LZMA/BCJ/BCJ2\r
+      LzmaCon       - lzma.exe: LZMA compression/decompression\r
+      LzmaSpec      - example code for LZMA Specification\r
+      SFXCon        - 7zCon.sfx: Console 7z SFX module\r
+      SFXSetup      - 7zS.sfx: 7z SFX module for installers\r
+      SFXWin        - 7z.sfx: GUI 7z SFX module\r
+\r
+    Common   - common files for 7-Zip\r
+\r
+    Compress - files for compression/decompression\r
+\r
+    Crypto   - files for encryption / decompression\r
+\r
+    UI       - User Interface files\r
+         \r
+      Client7z - Test application for 7za.dll, 7zr.dll, 7zxr.dll\r
+      Common   - Common UI files\r
+      Console  - Code for console program (7z.exe)\r
+      Explorer    - Some code from 7-Zip Shell extension\r
+      FileManager - Some GUI code from 7-Zip File Manager\r
+      GUI         - Some GUI code from 7-Zip\r
+\r
+\r
+CS/ - C# files\r
+  7zip\r
+    Common   - some common files for 7-Zip\r
+    Compress - files related to compression/decompression\r
+      LZ     - files related to LZ (Lempel-Ziv) compression algorithm\r
+      LZMA         - LZMA compression/decompression\r
+      LzmaAlone    - file->file LZMA compression/decompression\r
+      RangeCoder   - Range Coder (special code of compression/decompression)\r
+\r
+Java/  - Java files\r
+  SevenZip\r
+    Compression    - files related to compression/decompression\r
+      LZ           - files related to LZ (Lempel-Ziv) compression algorithm\r
+      LZMA         - LZMA compression/decompression\r
+      RangeCoder   - Range Coder (special code of compression/decompression)\r
+\r
+\r
+Note: \r
+  Asm / C / C++ source code of LZMA SDK is part of 7-Zip's source code.\r
+  7-Zip's source code can be downloaded from 7-Zip's SourceForge page:\r
+\r
+  http://sourceforge.net/projects/sevenzip/\r
+\r
+\r
+\r
+LZMA features\r
+-------------\r
+  - Variable dictionary size (up to 1 GB)\r
+  - Estimated compressing speed: about 2 MB/s on 2 GHz CPU\r
+  - Estimated decompressing speed: \r
+      - 20-30 MB/s on modern 2 GHz cpu\r
+      - 1-2 MB/s on 200 MHz simple RISC cpu: (ARM, MIPS, PowerPC)\r
+  - Small memory requirements for decompressing (16 KB + DictionarySize)\r
+  - Small code size for decompressing: 5-8 KB\r
+\r
+LZMA decoder uses only integer operations and can be \r
+implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).\r
+\r
+Some critical operations that affect the speed of LZMA decompression:\r
+  1) 32*16 bit integer multiply\r
+  2) Mispredicted branches (penalty mostly depends from pipeline length)\r
+  3) 32-bit shift and arithmetic operations\r
+\r
+The speed of LZMA decompressing mostly depends from CPU speed.\r
+Memory speed has no big meaning. But if your CPU has small data cache, \r
+overall weight of memory speed will slightly increase.\r
+\r
+\r
+How To Use\r
+----------\r
+\r
+Using LZMA encoder/decoder executable\r
+--------------------------------------\r
+\r
+Usage:  LZMA <e|d> inputFile outputFile [<switches>...]\r
+\r
+  e: encode file\r
+\r
+  d: decode file\r
+\r
+  b: Benchmark. There are two tests: compressing and decompressing \r
+     with LZMA method. Benchmark shows rating in MIPS (million \r
+     instructions per second). Rating value is calculated from \r
+     measured speed and it is normalized with Intel's Core 2 results.\r
+     Also Benchmark checks possible hardware errors (RAM \r
+     errors in most cases). Benchmark uses these settings:\r
+     (-a1, -d21, -fb32, -mfbt4). You can change only -d parameter. \r
+     Also you can change the number of iterations. Example for 30 iterations:\r
+       LZMA b 30\r
+     Default number of iterations is 10.\r
+\r
+<Switches>\r
+  \r
+\r
+  -a{N}:  set compression mode 0 = fast, 1 = normal\r
+          default: 1 (normal)\r
+\r
+  d{N}:   Sets Dictionary size - [0, 30], default: 23 (8MB)\r
+          The maximum value for dictionary size is 1 GB = 2^30 bytes.\r
+          Dictionary size is calculated as DictionarySize = 2^N bytes. \r
+          For decompressing file compressed by LZMA method with dictionary \r
+          size D = 2^N you need about D bytes of memory (RAM).\r
+\r
+  -fb{N}: set number of fast bytes - [5, 273], default: 128\r
+          Usually big number gives a little bit better compression ratio \r
+          and slower compression process.\r
+\r
+  -lc{N}: set number of literal context bits - [0, 8], default: 3\r
+          Sometimes lc=4 gives gain for big files.\r
+\r
+  -lp{N}: set number of literal pos bits - [0, 4], default: 0\r
+          lp switch is intended for periodical data when period is \r
+          equal 2^N. For example, for 32-bit (4 bytes) \r
+          periodical data you can use lp=2. Often it's better to set lc0, \r
+          if you change lp switch.\r
+\r
+  -pb{N}: set number of pos bits - [0, 4], default: 2\r
+          pb switch is intended for periodical data \r
+          when period is equal 2^N.\r
+\r
+  -mf{MF_ID}: set Match Finder. Default: bt4. \r
+              Algorithms from hc* group doesn't provide good compression \r
+              ratio, but they often works pretty fast in combination with \r
+              fast mode (-a0).\r
+\r
+              Memory requirements depend from dictionary size \r
+              (parameter "d" in table below). \r
+\r
+               MF_ID     Memory                   Description\r
+\r
+                bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.\r
+                bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.\r
+                bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.\r
+                hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.\r
+\r
+  -eos:   write End Of Stream marker. By default LZMA doesn't write \r
+          eos marker, since LZMA decoder knows uncompressed size \r
+          stored in .lzma file header.\r
+\r
+  -si:    Read data from stdin (it will write End Of Stream marker).\r
+  -so:    Write data to stdout\r
+\r
+\r
+Examples:\r
+\r
+1) LZMA e file.bin file.lzma -d16 -lc0 \r
+\r
+compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)  \r
+and 0 literal context bits. -lc0 allows to reduce memory requirements \r
+for decompression.\r
+\r
+\r
+2) LZMA e file.bin file.lzma -lc0 -lp2\r
+\r
+compresses file.bin to file.lzma with settings suitable \r
+for 32-bit periodical data (for example, ARM or MIPS code).\r
+\r
+3) LZMA d file.lzma file.bin\r
+\r
+decompresses file.lzma to file.bin.\r
+\r
+\r
+Compression ratio hints\r
+-----------------------\r
+\r
+Recommendations\r
+---------------\r
+\r
+To increase the compression ratio for LZMA compressing it's desirable \r
+to have aligned data (if it's possible) and also it's desirable to locate\r
+data in such order, where code is grouped in one place and data is \r
+grouped in other place (it's better than such mixing: code, data, code,\r
+data, ...).\r
+\r
+\r
+Filters\r
+-------\r
+You can increase the compression ratio for some data types, using\r
+special filters before compressing. For example, it's possible to \r
+increase the compression ratio on 5-10% for code for those CPU ISAs: \r
+x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.\r
+\r
+You can find C source code of such filters in C/Bra*.* files\r
+\r
+You can check the compression ratio gain of these filters with such \r
+7-Zip commands (example for ARM code):\r
+No filter:\r
+  7z a a1.7z a.bin -m0=lzma\r
+\r
+With filter for little-endian ARM code:\r
+  7z a a2.7z a.bin -m0=arm -m1=lzma        \r
+\r
+It works in such manner:\r
+Compressing    = Filter_encoding + LZMA_encoding\r
+Decompressing  = LZMA_decoding + Filter_decoding\r
+\r
+Compressing and decompressing speed of such filters is very high,\r
+so it will not increase decompressing time too much.\r
+Moreover, it reduces decompression time for LZMA_decoding, \r
+since compression ratio with filtering is higher.\r
+\r
+These filters convert CALL (calling procedure) instructions \r
+from relative offsets to absolute addresses, so such data becomes more \r
+compressible.\r
+\r
+For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.\r
+\r
+\r
+\r
+---\r
+\r
+http://www.7-zip.org\r
+http://www.7-zip.org/sdk.html\r
+http://www.7-zip.org/support.html\r