filter strategy option to build no loader at all

modified:   packer.cpp
This commit is contained in:
John Reiser 2024-11-18 16:17:37 -08:00
parent 33b9c68677
commit 5bf2258505

View File

@ -879,6 +879,7 @@ void Packer::relocateLoader() {
// -1: try all filters, use first working one // -1: try all filters, use first working one
// -2: try only the opt->filter filter // -2: try only the opt->filter filter
// -3: use no filter at all // -3: use no filter at all
// -4: use no filter at all, and build no loader, either
// //
// This has been prepared for generalization into class Packer so that // This has been prepared for generalization into class Packer so that
// opt->all_methods and/or opt->all_filters are available for all // opt->all_methods and/or opt->all_filters are available for all
@ -952,7 +953,7 @@ static int prepareFilters(int *filters, int &filter_strategy, const int *all_fil
} }
assert(filter_strategy != 0); assert(filter_strategy != 0);
if (filter_strategy == -3) if (filter_strategy <= -3)
goto done; goto done;
if (filter_strategy == -2) { if (filter_strategy == -2) {
if (opt->filter >= 0 && Filter::isValidFilter(opt->filter, all_filters)) { if (opt->filter >= 0 && Filter::isValidFilter(opt->filter, all_filters)) {
@ -1134,10 +1135,12 @@ void Packer::compressWithFilters(byte *i_ptr,
best_ph.c_len + best_ph_lsize + best_hdr_c_len) { best_ph.c_len + best_ph_lsize + best_hdr_c_len) {
// get results // get results
ph.overlap_overhead = findOverlapOverhead(o_tmp, i_ptr, overlap_range); ph.overlap_overhead = findOverlapOverhead(o_tmp, i_ptr, overlap_range);
if (-4 < filter_strategy) {
buildLoader(&ft); buildLoader(&ft);
lsize = getLoaderSize(); lsize = getLoaderSize();
assert(lsize > 0); assert(lsize > 0);
} }
}
NO_printf("\n%2d %02x: %d +%4d +%3d = %d (best: %d +%4d +%3d = %d)\n", ph.method, NO_printf("\n%2d %02x: %d +%4d +%3d = %d (best: %d +%4d +%3d = %d)\n", ph.method,
ph.filter, ph.c_len, lsize, hdr_c_len, ph.c_len + lsize + hdr_c_len, ph.filter, ph.c_len, lsize, hdr_c_len, ph.c_len + lsize + hdr_c_len,
best_ph.c_len, best_ph_lsize, best_hdr_c_len, best_ph.c_len, best_ph_lsize, best_hdr_c_len,
@ -1227,7 +1230,7 @@ void Packer::compressWithFilters(Filter *ft, const unsigned overlap_range,
unsigned i_len = ph.u_len; unsigned i_len = ph.u_len;
byte *o_ptr = obuf + obuf_off; byte *o_ptr = obuf + obuf_off;
unsigned f_len = ft->buf_len ? ft->buf_len : i_len; unsigned f_len = ft->buf_len ? ft->buf_len : i_len;
if (filter_strategy == -3) { if (filter_strategy <= -3) {
filter_off = 0; filter_off = 0;
f_len = 0; f_len = 0;
} }