Move upx_compress_result_t handling into right place.
This commit is contained in:
@@ -105,16 +105,6 @@ int upx_compress ( const upx_bytep src, unsigned src_len,
|
|||||||
cresult->u_len = src_len;
|
cresult->u_len = src_len;
|
||||||
cresult->c_len = 0;
|
cresult->c_len = 0;
|
||||||
#endif
|
#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) {
|
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
|
cconf = cconf_parm->conf_ucl; // struct copy
|
||||||
|
|
||||||
ucl_uint *res = cresult->result_ucl.result;
|
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
|
// prepare bit-buffer settings
|
||||||
cconf.bb_endian = 0;
|
cconf.bb_endian = 0;
|
||||||
|
|||||||
+35
-29
@@ -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,
|
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;
|
ph.c_len = 0;
|
||||||
assert(ph.level >= 1); assert(ph.level <= 10);
|
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
|
// save current checksums
|
||||||
ph.saved_u_adler = ph.u_adler;
|
ph.saved_u_adler = ph.u_adler;
|
||||||
ph.saved_c_adler = ph.c_adler;
|
ph.saved_c_adler = ph.c_adler;
|
||||||
@@ -173,24 +176,24 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||||||
upx_compress_config_t cconf; cconf.reset();
|
upx_compress_config_t cconf; cconf.reset();
|
||||||
if (cconf_parm)
|
if (cconf_parm)
|
||||||
cconf = *cconf_parm;
|
cconf = *cconf_parm;
|
||||||
// options
|
// cconf options
|
||||||
if (opt->crp.crp_ucl.c_flags != -1)
|
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||||
cconf.conf_ucl.c_flags = opt->crp.crp_ucl.c_flags;
|
{
|
||||||
if (opt->crp.crp_ucl.p_level != -1)
|
if (opt->crp.crp_ucl.c_flags != -1)
|
||||||
cconf.conf_ucl.p_level = opt->crp.crp_ucl.p_level;
|
cconf.conf_ucl.c_flags = opt->crp.crp_ucl.c_flags;
|
||||||
if (opt->crp.crp_ucl.h_level != -1)
|
if (opt->crp.crp_ucl.p_level != -1)
|
||||||
cconf.conf_ucl.h_level = opt->crp.crp_ucl.h_level;
|
cconf.conf_ucl.p_level = opt->crp.crp_ucl.p_level;
|
||||||
if (opt->crp.crp_ucl.max_offset != UINT_MAX && opt->crp.crp_ucl.max_offset < cconf.conf_ucl.max_offset)
|
if (opt->crp.crp_ucl.h_level != -1)
|
||||||
cconf.conf_ucl.max_offset = opt->crp.crp_ucl.max_offset;
|
cconf.conf_ucl.h_level = opt->crp.crp_ucl.h_level;
|
||||||
if (opt->crp.crp_ucl.max_match != UINT_MAX && opt->crp.crp_ucl.max_match < cconf.conf_ucl.max_match)
|
if (opt->crp.crp_ucl.max_offset != UINT_MAX && opt->crp.crp_ucl.max_offset < cconf.conf_ucl.max_offset)
|
||||||
cconf.conf_ucl.max_match = opt->crp.crp_ucl.max_match;
|
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)
|
||||||
// Avoid too many progress bar updates. 64 is s->bar_len in ui.cpp.
|
cconf.conf_ucl.max_match = opt->crp.crp_ucl.max_match;
|
||||||
unsigned step = (ph.u_len < 64*1024) ? 0 : ph.u_len / 64;
|
|
||||||
#if defined(WITH_NRV)
|
#if defined(WITH_NRV)
|
||||||
if (ph.level >= 7 || (ph.level >= 4 && ph.u_len >= 512*1024))
|
if (ph.level >= 7 || (ph.level >= 4 && ph.u_len >= 512*1024))
|
||||||
step = 0;
|
step = 0;
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
if (ui_pass >= 0)
|
if (ui_pass >= 0)
|
||||||
ui_pass++;
|
ui_pass++;
|
||||||
uip->startCallback(ph.u_len, step, ui_pass, ui_total_passes);
|
uip->startCallback(ph.u_len, step, ui_pass, ui_total_passes);
|
||||||
@@ -211,19 +214,22 @@ bool Packer::compress(upx_bytep in, upx_bytep out,
|
|||||||
if (r != UPX_E_OK)
|
if (r != UPX_E_OK)
|
||||||
throwInternalError("compression failed");
|
throwInternalError("compression failed");
|
||||||
|
|
||||||
ucl_uint *res = ph.compress_result.result_ucl.result;
|
if (M_IS_NRV2B(ph.method) || M_IS_NRV2D(ph.method) || M_IS_NRV2E(ph.method))
|
||||||
//ph.min_offset_found = res[0];
|
|
||||||
ph.max_offset_found = res[1];
|
|
||||||
//ph.min_match_found = res[2];
|
|
||||||
ph.max_match_found = res[3];
|
|
||||||
//ph.min_run_found = res[4];
|
|
||||||
ph.max_run_found = res[5];
|
|
||||||
ph.first_offset_found = res[6];
|
|
||||||
//ph.same_match_offsets_found = res[7];
|
|
||||||
if (cconf_parm)
|
|
||||||
{
|
{
|
||||||
assert(cconf.conf_ucl.max_offset == 0 || cconf.conf_ucl.max_offset >= ph.max_offset_found);
|
ucl_uint *res = ph.compress_result.result_ucl.result;
|
||||||
assert(cconf.conf_ucl.max_match == 0 || cconf.conf_ucl.max_match >= ph.max_match_found);
|
//ph.min_offset_found = res[0];
|
||||||
|
ph.max_offset_found = res[1];
|
||||||
|
//ph.min_match_found = res[2];
|
||||||
|
ph.max_match_found = res[3];
|
||||||
|
//ph.min_run_found = res[4];
|
||||||
|
ph.max_run_found = res[5];
|
||||||
|
ph.first_offset_found = res[6];
|
||||||
|
//ph.same_match_offsets_found = res[7];
|
||||||
|
if (cconf_parm)
|
||||||
|
{
|
||||||
|
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);
|
//printf("\nPacker::compress: %d/%d: %7d -> %7d\n", ph.method, ph.level, ph.u_len, ph.c_len);
|
||||||
|
|||||||
Reference in New Issue
Block a user