While this allows setting the LZMA2 compression options in detail,
often you only need LZMA2Options() or
LZMA2Options(int).
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| public static final int | DICT_SIZE_DEFAULT
The default dictionary size is 8 MiB. |
| public static final int | DICT_SIZE_MAX
Maximum dictionary size for compression is 768 MiB. |
| public static final int | DICT_SIZE_MIN
Minimum dictionary size is 4 KiB. |
| private int | |
| private int | |
| public static final int | LC_DEFAULT
The default number of literal context bits is 3. |
| public static final int | LC_LP_MAX
Maximum value for lc + lp is 4. |
| private int | |
| public static final int | LP_DEFAULT
The default number of literal position bits is 0. |
| private int | |
| public static final int | MF_BT4
Match finder: Binary tree 2-3-4 |
| public static final int | MF_HC4
Match finder: Hash Chain 2-3-4 |
| private int | |
| public static final int | MODE_FAST
Compression mode: fast. |
| public static final int | MODE_NORMAL
Compression mode: normal. |
| public static final int | MODE_UNCOMPRESSED
Compression mode: uncompressed. |
| public static final int | NICE_LEN_MAX
Maximum value for |
| public static final int | NICE_LEN_MIN
Minimum value for |
| private int | |
| private int | |
| public static final int | PB_DEFAULT
The default number of position bits is 2. |
| public static final int | PB_MAX
Maximum value for pb is 4. |
| public static final int | PRESET_DEFAULT
Default compression preset level is 6. |
| public static final int | PRESET_MAX
Maximum valid compression preset level is 9. |
| public static final int | PRESET_MIN
Minimum valid compression preset level is 0. |
| private byte[] | |
| private static final int[] | |
| private static final int[] |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | LZMA2Options(int dictSize, int lc, int lp, int pb, int mode, int niceLen, int mf, int depthLimit)
Creates new LZMA2 options and sets them to the given custom values. |
| Modifier and Type | Method and Description |
|---|---|
| public Object | |
| public int | getDecoderMemoryUsage()
Implements abstract org. |
| public int | |
| public int | |
| public int | getEncoderMemoryUsage()
Implements abstract org. |
| pack-priv FilterEncoder | |
| public InputStream | getInputStream(InputStream in, ArrayCache arrayCache)
Implements abstract org. |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public FinishableOutputStream | getOutputStream(FinishableOutputStream out, ArrayCache arrayCache)
Implements abstract org. |
| public int | |
| public byte[] | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void |
| depthLimit | back to summary |
|---|---|
| private int depthLimit | |
| DICT_SIZE_DEFAULT | back to summary |
|---|---|
| public static final int DICT_SIZE_DEFAULT The default dictionary size is 8 MiB. | |
| DICT_SIZE_MAX | back to summary |
|---|---|
| public static final int DICT_SIZE_MAX Maximum dictionary size for compression is 768 MiB. The decompressor supports bigger dictionaries, up to almost 2 GiB. With HC4 the encoder would support dictionaries bigger than 768 MiB. The 768 MiB limit comes from the current implementation of BT4 where we would otherwise hit the limits of signed ints in array indexing.
If you really need bigger dictionary for decompression,
use | |
| DICT_SIZE_MIN | back to summary |
|---|---|
| public static final int DICT_SIZE_MIN Minimum dictionary size is 4 KiB. | |
| dictSize | back to summary |
|---|---|
| private int dictSize | |
| lc | back to summary |
|---|---|
| private int lc | |
| LC_DEFAULT | back to summary |
|---|---|
| public static final int LC_DEFAULT The default number of literal context bits is 3. | |
| LC_LP_MAX | back to summary |
|---|---|
| public static final int LC_LP_MAX Maximum value for lc + lp is 4. | |
| lp | back to summary |
|---|---|
| private int lp | |
| LP_DEFAULT | back to summary |
|---|---|
| public static final int LP_DEFAULT The default number of literal position bits is 0. | |
| mf | back to summary |
|---|---|
| private int mf | |
| MF_BT4 | back to summary |
|---|---|
| public static final int MF_BT4 Match finder: Binary tree 2-3-4 | |
| MF_HC4 | back to summary |
|---|---|
| public static final int MF_HC4 Match finder: Hash Chain 2-3-4 | |
| mode | back to summary |
|---|---|
| private int mode | |
| MODE_FAST | back to summary |
|---|---|
| public static final int MODE_FAST Compression mode: fast. This is usually combined with a hash chain match finder. | |
| MODE_NORMAL | back to summary |
|---|---|
| public static final int MODE_NORMAL Compression mode: normal. This is usually combined with a binary tree match finder. | |
| MODE_UNCOMPRESSED | back to summary |
|---|---|
| public static final int MODE_UNCOMPRESSED Compression mode: uncompressed. The data is wrapped into a LZMA2 stream without compression. | |
| NICE_LEN_MAX | back to summary |
|---|---|
| public static final int NICE_LEN_MAX Maximum value for | |
| NICE_LEN_MIN | back to summary |
|---|---|
| public static final int NICE_LEN_MIN Minimum value for | |
| niceLen | back to summary |
|---|---|
| private int niceLen | |
| pb | back to summary |
|---|---|
| private int pb | |
| PB_DEFAULT | back to summary |
|---|---|
| public static final int PB_DEFAULT The default number of position bits is 2. | |
| PB_MAX | back to summary |
|---|---|
| public static final int PB_MAX Maximum value for pb is 4. | |
| PRESET_DEFAULT | back to summary |
|---|---|
| public static final int PRESET_DEFAULT Default compression preset level is 6. | |
| PRESET_MAX | back to summary |
|---|---|
| public static final int PRESET_MAX Maximum valid compression preset level is 9. | |
| PRESET_MIN | back to summary |
|---|---|
| public static final int PRESET_MIN Minimum valid compression preset level is 0. | |
| presetDict | back to summary |
|---|---|
| private byte[] presetDict | |
| presetToDepthLimit | back to summary |
|---|---|
| private static final int[] presetToDepthLimit | |
| presetToDictSize | back to summary |
|---|---|
| private static final int[] presetToDictSize | |
| LZMA2Options | back to summary |
|---|---|
| public LZMA2Options() Creates new LZMA2 options and sets them to the default values.
This is equivalent to | |
| LZMA2Options | back to summary |
|---|---|
| public LZMA2Options(int preset) throws UnsupportedOptionsException Creates new LZMA2 options and sets them to the given preset.
| |
| LZMA2Options | back to summary |
|---|---|
| public LZMA2Options(int dictSize, int lc, int lp, int pb, int mode, int niceLen, int mf, int depthLimit) throws UnsupportedOptionsException Creates new LZMA2 options and sets them to the given custom values.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| getDecoderMemoryUsage | back to summary |
|---|---|
| public int getDecoderMemoryUsage() Implements abstract org. Gets how much memory the LZMA2 decoder will need to decompress the data that was encoded with these options and stored in a .xz file.
The returned value may bigger than the value returned by a direct call
to
If you use raw LZMA2 streams and unusual dictioanary size, call
| |
| getDepthLimit | back to summary |
|---|---|
| public int getDepthLimit() Gets the match finder search depth limit. | |
| getDictSize | back to summary |
|---|---|
| public int getDictSize() Gets the dictionary size in bytes. | |
| getEncoderMemoryUsage | back to summary |
|---|---|
| public int getEncoderMemoryUsage() Implements abstract org. Doc from org. Gets how much memory the encoder will need with these options. | |
| getFilterEncoder | back to summary |
|---|---|
| pack-priv FilterEncoder getFilterEncoder() Implements abstract org. | |
| getInputStream | back to summary |
|---|---|
| public InputStream getInputStream(InputStream in, ArrayCache arrayCache) throws IOException Implements abstract org. Doc from org. Gets a raw (no XZ headers) decoder input stream using these options and the given ArrayCache. | |
| getLc | back to summary |
|---|---|
| public int getLc() Gets the number of literal context bits. | |
| getLp | back to summary |
|---|---|
| public int getLp() Gets the number of literal position bits. | |
| getMatchFinder | back to summary |
|---|---|
| public int getMatchFinder() Gets the match finder type. | |
| getMode | back to summary |
|---|---|
| public int getMode() Gets the compression mode. | |
| getNiceLen | back to summary |
|---|---|
| public int getNiceLen() Gets the nice length of matches. | |
| getOutputStream | back to summary |
|---|---|
| public FinishableOutputStream getOutputStream(FinishableOutputStream out, ArrayCache arrayCache) Implements abstract org. Doc from org. Gets a raw (no XZ headers) encoder output stream using these options and the given ArrayCache. Raw streams are an advanced feature. In most cases you want to store the compressed data in the .xz container format instead of using a raw stream. To use this filter in a .xz file, pass this object to XZOutputStream. | |
| getPb | back to summary |
|---|---|
| public int getPb() Gets the number of position bits. | |
| getPresetDict | back to summary |
|---|---|
| public byte[] getPresetDict() Gets the preset dictionary. | |
| setDepthLimit | back to summary |
|---|---|
| public void setDepthLimit(int depthLimit) throws UnsupportedOptionsException Sets the match finder search depth limit.
The default is a special value of Reasonable depth limit for Hash Chain match finders is 4-100 and 16-1000 for Binary Tree match finders. Using very high values can make the compressor extremely slow with some files. Avoid settings higher than 1000 unless you are prepared to interrupt the compression in case it is taking far too long.
| |
| setDictSize | back to summary |
|---|---|
| public void setDictSize(int dictSize) throws UnsupportedOptionsException Sets the dictionary size in bytes. The dictionary (or history buffer) holds the most recently seen uncompressed data. Bigger dictionary usually means better compression. However, using a dictioanary bigger than the size of the uncompressed data is waste of memory. Any value in the range [DICT_SIZE_MIN, DICT_SIZE_MAX] is valid, but sizes of 2^n and 2^n + 2^(n-1) bytes are somewhat recommended.
| |
| setLc | back to summary |
|---|---|
| public void setLc(int lc) throws UnsupportedOptionsException Sets the number of literal context bits. All bytes that cannot be encoded as matches are encoded as literals. That is, literals are simply 8-bit bytes that are encoded one at a time.
The literal coding makes an assumption that the highest
The default value (3) is usually good. If you want maximum compression,
try
| |
| setLcLp | back to summary |
|---|---|
| public void setLcLp(int lc, int lp) throws UnsupportedOptionsException Sets the number of literal context bits and literal position bits.
The sum of
| |
| setLp | back to summary |
|---|---|
| public void setLp(int lp) throws UnsupportedOptionsException Sets the number of literal position bits.
This affets what kind of alignment in the uncompressed data is
assumed when encoding literals. See
| |
| setMatchFinder | back to summary |
|---|---|
| public void setMatchFinder(int mf) throws UnsupportedOptionsException Sets the match finder type.
Match finder has a major effect on compression speed, memory usage,
and compression ratio. Usually Hash Chain match finders are faster
than Binary Tree match finders. The default depends on the preset:
0-3 use
| |
| setMode | back to summary |
|---|---|
| public void setMode(int mode) throws UnsupportedOptionsException Sets the compression mode.
This specifies the method to analyze the data produced by
a match finder. The default is
Usually
The special mode
| |
| setNiceLen | back to summary |
|---|---|
| public void setNiceLen(int niceLen) throws UnsupportedOptionsException Sets the nice length of matches.
Once a match of at least
| |
| setPb | back to summary |
|---|---|
| public void setPb(int pb) throws UnsupportedOptionsException Sets the number of position bits.
This affects what kind of alignment in the uncompressed data is
assumed in general. The default (2) means four-byte alignment
(2^
When the alignment is known, setting the number of position bits
accordingly may reduce the file size a little. For example with text
files having one-byte alignment (US-ASCII, ISO-8859-*, UTF-8), using
Even though the assumed alignment can be adjusted with
| |
| setPreset | back to summary |
|---|---|
| public void setPreset(int preset) throws UnsupportedOptionsException Sets the compression options to the given preset.
The presets 0-3 are fast presets with medium compression.
The presets 4-6 are fairly slow presets with high compression.
The default preset ( The presets 7-9 are like the preset 6 but use bigger dictionaries and have higher compressor and decompressor memory requirements. Unless the uncompressed size of the file exceeds 8 MiB, 16 MiB, or 32 MiB, it is waste of memory to use the presets 7, 8, or 9, respectively.
| |
| setPresetDict | back to summary |
|---|---|
| public void setPresetDict(byte[] presetDict) Sets a preset dictionary. Use null to disable the use of a preset dictionary. By default there is no preset dictionary. The .xz format doesn't support a preset dictionary for now. Do not set a preset dictionary unless you use raw LZMA2. Preset dictionary can be useful when compressing many similar, relatively small chunks of data independently from each other. A preset dictionary should contain typical strings that occur in the files being compressed. The most probable strings should be near the end of the preset dictionary. The preset dictionary used for compression is also needed for decompression. | |