mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Merge
This commit is contained in:
commit
9e65692b69
|
@ -37,7 +37,7 @@ void lzma_compress_config_t::reset()
|
||||||
pos_bits.reset();
|
pos_bits.reset();
|
||||||
lit_pos_bits.reset();
|
lit_pos_bits.reset();
|
||||||
lit_context_bits.reset();
|
lit_context_bits.reset();
|
||||||
dict_size = 1024 * 1024;
|
dict_size.reset();
|
||||||
fast_mode = 2;
|
fast_mode = 2;
|
||||||
num_fast_bytes.reset();
|
num_fast_bytes.reset();
|
||||||
match_finder_cycles = 0;
|
match_finder_cycles = 0;
|
||||||
|
@ -169,6 +169,19 @@ STDMETHODIMP ProgressInfo::SetRatioInfo(const UInt64 *inSize, const UInt64 *outS
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
|
#include "C/Common/Alloc.cpp"
|
||||||
|
#include "C/Common/CRC.cpp"
|
||||||
|
//#include "C/7zip/Common/InBuffer.cpp"
|
||||||
|
#include "C/7zip/Common/OutBuffer.cpp"
|
||||||
|
#include "C/7zip/Common/StreamUtils.cpp"
|
||||||
|
#include "C/7zip/Compress/LZ/LZInWindow.cpp"
|
||||||
|
//#include "C/7zip/Compress/LZ/LZOutWindow.cpp"
|
||||||
|
//#include "C/7zip/Compress/LZMA/LZMADecoder.cpp"
|
||||||
|
#include "C/7zip/Compress/LZMA/LZMAEncoder.cpp"
|
||||||
|
#include "C/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
|
||||||
|
#undef RC_NORMALIZE
|
||||||
|
|
||||||
|
|
||||||
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||||
upx_bytep dst, unsigned* dst_len,
|
upx_bytep dst, unsigned* dst_len,
|
||||||
upx_callback_p cb,
|
upx_callback_p cb,
|
||||||
|
@ -192,31 +205,39 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||||
progress.cb = cb;
|
progress.cb = cb;
|
||||||
|
|
||||||
NCompress::NLZMA::CEncoder enc;
|
NCompress::NLZMA::CEncoder enc;
|
||||||
const PROPID propIDs[7] = {
|
const PROPID propIDs[8] = {
|
||||||
NCoderPropID::kPosStateBits, // 0 pb _posStateBits(2)
|
NCoderPropID::kPosStateBits, // 0 pb _posStateBits(2)
|
||||||
NCoderPropID::kLitPosBits, // 1 lp _numLiteralPosStateBits(0)
|
NCoderPropID::kLitPosBits, // 1 lp _numLiteralPosStateBits(0)
|
||||||
NCoderPropID::kLitContextBits, // 2 lc _numLiteralContextBits(3)
|
NCoderPropID::kLitContextBits, // 2 lc _numLiteralContextBits(3)
|
||||||
NCoderPropID::kDictionarySize, // 3
|
NCoderPropID::kDictionarySize, // 3 ds
|
||||||
NCoderPropID::kAlgorithm, // 4 _fastmode
|
NCoderPropID::kAlgorithm, // 4 fm _fastmode
|
||||||
NCoderPropID::kNumFastBytes, // 5
|
NCoderPropID::kNumFastBytes, // 5 fb
|
||||||
NCoderPropID::kMatchFinderCycles // 6
|
NCoderPropID::kMatchFinderCycles, // 6 mfc _matchFinderCycles, _cutValue
|
||||||
|
NCoderPropID::kMatchFinder // 7 mf
|
||||||
};
|
};
|
||||||
PROPVARIANT pr[7];
|
PROPVARIANT pr[8];
|
||||||
pr[0].vt = pr[1].vt = pr[2].vt = pr[3].vt = VT_UI4;
|
pr[0].vt = pr[1].vt = pr[2].vt = pr[3].vt = VT_UI4;
|
||||||
pr[4].vt = pr[5].vt = pr[6].vt = VT_UI4;
|
pr[4].vt = pr[5].vt = pr[6].vt = VT_UI4;
|
||||||
|
pr[7].vt = VT_BSTR;
|
||||||
|
|
||||||
// setup defaults
|
// setup defaults
|
||||||
pr[0].uintVal = 2; // 0..4
|
pr[0].uintVal = 2; // 0 .. 4
|
||||||
pr[1].uintVal = 0; // 0..4
|
pr[1].uintVal = 0; // 0 .. 4
|
||||||
pr[2].uintVal = 3; // 0..8
|
pr[2].uintVal = 3; // 0 .. 8
|
||||||
pr[3].uintVal = 1024 * 1024;
|
pr[3].uintVal = 4 * 1024 * 1024; // 1 .. 2**30
|
||||||
pr[4].uintVal = 2;
|
pr[4].uintVal = 2;
|
||||||
pr[5].uintVal = 64; // 5..273
|
pr[5].uintVal = 64; // 5 .. 273
|
||||||
pr[6].uintVal = 0;
|
pr[6].uintVal = 0;
|
||||||
|
#ifdef COMPRESS_MF_BT4
|
||||||
|
static wchar_t matchfinder[] = L"BT4";
|
||||||
|
#endif
|
||||||
|
assert(NCompress::NLZMA::FindMatchFinder(matchfinder) >= 0);
|
||||||
|
pr[7].bstrVal = matchfinder;
|
||||||
#if 1
|
#if 1
|
||||||
pr[0].uintVal = lzma_compress_config_t::pos_bits_t::default_value_c;
|
pr[0].uintVal = lzma_compress_config_t::pos_bits_t::default_value_c;
|
||||||
pr[1].uintVal = lzma_compress_config_t::lit_pos_bits_t::default_value_c;
|
pr[1].uintVal = lzma_compress_config_t::lit_pos_bits_t::default_value_c;
|
||||||
pr[2].uintVal = lzma_compress_config_t::lit_context_bits_t::default_value_c;
|
pr[2].uintVal = lzma_compress_config_t::lit_context_bits_t::default_value_c;
|
||||||
|
pr[3].uintVal = lzma_compress_config_t::dict_size_t::default_value_c;
|
||||||
pr[5].uintVal = lzma_compress_config_t::num_fast_bytes_t::default_value_c;
|
pr[5].uintVal = lzma_compress_config_t::num_fast_bytes_t::default_value_c;
|
||||||
#endif
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -270,6 +291,8 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||||
pr[1].uintVal = cconf_parm->conf_lzma.lit_pos_bits;
|
pr[1].uintVal = cconf_parm->conf_lzma.lit_pos_bits;
|
||||||
if (cconf_parm->conf_lzma.lit_context_bits.is_set)
|
if (cconf_parm->conf_lzma.lit_context_bits.is_set)
|
||||||
pr[2].uintVal = cconf_parm->conf_lzma.lit_context_bits;
|
pr[2].uintVal = cconf_parm->conf_lzma.lit_context_bits;
|
||||||
|
if (cconf_parm->conf_lzma.dict_size.is_set)
|
||||||
|
pr[3].uintVal = cconf_parm->conf_lzma.dict_size;
|
||||||
if (cconf_parm->conf_lzma.num_fast_bytes.is_set)
|
if (cconf_parm->conf_lzma.num_fast_bytes.is_set)
|
||||||
pr[5].uintVal = cconf_parm->conf_lzma.num_fast_bytes;
|
pr[5].uintVal = cconf_parm->conf_lzma.num_fast_bytes;
|
||||||
}
|
}
|
||||||
|
@ -319,7 +342,7 @@ int upx_lzma_compress ( const upx_bytep src, unsigned src_len,
|
||||||
# error
|
# error
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (enc.SetCoderProperties(propIDs, pr, 7) != S_OK)
|
if (enc.SetCoderProperties(propIDs, pr, 8) != S_OK)
|
||||||
goto error;
|
goto error;
|
||||||
if (enc.WriteCoderProperties(&os) != S_OK)
|
if (enc.WriteCoderProperties(&os) != S_OK)
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -367,19 +390,6 @@ error:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#include "C/Common/Alloc.cpp"
|
|
||||||
#include "C/Common/CRC.cpp"
|
|
||||||
//#include "C/7zip/Common/InBuffer.cpp"
|
|
||||||
#include "C/7zip/Common/OutBuffer.cpp"
|
|
||||||
#include "C/7zip/Common/StreamUtils.cpp"
|
|
||||||
#include "C/7zip/Compress/LZ/LZInWindow.cpp"
|
|
||||||
//#include "C/7zip/Compress/LZ/LZOutWindow.cpp"
|
|
||||||
//#include "C/7zip/Compress/LZMA/LZMADecoder.cpp"
|
|
||||||
#include "C/7zip/Compress/LZMA/LZMAEncoder.cpp"
|
|
||||||
#include "C/7zip/Compress/RangeCoder/RangeCoderBit.cpp"
|
|
||||||
#undef RC_NORMALIZE
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
// decompress
|
// decompress
|
||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
|
@ -502,12 +502,13 @@ struct lzma_compress_config_t
|
||||||
typedef OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb
|
typedef OptVar<unsigned, 2u, 0u, 4u> pos_bits_t; // pb
|
||||||
typedef OptVar<unsigned, 0u, 0u, 4u> lit_pos_bits_t; // lb
|
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, 3u, 0u, 8u> lit_context_bits_t; // lc
|
||||||
|
typedef OptVar<unsigned, (1u<<22), 1u, (1u<<30) > dict_size_t;
|
||||||
typedef OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t;
|
typedef OptVar<unsigned, 64u, 5u, 273u> num_fast_bytes_t;
|
||||||
|
|
||||||
pos_bits_t pos_bits; // pb
|
pos_bits_t pos_bits; // pb
|
||||||
lit_pos_bits_t lit_pos_bits; // lp
|
lit_pos_bits_t lit_pos_bits; // lp
|
||||||
lit_context_bits_t lit_context_bits; // lc
|
lit_context_bits_t lit_context_bits; // lc
|
||||||
unsigned dict_size;
|
dict_size_t dict_size;
|
||||||
unsigned fast_mode;
|
unsigned fast_mode;
|
||||||
num_fast_bytes_t num_fast_bytes;
|
num_fast_bytes_t num_fast_bytes;
|
||||||
unsigned match_finder_cycles;
|
unsigned match_finder_cycles;
|
||||||
|
|
|
@ -674,6 +674,9 @@ static int do_option(int optc, const char *arg)
|
||||||
case 813:
|
case 813:
|
||||||
getoptvar(&opt->crp.crp_lzma.lit_context_bits, arg);
|
getoptvar(&opt->crp.crp_lzma.lit_context_bits, arg);
|
||||||
break;
|
break;
|
||||||
|
case 814:
|
||||||
|
getoptvar(&opt->crp.crp_lzma.dict_size, arg);
|
||||||
|
break;
|
||||||
case 816:
|
case 816:
|
||||||
getoptvar(&opt->crp.crp_lzma.num_fast_bytes, arg);
|
getoptvar(&opt->crp.crp_lzma.num_fast_bytes, arg);
|
||||||
break;
|
break;
|
||||||
|
@ -927,6 +930,7 @@ static const struct mfx_option longopts[] =
|
||||||
{"crp-lzma-pb", 0x31, 0, 811},
|
{"crp-lzma-pb", 0x31, 0, 811},
|
||||||
{"crp-lzma-lp", 0x31, 0, 812},
|
{"crp-lzma-lp", 0x31, 0, 812},
|
||||||
{"crp-lzma-lc", 0x31, 0, 813},
|
{"crp-lzma-lc", 0x31, 0, 813},
|
||||||
|
{"crp-lzma-ds", 0x31, 0, 814},
|
||||||
{"crp-lzma-fb", 0x31, 0, 816},
|
{"crp-lzma-fb", 0x31, 0, 816},
|
||||||
// [deprecated - only for compatibility with UPX 2.0x]
|
// [deprecated - only for compatibility with UPX 2.0x]
|
||||||
{"crp-ms", 0x31, 0, 807},
|
{"crp-ms", 0x31, 0, 807},
|
||||||
|
|
|
@ -191,10 +191,11 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
||||||
}
|
}
|
||||||
if (M_IS_LZMA(ph.method))
|
if (M_IS_LZMA(ph.method))
|
||||||
{
|
{
|
||||||
// info: these are optional assignments which query OptVar::is_set
|
// NOTE: these are _optional_ assignments which query OptVar::is_set !
|
||||||
cconf.conf_lzma.pos_bits = opt->crp.crp_lzma.pos_bits;
|
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_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.lit_context_bits = opt->crp.crp_lzma.lit_context_bits;
|
||||||
|
cconf.conf_lzma.dict_size = opt->crp.crp_lzma.dict_size;
|
||||||
cconf.conf_lzma.num_fast_bytes = opt->crp.crp_lzma.num_fast_bytes;
|
cconf.conf_lzma.num_fast_bytes = opt->crp.crp_lzma.num_fast_bytes;
|
||||||
}
|
}
|
||||||
if (uip->ui_pass >= 0)
|
if (uip->ui_pass >= 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user