diff --git a/src/compress_lzma.cpp b/src/compress_lzma.cpp index df04244b..bb570900 100644 --- a/src/compress_lzma.cpp +++ b/src/compress_lzma.cpp @@ -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)); diff --git a/src/conf.h b/src/conf.h index bd49e16a..394e0055 100644 --- a/src/conf.h +++ b/src/conf.h @@ -239,14 +239,16 @@ struct OptVar struct lzma_compress_config_t { - typedef OptVar pos_bits_t; // pb - typedef OptVar lit_pos_bits_t; // lb - typedef OptVar lit_context_bits_t; // lc + typedef OptVar pos_bits_t; // pb + typedef OptVar lit_pos_bits_t; // lb + typedef OptVar lit_context_bits_t; // lc + typedef OptVar 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 diff --git a/src/main.cpp b/src/main.cpp index b0498f49..5b526592 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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}, diff --git a/src/options.h b/src/options.h index cc24eba3..2f0ffcaf 100644 --- a/src/options.h +++ b/src/options.h @@ -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 { diff --git a/src/packer.cpp b/src/packer.cpp index 2dd09cf3..90ec358a 100644 --- a/src/packer.cpp +++ b/src/packer.cpp @@ -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++;