p7zip_4.49_x86_linux_bin.tar.bz2\p7zip_4.49\DOCS\MANUAL\switches\method.htm




-m (Set compression Method) switch

Specifies the compression method.

Syntax

-m<method_parameters>



The format for this switch depends on the archive type.

Zip

ParameterDefaultDescription
x=[0 | 1 | 3 | 5 | 7 | 9 ]5Sets level of compression.
m={MethodID}DeflateSets a method: Copy, Deflate, Deflate64, BZip2.
fb={NumFastBytes}32Sets number of Fast Bytes for Deflate encoder.
pass={NumPasses}1Sets number of Passes for Deflate encoder.
d={Size}[b|k|m]900000Sets Dictionary size for BZip2
mt=[off | on | {N}]onSets multithreading mode.
em={EncryptionMethodID}ZipCryptoSets a encryption method: ZipCrypto, AES128, AES192, AES256
x=[0 | 1 | 3 | 5 | 7 | 9 ]

Sets level of compression. x=0 means Copy mode (no compression).

Deflate / Deflate64 settings:

LevelNumFastBytesNumPassesDescription
1321Fastest
3Fast
5Normal
7643Maximum
912810Ultra

x=1 and x=3 with Deflate method set fast mode for compression.

BZip2 settings:

LevelDictionaryNumPassesDescription
11000001Fastest
3500000Fast
5900000Normal
72Maximum
97Ultra
fb={NumFastBytes}

Sets the number of fast bytes for the Deflate/Deflate64 encoder. It can be in the range from 3 to 258 (257 for Deflate64). Usually, a big number gives a little bit better compression ratio and a slower compression process. A large fast bytes parameter can significantly increase the compression ratio for files which contain long identical sequences of bytes.

pass={NumPasses}

Sets number of passes for Deflate encoder. It can be in the range from 1 to 15 for Deflate and from 1 to 10 for BZip2. Usually, a big number gives a little bit better compression ratio and a slower compression process.

d={Size}[b|k|m]

Sets the Dictionary size for BZip2. You must specify the size in bytes, kilobytes, or megabytes. The maximum value for the Dictionary size is 900000b. If you do not specify any symbol from set [b|k|m], dictionary size will be calculated as DictionarySize = 2^Size bytes.

mt=[off | on | {N}]

Sets multithread mode. If you have a multiprocessor or multicore system, you can get a speed increase with this switch. This option affects only compression with BZip2, Deflate and Deflate64 methods and decompression of BZip2 streams. Each thread in the multithread mode uses 32 MB of RAM for buffering. If you specify {N}, 7-Zip tries to use N threads.

GZip

GZip uses the same parameters as Zip, but GZip compresses only with Deflate method.

BZip2

ParameterDefaultDescription
x=[1 | 3 | 5 | 7 | 9 ]5Sets level of compression.
pass={NumPasses}1Sets number of Passes for Bzip2 encoder.
mt=[off | on | {N}]onSets multithreading mode.
x=[1 | 3 | 5 | 7 | 9 ]

Sets level of compression

LevelNumPassesDescription
51Default compression method.
72Maximum compression method.
97Ultra compression method.
pass={NumPasses}

Sets the number of passes. It can be in the range from 1 to 10. The default value is 1 for normal mode, 2 for maximum mode and 7 for ultra mode. A bigger number can give a little bit better compression ratio and a slower compression process.

mt=[off | on | {N}]

Sets multithread mode. If you have a multiprocessor or multicore system, you can get a speed increase with this switch. If you specify {N}, for example mt=4, 7-Zip tries to use 4 threads.

7z

ParameterDefaultDescription
x=[0 | 1 | 3 | 5 | 7 | 9 ]5Sets level of compression.
s=[off | on | [e] [{N}f] [{N}b | {N}k | {N}m | {N}g]onSets solid mode.
f=[off | on]onEnables or disables compression filters for executable files.
hc=[off | on]onEnables or disables archive header compressing.
he=[off | on]offEnables or disables archive header encryption.
b{C1}[s{S1}]:{C2}[s{S2}] Sets binding beetwen coders.
{N}={MethodID}[:param1][:param2][..]LZMASets a method: LZMA, PPMd, BZip2, Deflate, BCJ, BCJ2, Copy.
mt=[off | on | {N}]onSets multithreading mode.
x=[0 | 1 | 5 | 7 | 9 ]

Sets level of compression

LevelMethodDictionaryFastBytesMatchFinderFilterDescription
0Copy    No compression.
1LZMA64 KB32HC4BCJFastest compressing
3LZMA1 MB32HC4BCJFast compressing
5LZMA16 MB32BT4BCJNormal compressing
7LZMA32 MB64BT4BCJMaximum compressing
9LZMA64 MB64BT4BCJ2Ultra compressing
s=[off | on | [e] [{N}f] [{N}b | {N}k | {N}m | {N}g)]

Enables or disables solid mode. The default mode is s=on. In solid mode, files are grouped together. Usually, compressing in solid mode improves the compression ratio.

eUse a separate solid block for each new file extension
{N}fSet the limit for number of files in one solid block
{N}b | {N}k | {N}m | {N}gSet a limit for the total size of a solid block in bytes

These are the default limits for the solid block size:

Compression LevelSolid block size
Store0 B
Fastest16 MB
Fast128 MB
Normal2 GB
Maximum4 GB
Ultra4 GB

Limitation of the solid block size usually decreases compression ratio but gives the following advantages:

  • Decreases losses in case of future archive damage.
  • Decreases extraction time of a group of files (or just one file), so long as the group doesn't contain the entire archive.

The current version of 7-Zip doesn't support updating of solid archives, if it requires repacking solid blocks.

Example:

        s=100f10m

set solid mode with 100 files & 10 MB limits per one solid block.

f=[off | on]

Enables or disables compression filters for executable files: dll, exe, ocx, sfx, sys. It uses BCJ2 filter in Ultra mode and BCJ filter in other modes. The default mode is f=on.

hc=[off | on]

Enables or disables archive header compressing. The default mode is hc=on. If archive header compressing is enabled, some parts of archive header will be compressed with LZMA method.

he=[off | on]

Enables or disables archive header encryption. The default mode is he=off.

{N}

Sets order of methods. It is used also to associate parameters with methods. Numbers must begin from 0. Methods that have smaller numbers will be used before others.

b{C1}[s{S1}]:{C2}[s{S2}]

Binds output stream S1 in coder C1 with input stream S2 in coder C2. If stream number is not specified, stream with number 0 will be used.

Usally coder has one input stream and one output stream. In 7z some coders can have multiple input and output streams.

For example, BCJ2 encoder has one input stream and four output streams.

mt=[off | on | {N}]

Sets multithread mode. If you have a multiprocessor or multicore system, you can get a increase with this switch. 7-Zip supports multithread mode only for LZMA compression and BZip2 compression / decompression. If you specify {N}, for example mt=4, 7-Zip tries to use 4 threads. LZMA compression uses only 2 threads.

{N}={MethodID}[:param1][:param2] ... [:paramN]

Sets compression method. You can use any number of methods. The default method is LZMA.

Parameters must be in one of the following forms:

  • {ParamName}={ParamValue}.
  • {ParamName}{ParamValue}, if {ParamValue} is number and {ParamName} doesn't contain numbers.

Supported methods:

MethodIDDescription
LZMAAlgorithm based on LZ algorithm
PPMdDmitry Shkarin's PPMdH with small changes
BZip2BWT algorithm
DeflateLZ+Huffman
CopyNo compression

Supported filters:

MethodIDDescription
BCJconverter for x86 executables
BCJ2converter for x86 executables (version 2)
BC_ARMconverter for ARM (little endian) executables
BC_ARMThumbconverter for ARM Thumb (little endian) executables
BC_IA64converter for IA-64 executables
BC_PPC_Bconverter for PowerPC (big endian) executables
BC_SPARCconverter for SPARC executables

Filters increase the compression ratio for some types of files. Filters must be used with one of the compression method (for example, BCJ + LZMA).

LZMA

LZMA is an algorithm based on Lempel-Ziv algorithm. It provides very fast decompression (about 10-20 times faster than compression). Memory requirements for compression and decompression also are different (see d={Size}[b|k|m] switch for details).

ParameterDefaultDescription
a=[0|1]1Sets compressing mode
d={Size}[b|k|m]24Sets Dictionary size
mf={MF_ID}bt4Sets Match Finder
fb={N}32Sets number of Fast Bytes
mc={N}32Sets Number of Cycles for Match Finder
lc={N}3Sets number of Literal Context bits - [0, 8]
lp={N}0Sets number of Literal Pos bits - [0, 4]
pb={N}2Set number of Pos Bits - [0, 4]
a=[0|1]

Sets compression mode: 0 = fast, 1 = normal. Default value is 1.

d={Size}[b|k|m]

Sets Dictionary size for LZMA. You must specify the size in bytes, kilobytes, or megabytes. The maximum value for dictionary size is 1 GB = 2^30 bytes. Default values for LZMA are 24 (16 MB) in normal mode, 25 (32 MB) in maximum mode (-mx=7) and 26 (64 MB) in ultra mode (-mx=9). If you do not specify any symbol from the set [b|k|m], the dictionary size will be calculated as DictionarySize = 2^Size bytes. For decompressing a file compressed by LZMA method with dictionary size N, you need about N bytes of memory (RAM) available.

mf={MF_ID}

Sets Match Finder for LZMA. Default method is bt4. Algorithms from hc* group don't provide a good compression ratio, but they often work pretty fast in combination with fast mode (a=0). Memory requirements depend on dictionary size (parameter "d" in table below).

MF_IDMemoryDescription
bt2d*9.5 + 4 MBBinary Tree with 2 bytes hashing.
bt3d*11.5 + 4 MBBinary Tree with 3 bytes hashing.
bt4d*11.5 + 4 MBBinary Tree with 4 bytes hashing.
hc4d*7.5 + 4 MBHash Chain with 4 bytes hashing.

Note: Your operation system also needs some amount of physical memory for internal purposes. So keep at least 32MB of physical memory unused.

fb={N}

Sets number of fast bytes for LZMA. It can be in the range from 5 to 273. The default value is 32 for normal mode and 64 for maximum and ultra modes. Usually, a big number gives a little bit better compression ratio and slower compression process.

mc={N}

Sets number of cycles (passes) for match finder. It can be in range from 0 to 1000000000. Default value is (16 + number_of_fast_bytes / 2) for BT* match finders and (8 + number_of_fast_bytes / 4) for HC4 match finder. If you specify mc=0, LZMA will use default value. Usually, a big number gives a little bit better compression ratio and slower compression process. For example, mf=HC4 and mc=10000 can provide almost the same compression ratio as mf=BT4.

lc={N}

Sets the number of literal context bits (high bits of previous literal). It can be in range from 0 to 8. Default value is 3. Sometimes lc=4 gives gain for big files.

lp={N}

Sets the number of literal pos bits (low bits of current position for literals). It can be in the range from 0 to 4. The default value is 0. The lp switch is intended for periodical data when the period is equal to 2^value (where lp=value). For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's better to set lc=0, if you change lp switch.

pb={N}

Sets the number of pos bits (low bits of current position). It can be in the range from 0 to 4. The default value is 2. The pb switch is intended for periodical data when the period is equal 2^value (where lp=value).

PPMd

PPMd is a PPM-based algorithm. This algorithm is mostly based on Dmitry Shkarin's PPMdH source code. PPMd provides very good compression ratio for plain text files. There is no difference between compression speed and decompression speed. Memory requirements for compression and decompression also are the same.

ParameterDefaultDescription
mem={Size}[b|k|m]24Sets size of used memory for PPMd.
o={Size}6Sets model order for PPMd.
mem={Size}[b|k|m]

Sets the size of memory used for PPMd. You must specify the size in bytes, kilobytes, or megabytes. The maximum value is 2GB = 2^31 bytes. The default value is 24 (16MB). If you do not specify any symbol from the set [b|k|m], the memory size will be calculated as (2^Size) bytes. PPMd uses the same amount of memory for compression and decompression.

o={Size}

Sets the model order for PPMd. The size must be in the range [2,32]. The default value is 6.

BCJ2

BCJ2 is a Branch converter for 32-bit x86 executables (version 2). It converts some branch instructions for increasing further compression.

A BCJ2 encoder has one input stream and four output streams:

  • s0: main stream. It requires further compression.
  • s1: stream for converted CALL values. It requires further compression.
  • s2: stream for converted JUMP values. It requires further compression.
  • s3: service stream. It is already compressed.

If LZMA is used, the size of the dictionary for streams s1 and s2 can be much smaller (512 KB is enough for most cases) than the dictionary size for stream s0.

Examples

7z a -tzip archive.zip *.jpg -mx0

adds *.jpg files to archive.zip archive without compression.

7z a -t7z archive.7z *.exe *.dll -m0=BCJ -m1=LZMA:d=21 -ms -mmt

adds *.exe and *.dll files to solid archive archive.7z using LZMA method with 2 MB dictionary and BCJ converter. Compression will use multithreading optimization.

7z a -t7z archive.7z *.exe *.dll -m0=BCJ2 -m1=LZMA:d23 -m2=LZMA:d19 

-m3=LZMA:d19 -mb0:1 -mb0s1:2 -mb0s2:3

adds *.exe and *.dll files to archive archive.7z using BCJ2 converter, LZMA with 8 MB dictionary for main output stream (s0), and LZMA with 512 KB dictionary for s1 and s2 output streams of BCJ2.

7z a -t7z archive.7z *.txt -m0=PPMd

adds *.txt files to archive archive.7z using PPMd method.

Commands that can be used with this switch

a (Add), d (Delete), u (Update),

See also

Switches: -t (set Type of archive)

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 ca95 的頭像
    ca95

    ca95 台灣地誌

    ca95 發表在 痞客邦 留言(0) 人氣()