mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Added option '--crp-lzma-fb='. Started tuning lzma compression
levels '-1' and '-2'.
This commit is contained in:
parent
e1379ac5ce
commit
b31b8cd7f0
|
@ -193,7 +193,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||
pr[2].uintVal = 3; // 0..8
|
||||
pr[3].uintVal = 1024 * 1024;
|
||||
pr[4].uintVal = 2;
|
||||
pr[5].uintVal = 64; // 5..
|
||||
pr[5].uintVal = 64; // 5..273
|
||||
pr[6].uintVal = 0;
|
||||
#if 0
|
||||
// DEBUG - set sizes so that we use a maxmimum amount of stack.
|
||||
|
@ -209,8 +209,11 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||
case 1:
|
||||
pr[3].uintVal = 256 * 1024;
|
||||
pr[4].uintVal = 0;
|
||||
pr[5].uintVal = 8;
|
||||
break;
|
||||
case 2:
|
||||
pr[3].uintVal = 256 * 1024;
|
||||
pr[4].uintVal = 0;
|
||||
break;
|
||||
case 3:
|
||||
break;
|
||||
|
@ -243,6 +246,8 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||
pr[1].uintVal = cconf_parm->conf_lzma.lit_pos_bits;
|
||||
if (cconf_parm->conf_lzma.lit_context_bits.is_set)
|
||||
pr[2].uintVal = cconf_parm->conf_lzma.lit_context_bits;
|
||||
if (cconf_parm->conf_lzma.num_fast_bytes.is_set)
|
||||
pr[5].uintVal = cconf_parm->conf_lzma.num_fast_bytes;
|
||||
}
|
||||
|
||||
// limit dictionary size
|
||||
|
@ -276,6 +281,9 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
|||
res->lit_pos_bits = pr[1].uintVal;
|
||||
res->lit_context_bits = pr[2].uintVal;
|
||||
res->dict_size = pr[3].uintVal;
|
||||
res->fast_mode = pr[4].uintVal;
|
||||
res->num_fast_bytes = pr[5].uintVal;
|
||||
res->match_finder_cycles = pr[6].uintVal;
|
||||
//res->num_probs = LzmaGetNumProbs(&s.Properties));
|
||||
//res->num_probs = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((Properties)->lc + (Properties)->lp)))
|
||||
res->num_probs = 1846 + (768 << (res->lit_context_bits + res->lit_pos_bits));
|
||||
|
|
|
@ -242,11 +242,13 @@ struct lzma_compress_config_t
|
|||
typedef OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb
|
||||
typedef OptVar<unsigned, 0u, 0u, 4u> lit_pos_bits_t; // lb
|
||||
typedef OptVar<unsigned, 3u, 0u, 8u> lit_context_bits_t; // lc
|
||||
typedef OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t;
|
||||
|
||||
unsigned max_num_probs;
|
||||
pos_bits_t pos_bits; // pb
|
||||
lit_pos_bits_t lit_pos_bits; // lp
|
||||
lit_context_bits_t lit_context_bits; // lc
|
||||
num_fast_bytes_t num_fast_bytes;
|
||||
#if 0
|
||||
unsigned dict_size;
|
||||
unsigned mf_passes;
|
||||
|
@ -254,6 +256,7 @@ struct lzma_compress_config_t
|
|||
void reset() {
|
||||
memset(this, 0, sizeof(*this));
|
||||
pos_bits.reset(); lit_pos_bits.reset(); lit_context_bits.reset();
|
||||
num_fast_bytes.reset();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -276,7 +279,10 @@ struct lzma_compress_result_t
|
|||
unsigned lit_pos_bits; // lp
|
||||
unsigned lit_context_bits; // lc
|
||||
unsigned dict_size;
|
||||
unsigned num_probs;
|
||||
unsigned fast_mode;
|
||||
unsigned num_fast_bytes;
|
||||
unsigned match_finder_cycles;
|
||||
unsigned num_probs; // (computed result)
|
||||
};
|
||||
|
||||
struct ucl_compress_result_t
|
||||
|
|
|
@ -651,6 +651,9 @@ static int do_option(int optc, const char *arg)
|
|||
case 813:
|
||||
getoptvar(&opt->crp.crp_lzma.lit_context_bits, arg);
|
||||
break;
|
||||
case 816:
|
||||
getoptvar(&opt->crp.crp_lzma.num_fast_bytes, arg);
|
||||
break;
|
||||
// backup
|
||||
case 'k':
|
||||
opt->backup = 1;
|
||||
|
@ -898,6 +901,7 @@ static const struct mfx_option longopts[] =
|
|||
{"crp-lzma-pb", 0x31, 0, 811},
|
||||
{"crp-lzma-lp", 0x31, 0, 812},
|
||||
{"crp-lzma-lc", 0x31, 0, 813},
|
||||
{"crp-lzma-fb", 0x31, 0, 816},
|
||||
|
||||
// atari/tos
|
||||
{"split-segments", 0x10, 0, 650},
|
||||
|
|
|
@ -89,6 +89,7 @@ struct options_t {
|
|||
TT::pos_bits_t pos_bits; // pb
|
||||
TT::lit_pos_bits_t lit_pos_bits; // lp
|
||||
TT::lit_context_bits_t lit_context_bits; // lc
|
||||
TT::num_fast_bytes_t num_fast_bytes;
|
||||
#if 0
|
||||
unsigned dict_size;
|
||||
unsigned mf_passes;
|
||||
|
@ -96,6 +97,7 @@ struct options_t {
|
|||
void reset() {
|
||||
memset(this, 0, sizeof(*this));
|
||||
pos_bits.reset(); lit_pos_bits.reset(); lit_context_bits.reset();
|
||||
num_fast_bytes.reset();
|
||||
}
|
||||
};
|
||||
struct crp_ucl_t {
|
||||
|
|
|
@ -195,6 +195,7 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||
cconf.conf_lzma.pos_bits = opt->crp.crp_lzma.pos_bits;
|
||||
cconf.conf_lzma.lit_pos_bits = opt->crp.crp_lzma.lit_pos_bits;
|
||||
cconf.conf_lzma.lit_context_bits = opt->crp.crp_lzma.lit_context_bits;
|
||||
cconf.conf_lzma.num_fast_bytes = opt->crp.crp_lzma.num_fast_bytes;
|
||||
}
|
||||
if (uip->ui_pass >= 0)
|
||||
uip->ui_pass++;
|
||||
|
|
Loading…
Reference in New Issue
Block a user