~ubuntu-branches/debian/sid/upx-ucl/sid

« back to all changes in this revision

Viewing changes to src/packer.cpp

  • Committer: Package Import Robot
  • Author(s): Robert Luberda
  • Date: 2013-05-10 09:18:12 UTC
  • mfrom: (5.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20130510091812-l0xhxajjny9s0d8p
Tags: 3.09-2
* Upload to unstable.
* Standard-Version: 3.9.4:
  + add Built-Using field referring to version of lzma-dev package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
   This file is part of the UPX executable compressor.
4
4
 
5
 
   Copyright (C) 1996-2011 Markus Franz Xaver Johannes Oberhumer
6
 
   Copyright (C) 1996-2011 Laszlo Molnar
 
5
   Copyright (C) 1996-2013 Markus Franz Xaver Johannes Oberhumer
 
6
   Copyright (C) 1996-2013 Laszlo Molnar
7
7
   All Rights Reserved.
8
8
 
9
9
   UPX and the UCL library are free software; you can redistribute them
475
475
 
476
476
 
477
477
/*************************************************************************
478
 
// Find overhead for in-place decompression in an heuristic way
 
478
// Find overhead for in-place decompression in a heuristic way
479
479
// (using a binary search). Return 0 on error.
480
480
//
481
481
// To speed up things:
1311
1311
                                 Filter *parm_ft,
1312
1312
                                 const unsigned overlap_range,
1313
1313
                                 const upx_compress_config_t *cconf,
1314
 
                                 int filter_strategy)
 
1314
                                 int filter_strategy,
 
1315
                                 int inhibit_compression_check)
1315
1316
{
1316
1317
    parm_ft->buf_len = f_len;
1317
1318
    // struct copies
1487
1488
    this->ph = best_ph;
1488
1489
    *parm_ft = best_ft;
1489
1490
 
1490
 
    // finally check compression ratio
1491
 
    if (best_ph.c_len + best_ph_lsize >= best_ph.u_len)
1492
 
        throwNotCompressible();
1493
 
    if (!checkCompressionRatio(best_ph.u_len, best_ph.c_len))
1494
 
        throwNotCompressible();
 
1491
    // Finally, check compression ratio.
 
1492
    // Might be inhibited when blocksize < file_size, for instance.
 
1493
    if (!inhibit_compression_check) {
 
1494
        if (best_ph.c_len + best_ph_lsize >= best_ph.u_len)
 
1495
            throwNotCompressible();
 
1496
        if (!checkCompressionRatio(best_ph.u_len, best_ph.c_len))
 
1497
            throwNotCompressible();
1495
1498
 
1496
 
    // postconditions 2)
1497
 
    assert(best_ph.overlap_overhead > 0);
 
1499
        // postconditions 2)
 
1500
        assert(best_ph.overlap_overhead > 0);
 
1501
    }
1498
1502
 
1499
1503
    // convenience
1500
1504
    buildLoader(&best_ft);
1508
1512
void Packer::compressWithFilters(Filter *ft,
1509
1513
                                 const unsigned overlap_range,
1510
1514
                                 const upx_compress_config_t *cconf,
1511
 
                                 int filter_strategy)
 
1515
                                 int filter_strategy,
 
1516
                                 int inhibit_compression_check)
1512
1517
{
1513
1518
    compressWithFilters(ft, overlap_range, cconf, filter_strategy,
1514
 
                        0, 0, 0, NULL, 0);
 
1519
                        0, 0, 0, NULL, 0, inhibit_compression_check);
1515
1520
}
1516
1521
 
1517
1522
 
1522
1527
                                 unsigned filter_off,
1523
1528
                                 unsigned ibuf_off,
1524
1529
                                 unsigned obuf_off,
1525
 
                                 const upx_bytep hdr_ptr, unsigned hdr_len)
 
1530
                                 const upx_bytep hdr_ptr, unsigned hdr_len,
 
1531
                                 int inhibit_compression_check)
1526
1532
{
1527
1533
    ibuf.checkState(); obuf.checkState();
1528
1534
 
1538
1544
                        o_ptr,
1539
1545
                        f_ptr, f_len,
1540
1546
                        hdr_ptr, hdr_len,
1541
 
                        ft, overlap_range, cconf, filter_strategy);
 
1547
                        ft, overlap_range, cconf, filter_strategy,
 
1548
                        inhibit_compression_check);
1542
1549
 
1543
1550
    ibuf.checkState(); obuf.checkState();
1544
1551
}