mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Move upx_compress_result_t handling into right place.
This commit is contained in:
parent
66df7389d2
commit
930f07d15e
|
@ -105,16 +105,6 @@ int upx_compress ( const upx_bytep src, unsigned src_len,
|
|||
cresult->u_len = src_len;
|
||||
cresult->c_len = 0;
|
||||
#endif
|
||||
// assume no info available - fill in worst case results
|
||||
ucl_uint *res = cresult->result_ucl.result;
|
||||
//res[0] = 1; // min_offset_found - NOT USED
|
||||
res[1] = src_len - 1; // max_offset_found
|
||||
//res[2] = 2; // min_match_found - NOT USED
|
||||
res[3] = src_len - 1; // max_match_found
|
||||
//res[4] = 1; // min_run_found - NOT USED
|
||||
res[5] = src_len; // max_run_found
|
||||
res[6] = 1; // first_offset_found
|
||||
//res[7] = 999999; // same_match_offsets_found - NOT USED
|
||||
|
||||
if (method < 0) {
|
||||
}
|
||||
|
|
|
@ -121,6 +121,15 @@ int upx_ucl_compress ( const upx_bytep src, unsigned src_len,
|
|||
cconf = cconf_parm->conf_ucl; // struct copy
|
||||
|
||||
ucl_uint *res = cresult->result_ucl.result;
|
||||
// assume no info available - fill in worst case results
|
||||
//res[0] = 1; // min_offset_found - NOT USED
|
||||
res[1] = src_len - 1; // max_offset_found
|
||||
//res[2] = 2; // min_match_found - NOT USED
|
||||
res[3] = src_len - 1; // max_match_found
|
||||
//res[4] = 1; // min_run_found - NOT USED
|
||||
res[5] = src_len; // max_run_found
|
||||
res[6] = 1; // first_offset_found
|
||||
//res[7] = 999999; // same_match_offsets_found - NOT USED
|
||||
|
||||
// prepare bit-buffer settings
|
||||
cconf.bb_endian = 0;
|
||||
|
|
|
@ -154,7 +154,7 @@ bool Packer::skipVerify() const
|
|||
|
||||
|
||||
/*************************************************************************
|
||||
// compress
|
||||
// compress - wrap call to low-level upx_compress()
|
||||
**************************************************************************/
|
||||
|
||||
bool Packer::compress(upx_bytep in, upx_bytep out,
|
||||
|
@ -163,6 +163,9 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||
ph.c_len = 0;
|
||||
assert(ph.level >= 1); assert(ph.level <= 10);
|
||||
|
||||
// Avoid too many progress bar updates. 64 is s->bar_len in ui.cpp.
|
||||
unsigned step = (ph.u_len < 64*1024) ? 0 : ph.u_len / 64;
|
||||
|
||||
// save current checksums
|
||||
ph.saved_u_adler = ph.u_adler;
|
||||
ph.saved_c_adler = ph.c_adler;
|
||||
|
@ -173,7 +176,9 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||
upx_compress_config_t cconf; cconf.reset();
|
||||
if (cconf_parm)
|
||||
cconf = *cconf_parm;
|
||||
// options
|
||||
// cconf options
|
||||
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||
{
|
||||
if (opt->crp.crp_ucl.c_flags != -1)
|
||||
cconf.conf_ucl.c_flags = opt->crp.crp_ucl.c_flags;
|
||||
if (opt->crp.crp_ucl.p_level != -1)
|
||||
|
@ -184,13 +189,11 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||
cconf.conf_ucl.max_offset = opt->crp.crp_ucl.max_offset;
|
||||
if (opt->crp.crp_ucl.max_match != UINT_MAX && opt->crp.crp_ucl.max_match < cconf.conf_ucl.max_match)
|
||||
cconf.conf_ucl.max_match = opt->crp.crp_ucl.max_match;
|
||||
|
||||
// Avoid too many progress bar updates. 64 is s->bar_len in ui.cpp.
|
||||
unsigned step = (ph.u_len < 64*1024) ? 0 : ph.u_len / 64;
|
||||
#if defined(WITH_NRV)
|
||||
if (ph.level >= 7 || (ph.level >= 4 && ph.u_len >= 512*1024))
|
||||
step = 0;
|
||||
#endif
|
||||
}
|
||||
if (ui_pass >= 0)
|
||||
ui_pass++;
|
||||
uip->startCallback(ph.u_len, step, ui_pass, ui_total_passes);
|
||||
|
@ -211,6 +214,8 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||
if (r != UPX_E_OK)
|
||||
throwInternalError("compression failed");
|
||||
|
||||
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||
{
|
||||
ucl_uint *res = ph.compress_result.result_ucl.result;
|
||||
//ph.min_offset_found = res[0];
|
||||
ph.max_offset_found = res[1];
|
||||
|
@ -225,6 +230,7 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||
assert(cconf.conf_ucl.max_offset == 0 || cconf.conf_ucl.max_offset >= ph.max_offset_found);
|
||||
assert(cconf.conf_ucl.max_match == 0 || cconf.conf_ucl.max_match >= ph.max_match_found);
|
||||
}
|
||||
}
|
||||
|
||||
//printf("\nPacker::compress: %d/%d: %7d -> %7d\n", ph.method, ph.level, ph.u_len, ph.c_len);
|
||||
if (!checkCompressionRatio(ph.u_len, ph.c_len))
|
||||
|
|
Loading…
Reference in New Issue
Block a user