src/lzma/lzma.txt
author Ryan C. Gordon <icculus@icculus.org>
Thu, 25 Feb 2016 01:16:42 -0500
changeset 1371 da48b9ff4c9b
parent 972 254427fc42ab
permissions -rw-r--r--
Fixed a comment.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
917
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     1
LZMA SDK 4.57
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     2
-------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     3
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     4
LZMA SDK   Copyright (C) 1999-2007 Igor Pavlov
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     5
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     6
LZMA SDK provides the documentation, samples, header files, libraries, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     7
and tools you need to develop applications that use LZMA compression.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     8
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
     9
LZMA is default and general compression method of 7z format
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    10
in 7-Zip compression program (www.7-zip.org). LZMA provides high 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    11
compression ratio and very fast decompression.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    12
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    13
LZMA is an improved version of famous LZ77 compression algorithm. 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    14
It was improved in way of maximum increasing of compression ratio,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    15
keeping high decompression speed and low memory requirements for 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    16
decompressing.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    17
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    18
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    19
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    20
LICENSE
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    21
-------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    22
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    23
LZMA SDK is available under any of the following licenses:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    24
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    25
1) GNU Lesser General Public License (GNU LGPL)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    26
2) Common Public License (CPL)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    27
3) Simplified license for unmodified code (read SPECIAL EXCEPTION) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    28
4) Proprietary license 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    29
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    30
It means that you can select one of these four options and follow rules of that license.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    31
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    32
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    33
1,2) GNU LGPL and CPL licenses are pretty similar and both these
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    34
licenses are classified as 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    35
 - "Free software licenses" at http://www.gnu.org/ 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    36
 - "OSI-approved" at http://www.opensource.org/
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    37
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    38
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    39
3) SPECIAL EXCEPTION
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    40
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    41
Igor Pavlov, as the author of this code, expressly permits you 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    42
to statically or dynamically link your code (or bind by name) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    43
to the files from LZMA SDK without subjecting your linked 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    44
code to the terms of the CPL or GNU LGPL. 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    45
Any modifications or additions to files from LZMA SDK, however, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    46
are subject to the GNU LGPL or CPL terms.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    47
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    48
SPECIAL EXCEPTION allows you to use LZMA SDK in applications with closed code, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    49
while you keep LZMA SDK code unmodified.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    50
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    51
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    52
SPECIAL EXCEPTION #2: Igor Pavlov, as the author of this code, expressly permits 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    53
you to use this code under the same terms and conditions contained in the License 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    54
Agreement you have for any previous version of LZMA SDK developed by Igor Pavlov.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    55
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    56
SPECIAL EXCEPTION #2 allows owners of proprietary licenses to use latest version 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    57
of LZMA SDK as update for previous versions.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    58
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    59
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    60
SPECIAL EXCEPTION #3: Igor Pavlov, as the author of this code, expressly permits 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    61
you to use code of the following files: 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    62
BranchTypes.h, LzmaTypes.h, LzmaTest.c, LzmaStateTest.c, LzmaAlone.cpp, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    63
LzmaAlone.cs, LzmaAlone.java
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    64
as public domain code. 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    65
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    66
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    67
4) Proprietary license
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    68
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    69
LZMA SDK also can be available under a proprietary license which 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    70
can include:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    71
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    72
1) Right to modify code without subjecting modified code to the 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    73
terms of the CPL or GNU LGPL
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    74
2) Technical support for code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    75
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    76
To request such proprietary license or any additional consultations,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    77
send email message from that page:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    78
http://www.7-zip.org/support.html
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    79
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    80
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    81
You should have received a copy of the GNU Lesser General Public
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    82
License along with this library; if not, write to the Free Software
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    83
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    84
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    85
You should have received a copy of the Common Public License
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    86
along with this library.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    87
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    88
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    89
LZMA SDK Contents
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    90
-----------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    91
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    92
LZMA SDK includes:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    93
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    94
  - C++ source code of LZMA compressing and decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    95
  - ANSI-C compatible source code for LZMA decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    96
  - C# source code for LZMA compressing and decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    97
  - Java source code for LZMA compressing and decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    98
  - Compiled file->file LZMA compressing/decompressing program for Windows system
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
    99
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   100
ANSI-C LZMA decompression code was ported from original C++ sources to C.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   101
Also it was simplified and optimized for code size. 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   102
But it is fully compatible with LZMA from 7-Zip.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   103
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   104
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   105
UNIX/Linux version 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   106
------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   107
To compile C++ version of file->file LZMA, go to directory
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   108
C/7zip/Compress/LZMA_Alone 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   109
and type "make" or "make clean all" to recompile all.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   110
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   111
In some UNIX/Linux versions you must compile LZMA with static libraries.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   112
To compile with static libraries, change string in makefile
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   113
LIB = -lm
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   114
to string  
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   115
LIB = -lm -static
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   116
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   117
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   118
Files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   119
---------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   120
C        - C source code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   121
CPP      - CPP source code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   122
CS       - C# source code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   123
Java     - Java source code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   124
lzma.txt - LZMA SDK description (this file)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   125
7zFormat.txt - 7z Format description
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   126
7zC.txt  - 7z ANSI-C Decoder description (this file)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   127
methods.txt  - Compression method IDs for .7z
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   128
LGPL.txt - GNU Lesser General Public License
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   129
CPL.html - Common Public License
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   130
lzma.exe - Compiled file->file LZMA encoder/decoder for Windows
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   131
history.txt - history of the LZMA SDK
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   132
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   133
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   134
Source code structure
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   135
---------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   136
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   137
C  - C files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   138
    Compress - files related to compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   139
      Lz     - files related to LZ (Lempel-Ziv) compression algorithm
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   140
      Lzma   - ANSI-C compatible LZMA decompressor
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   141
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   142
        LzmaDecode.h  - interface for LZMA decoding on ANSI-C
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   143
        LzmaDecode.c      - LZMA decoding on ANSI-C (new fastest version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   144
        LzmaDecodeSize.c  - LZMA decoding on ANSI-C (old size-optimized version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   145
        LzmaTest.c        - test application that decodes LZMA encoded file
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   146
        LzmaTypes.h       - basic types for LZMA Decoder
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   147
        LzmaStateDecode.h - interface for LZMA decoding (State version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   148
        LzmaStateDecode.c - LZMA decoding on ANSI-C (State version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   149
        LzmaStateTest.c   - test application (State version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   150
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   151
      Branch       - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   152
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   153
    Archive - files related to archiving
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   154
      7z_C     - 7z ANSI-C Decoder
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   155
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   156
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   157
CPP -- CPP files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   158
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   159
  Common  - common files for C++ projects
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   160
  Windows - common files for Windows related code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   161
  7zip    - files related to 7-Zip Project
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   162
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   163
    Common   - common files for 7-Zip
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   164
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   165
    Compress - files related to compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   166
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   167
      LZ     - files related to LZ (Lempel-Ziv) compression algorithm
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   168
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   169
      Copy         - Copy coder
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   170
      RangeCoder   - Range Coder (special code of compression/decompression)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   171
      LZMA         - LZMA compression/decompression on C++
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   172
      LZMA_Alone   - file->file LZMA compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   173
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   174
      Branch       - Filters for x86, IA-64, ARM, ARM-Thumb, PowerPC and SPARC code
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   175
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   176
    Archive - files related to archiving
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   177
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   178
      Common   - common files for archive handling
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   179
      7z       - 7z C++ Encoder/Decoder
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   180
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   181
    Bundles    - Modules that are bundles of other modules
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   182
  
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   183
      Alone7z           - 7zr.exe: Standalone version of 7z.exe that supports only 7z/LZMA/BCJ/BCJ2
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   184
      Format7zR         - 7zr.dll: Reduced version of 7za.dll: extracting/compressing to 7z/LZMA/BCJ/BCJ2
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   185
      Format7zExtractR  - 7zxr.dll: Reduced version of 7zxa.dll: extracting from 7z/LZMA/BCJ/BCJ2.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   186
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   187
    UI        - User Interface files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   188
         
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   189
      Client7z - Test application for 7za.dll,  7zr.dll, 7zxr.dll
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   190
      Common   - Common UI files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   191
      Console  - Code for console archiver
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   192
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   193
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   194
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   195
CS - C# files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   196
  7zip
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   197
    Common   - some common files for 7-Zip
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   198
    Compress - files related to compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   199
      LZ     - files related to LZ (Lempel-Ziv) compression algorithm
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   200
      LZMA         - LZMA compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   201
      LzmaAlone    - file->file LZMA compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   202
      RangeCoder   - Range Coder (special code of compression/decompression)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   203
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   204
Java  - Java files
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   205
  SevenZip
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   206
    Compression    - files related to compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   207
      LZ           - files related to LZ (Lempel-Ziv) compression algorithm
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   208
      LZMA         - LZMA compression/decompression
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   209
      RangeCoder   - Range Coder (special code of compression/decompression)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   210
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   211
C/C++ source code of LZMA SDK is part of 7-Zip project.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   212
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   213
You can find ANSI-C LZMA decompressing code at folder 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   214
  C/7zip/Compress/Lzma
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   215
7-Zip doesn't use that ANSI-C LZMA code and that code was developed 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   216
specially for this SDK. And files from C/7zip/Compress/Lzma do not need 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   217
files from other directories of SDK for compiling.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   218
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   219
7-Zip source code can be downloaded from 7-Zip's SourceForge page:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   220
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   221
  http://sourceforge.net/projects/sevenzip/
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   222
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   223
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   224
LZMA features
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   225
-------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   226
  - Variable dictionary size (up to 1 GB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   227
  - Estimated compressing speed: about 1 MB/s on 1 GHz CPU
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   228
  - Estimated decompressing speed: 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   229
      - 8-12 MB/s on 1 GHz Intel Pentium 3 or AMD Athlon
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   230
      - 500-1000 KB/s on 100 MHz ARM, MIPS, PowerPC or other simple RISC
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   231
  - Small memory requirements for decompressing (8-32 KB + DictionarySize)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   232
  - Small code size for decompressing: 2-8 KB (depending from 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   233
    speed optimizations) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   234
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   235
LZMA decoder uses only integer operations and can be 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   236
implemented in any modern 32-bit CPU (or on 16-bit CPU with some conditions).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   237
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   238
Some critical operations that affect to speed of LZMA decompression:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   239
  1) 32*16 bit integer multiply
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   240
  2) Misspredicted branches (penalty mostly depends from pipeline length)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   241
  3) 32-bit shift and arithmetic operations
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   242
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   243
Speed of LZMA decompressing mostly depends from CPU speed.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   244
Memory speed has no big meaning. But if your CPU has small data cache, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   245
overall weight of memory speed will slightly increase.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   246
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   247
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   248
How To Use
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   249
----------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   250
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   251
Using LZMA encoder/decoder executable
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   252
--------------------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   253
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   254
Usage:  LZMA <e|d> inputFile outputFile [<switches>...]
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   255
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   256
  e: encode file
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   257
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   258
  d: decode file
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   259
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   260
  b: Benchmark. There are two tests: compressing and decompressing 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   261
     with LZMA method. Benchmark shows rating in MIPS (million 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   262
     instructions per second). Rating value is calculated from 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   263
     measured speed and it is normalized with AMD Athlon 64 X2 CPU
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   264
     results. Also Benchmark checks possible hardware errors (RAM 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   265
     errors in most cases). Benchmark uses these settings:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   266
     (-a1, -d21, -fb32, -mfbt4). You can change only -d. Also you 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   267
     can change number of iterations. Example for 30 iterations:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   268
       LZMA b 30
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   269
     Default number of iterations is 10.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   270
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   271
<Switches>
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   272
  
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   273
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   274
  -a{N}:  set compression mode 0 = fast, 1 = normal
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   275
          default: 1 (normal)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   276
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   277
  d{N}:   Sets Dictionary size - [0, 30], default: 23 (8MB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   278
          The maximum value for dictionary size is 1 GB = 2^30 bytes.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   279
          Dictionary size is calculated as DictionarySize = 2^N bytes. 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   280
          For decompressing file compressed by LZMA method with dictionary 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   281
          size D = 2^N you need about D bytes of memory (RAM).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   282
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   283
  -fb{N}: set number of fast bytes - [5, 273], default: 128
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   284
          Usually big number gives a little bit better compression ratio 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   285
          and slower compression process.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   286
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   287
  -lc{N}: set number of literal context bits - [0, 8], default: 3
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   288
          Sometimes lc=4 gives gain for big files.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   289
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   290
  -lp{N}: set number of literal pos bits - [0, 4], default: 0
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   291
          lp switch is intended for periodical data when period is 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   292
          equal 2^N. For example, for 32-bit (4 bytes) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   293
          periodical data you can use lp=2. Often it's better to set lc0, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   294
          if you change lp switch.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   295
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   296
  -pb{N}: set number of pos bits - [0, 4], default: 2
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   297
          pb switch is intended for periodical data 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   298
          when period is equal 2^N.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   299
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   300
  -mf{MF_ID}: set Match Finder. Default: bt4. 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   301
              Algorithms from hc* group doesn't provide good compression 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   302
              ratio, but they often works pretty fast in combination with 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   303
              fast mode (-a0).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   304
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   305
              Memory requirements depend from dictionary size 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   306
              (parameter "d" in table below). 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   307
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   308
               MF_ID     Memory                   Description
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   309
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   310
                bt2    d *  9.5 + 4MB  Binary Tree with 2 bytes hashing.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   311
                bt3    d * 11.5 + 4MB  Binary Tree with 3 bytes hashing.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   312
                bt4    d * 11.5 + 4MB  Binary Tree with 4 bytes hashing.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   313
                hc4    d *  7.5 + 4MB  Hash Chain with 4 bytes hashing.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   314
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   315
  -eos:   write End Of Stream marker. By default LZMA doesn't write 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   316
          eos marker, since LZMA decoder knows uncompressed size 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   317
          stored in .lzma file header.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   318
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   319
  -si:    Read data from stdin (it will write End Of Stream marker).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   320
  -so:    Write data to stdout
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   321
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   322
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   323
Examples:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   324
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   325
1) LZMA e file.bin file.lzma -d16 -lc0 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   326
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   327
compresses file.bin to file.lzma with 64 KB dictionary (2^16=64K)  
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   328
and 0 literal context bits. -lc0 allows to reduce memory requirements 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   329
for decompression.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   330
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   331
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   332
2) LZMA e file.bin file.lzma -lc0 -lp2
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   333
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   334
compresses file.bin to file.lzma with settings suitable 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   335
for 32-bit periodical data (for example, ARM or MIPS code).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   336
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   337
3) LZMA d file.lzma file.bin
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   338
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   339
decompresses file.lzma to file.bin.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   340
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   341
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   342
Compression ratio hints
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   343
-----------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   344
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   345
Recommendations
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   346
---------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   347
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   348
To increase compression ratio for LZMA compressing it's desirable 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   349
to have aligned data (if it's possible) and also it's desirable to locate
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   350
data in such order, where code is grouped in one place and data is 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   351
grouped in other place (it's better than such mixing: code, data, code,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   352
data, ...).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   353
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   354
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   355
Using Filters
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   356
-------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   357
You can increase compression ratio for some data types, using
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   358
special filters before compressing. For example, it's possible to 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   359
increase compression ratio on 5-10% for code for those CPU ISAs: 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   360
x86, IA-64, ARM, ARM-Thumb, PowerPC, SPARC.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   361
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   362
You can find C/C++ source code of such filters in folder "7zip/Compress/Branch"
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   363
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   364
You can check compression ratio gain of these filters with such 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   365
7-Zip commands (example for ARM code):
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   366
No filter:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   367
  7z a a1.7z a.bin -m0=lzma
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   368
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   369
With filter for little-endian ARM code:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   370
  7z a a2.7z a.bin -m0=bc_arm -m1=lzma        
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   371
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   372
With filter for big-endian ARM code (using additional Swap4 filter):
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   373
  7z a a3.7z a.bin -m0=swap4 -m1=bc_arm -m2=lzma
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   374
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   375
It works in such manner:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   376
Compressing    = Filter_encoding + LZMA_encoding
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   377
Decompressing  = LZMA_decoding + Filter_decoding
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   378
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   379
Compressing and decompressing speed of such filters is very high,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   380
so it will not increase decompressing time too much.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   381
Moreover, it reduces decompression time for LZMA_decoding, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   382
since compression ratio with filtering is higher.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   383
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   384
These filters convert CALL (calling procedure) instructions 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   385
from relative offsets to absolute addresses, so such data becomes more 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   386
compressible. Source code of these CALL filters is pretty simple
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   387
(about 20 lines of C++), so you can convert it from C++ version yourself.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   388
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   389
For some ISAs (for example, for MIPS) it's impossible to get gain from such filter.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   390
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   391
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   392
LZMA compressed file format
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   393
---------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   394
Offset Size Description
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   395
  0     1   Special LZMA properties for compressed data
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   396
  1     4   Dictionary size (little endian)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   397
  5     8   Uncompressed size (little endian). -1 means unknown size
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   398
 13         Compressed data
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   399
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   400
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   401
ANSI-C LZMA Decoder
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   402
~~~~~~~~~~~~~~~~~~~
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   403
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   404
To compile ANSI-C LZMA Decoder you can use one of the following files sets:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   405
1) LzmaDecode.h + LzmaDecode.c + LzmaTest.c  (fastest version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   406
2) LzmaDecode.h + LzmaDecodeSize.c + LzmaTest.c  (old size-optimized version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   407
3) LzmaStateDecode.h + LzmaStateDecode.c + LzmaStateTest.c  (zlib-like interface)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   408
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   409
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   410
Memory requirements for LZMA decoding
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   411
-------------------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   412
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   413
LZMA decoder doesn't allocate memory itself, so you must 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   414
allocate memory and send it to LZMA.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   415
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   416
Stack usage of LZMA decoding function for local variables is not 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   417
larger than 200 bytes.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   418
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   419
How To decompress data
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   420
----------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   421
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   422
LZMA Decoder (ANSI-C version) now supports 5 interfaces:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   423
1) Single-call Decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   424
2) Single-call Decompressing with input stream callback
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   425
3) Multi-call Decompressing with output buffer
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   426
4) Multi-call Decompressing with input callback and output buffer
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   427
5) Multi-call State Decompressing (zlib-like interface)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   428
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   429
Variant-5 is similar to Variant-4, but Variant-5 doesn't use callback functions.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   430
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   431
Decompressing steps
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   432
-------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   433
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   434
1) read LZMA properties (5 bytes):
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   435
   unsigned char properties[LZMA_PROPERTIES_SIZE];
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   436
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   437
2) read uncompressed size (8 bytes, little-endian)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   438
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   439
3) Decode properties:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   440
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   441
  CLzmaDecoderState state;  /* it's 24-140 bytes structure, if int is 32-bit */
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   442
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   443
  if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   444
    return PrintError(rs, "Incorrect stream properties");
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   445
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   446
4) Allocate memory block for internal Structures:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   447
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   448
  state.Probs = (CProb *)malloc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   449
  if (state.Probs == 0)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   450
    return PrintError(rs, kCantAllocateMessage);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   451
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   452
  LZMA decoder uses array of CProb variables as internal structure.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   453
  By default, CProb is unsigned_short. But you can define _LZMA_PROB32 to make 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   454
  it unsigned_int. It can increase speed on some 32-bit CPUs, but memory 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   455
  usage will be doubled in that case.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   456
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   457
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   458
5) Main Decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   459
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   460
You must use one of the following interfaces:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   461
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   462
5.1 Single-call Decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   463
-----------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   464
When to use: RAM->RAM decompressing
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   465
Compile files: LzmaDecode.h, LzmaDecode.c
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   466
Compile defines: no defines
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   467
Memory Requirements:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   468
  - Input buffer: compressed size
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   469
  - Output buffer: uncompressed size
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   470
  - LZMA Internal Structures (~16 KB for default settings) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   471
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   472
Interface:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   473
  int res = LzmaDecode(&state, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   474
      inStream, compressedSize, &inProcessed,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   475
      outStream, outSize, &outProcessed);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   476
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   477
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   478
5.2 Single-call Decompressing with input stream callback
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   479
--------------------------------------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   480
When to use: File->RAM or Flash->RAM decompressing.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   481
Compile files: LzmaDecode.h, LzmaDecode.c
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   482
Compile defines: _LZMA_IN_CB
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   483
Memory Requirements:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   484
  - Buffer for input stream: any size (for example, 16 KB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   485
  - Output buffer: uncompressed size
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   486
  - LZMA Internal Structures (~16 KB for default settings) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   487
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   488
Interface:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   489
  typedef struct _CBuffer
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   490
  {
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   491
    ILzmaInCallback InCallback;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   492
    FILE *File;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   493
    unsigned char Buffer[kInBufferSize];
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   494
  } CBuffer;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   495
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   496
  int LzmaReadCompressed(void *object, const unsigned char **buffer, SizeT *size)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   497
  {
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   498
    CBuffer *bo = (CBuffer *)object;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   499
    *buffer = bo->Buffer;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   500
    *size = MyReadFile(bo->File, bo->Buffer, kInBufferSize);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   501
    return LZMA_RESULT_OK;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   502
  }
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   503
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   504
  CBuffer g_InBuffer;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   505
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   506
  g_InBuffer.File = inFile;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   507
  g_InBuffer.InCallback.Read = LzmaReadCompressed;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   508
  int res = LzmaDecode(&state, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   509
      &g_InBuffer.InCallback,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   510
      outStream, outSize, &outProcessed);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   511
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   512
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   513
5.3 Multi-call decompressing with output buffer
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   514
-----------------------------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   515
When to use: RAM->File decompressing 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   516
Compile files: LzmaDecode.h, LzmaDecode.c
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   517
Compile defines: _LZMA_OUT_READ
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   518
Memory Requirements:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   519
 - Input buffer: compressed size
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   520
 - Buffer for output stream: any size (for example, 16 KB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   521
 - LZMA Internal Structures (~16 KB for default settings) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   522
 - LZMA dictionary (dictionary size is encoded in stream properties)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   523
 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   524
Interface:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   525
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   526
  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   527
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   528
  LzmaDecoderInit(&state);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   529
  do
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   530
  {
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   531
    LzmaDecode(&state,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   532
      inBuffer, inAvail, &inProcessed,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   533
      g_OutBuffer, outAvail, &outProcessed);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   534
    inAvail -= inProcessed;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   535
    inBuffer += inProcessed;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   536
  }
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   537
  while you need more bytes
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   538
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   539
  see LzmaTest.c for more details.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   540
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   541
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   542
5.4 Multi-call decompressing with input callback and output buffer
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   543
------------------------------------------------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   544
When to use: File->File decompressing 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   545
Compile files: LzmaDecode.h, LzmaDecode.c
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   546
Compile defines: _LZMA_IN_CB, _LZMA_OUT_READ
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   547
Memory Requirements:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   548
 - Buffer for input stream: any size (for example, 16 KB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   549
 - Buffer for output stream: any size (for example, 16 KB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   550
 - LZMA Internal Structures (~16 KB for default settings) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   551
 - LZMA dictionary (dictionary size is encoded in stream properties)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   552
 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   553
Interface:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   554
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   555
  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   556
 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   557
  LzmaDecoderInit(&state);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   558
  do
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   559
  {
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   560
    LzmaDecode(&state,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   561
      &bo.InCallback,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   562
      g_OutBuffer, outAvail, &outProcessed);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   563
  }
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   564
  while you need more bytes
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   565
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   566
  see LzmaTest.c for more details:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   567
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   568
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   569
5.5 Multi-call State Decompressing (zlib-like interface)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   570
------------------------------------------------------------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   571
When to use: file->file decompressing 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   572
Compile files: LzmaStateDecode.h, LzmaStateDecode.c
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   573
Compile defines:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   574
Memory Requirements:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   575
 - Buffer for input stream: any size (for example, 16 KB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   576
 - Buffer for output stream: any size (for example, 16 KB)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   577
 - LZMA Internal Structures (~16 KB for default settings) 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   578
 - LZMA dictionary (dictionary size is encoded in stream properties)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   579
 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   580
Interface:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   581
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   582
  state.Dictionary = (unsigned char *)malloc(state.Properties.DictionarySize);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   583
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   584
  
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   585
  LzmaDecoderInit(&state);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   586
  do
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   587
  {
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   588
    res = LzmaDecode(&state,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   589
      inBuffer, inAvail, &inProcessed,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   590
      g_OutBuffer, outAvail, &outProcessed,
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   591
      finishDecoding);
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   592
    inAvail -= inProcessed;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   593
    inBuffer += inProcessed;
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   594
  }
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   595
  while you need more bytes
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   596
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   597
  see LzmaStateTest.c for more details:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   598
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   599
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   600
6) Free all allocated blocks
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   601
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   602
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   603
Note
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   604
----
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   605
LzmaDecodeSize.c is size-optimized version of LzmaDecode.c.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   606
But compiled code of LzmaDecodeSize.c can be larger than 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   607
compiled code of LzmaDecode.c. So it's better to use 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   608
LzmaDecode.c in most cases.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   609
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   610
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   611
EXIT codes
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   612
-----------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   613
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   614
LZMA decoder can return one of the following codes:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   615
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   616
#define LZMA_RESULT_OK 0
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   617
#define LZMA_RESULT_DATA_ERROR 1
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   618
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   619
If you use callback function for input data and you return some 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   620
error code, LZMA Decoder also returns that code.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   621
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   622
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   623
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   624
LZMA Defines
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   625
------------
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   626
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   627
_LZMA_IN_CB    - Use callback for input data
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   628
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   629
_LZMA_OUT_READ - Use read function for output data
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   630
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   631
_LZMA_LOC_OPT  - Enable local speed optimizations inside code.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   632
                 _LZMA_LOC_OPT is only for LzmaDecodeSize.c (size-optimized version).
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   633
                 _LZMA_LOC_OPT doesn't affect LzmaDecode.c (speed-optimized version)
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   634
                 and LzmaStateDecode.c
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   635
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   636
_LZMA_PROB32   - It can increase speed on some 32-bit CPUs, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   637
                 but memory usage will be doubled in that case
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   638
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   639
_LZMA_UINT32_IS_ULONG  - Define it if int is 16-bit on your compiler
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   640
                         and long is 32-bit.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   641
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   642
_LZMA_SYSTEM_SIZE_T  - Define it if you want to use system's size_t.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   643
                       You can use it to enable 64-bit sizes supporting
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   644
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   645
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   646
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   647
C++ LZMA Encoder/Decoder 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   648
~~~~~~~~~~~~~~~~~~~~~~~~
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   649
C++ LZMA code use COM-like interfaces. So if you want to use it, 
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   650
you can study basics of COM/OLE.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   651
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   652
By default, LZMA Encoder contains all Match Finders.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   653
But for compressing it's enough to have just one of them.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   654
So for reducing size of compressing code you can define:
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   655
  #define COMPRESS_MF_BT
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   656
  #define COMPRESS_MF_BT4
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   657
and it will use only bt4 match finder.
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   658
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   659
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   660
---
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   661
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   662
http://www.7-zip.org
d299a58a274f Upgraded lzma sdk to 4.57.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
   663
http://www.7-zip.org/support.html