diff options
author | Jay Berkenbilt <ejb@ql.org> | 2017-09-07 23:46:55 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2017-09-08 04:59:11 +0200 |
commit | 40ecba4172722533916c359fcfe5a43dcd0801ea (patch) | |
tree | b28909fe1eaa2e2c2ecc2ab4ab44efd81cacff13 /libtests/qtest/dct.test | |
parent | cbb2614975baf4269ad0c7944520d2d96799a925 (diff) | |
download | qpdf-40ecba4172722533916c359fcfe5a43dcd0801ea.tar.zst |
Pl_DCT: Use custom source and destination managers (fixes #153)
Avoid calling jpeg_mem_src and jpeg_mem_dest. The custom destination
manager writes to the pipeline in smaller chunks to avoid having the
whole image in memory at once. The source manager works directly with
the Buffer object. Using customer managers avoids use of memory source
and destination managers, which are not present in older versions of
libjpeg still in use by some Linux distributions.
Diffstat (limited to 'libtests/qtest/dct.test')
-rw-r--r-- | libtests/qtest/dct.test | 51 |
1 files changed, 29 insertions, 22 deletions
diff --git a/libtests/qtest/dct.test b/libtests/qtest/dct.test index f3b28581..666f6df8 100644 --- a/libtests/qtest/dct.test +++ b/libtests/qtest/dct.test @@ -16,38 +16,45 @@ my $td = new TestDriver('dct'); cleanup(); -$td->runtest("compress", - {$td->COMMAND => "dct_compress rawdata a.jpg 400 256 gray"}, - {$td->STRING => "", $td->EXIT_STATUS => 0}); -$td->runtest("decompress", - {$td->COMMAND => "dct_uncompress a.jpg out"}, - {$td->STRING => "", $td->EXIT_STATUS => 0}); -# Compare -my @raw = get_data('rawdata'); -my @processed = get_data('out'); my $checked_data = 0; -if ($td->runtest("bytes in data", - {$td->STRING => scalar(@processed)}, - {$td->STRING => scalar(@raw)})) +foreach my $d (['rawdata', '400 256 gray', 0], + ['big-rawdata', '1024 576 rgb', 0.2]) { - my $mismatch = 0; - for (my $i = 0; $i < scalar(@raw); ++$i) + my ($in, $args, $mismatch_fraction) = @$d; + $td->runtest("compress", + {$td->COMMAND => "dct_compress $in a.jpg $args"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); + $td->runtest("decompress", + {$td->COMMAND => "dct_uncompress a.jpg out"}, + {$td->STRING => "", $td->EXIT_STATUS => 0}); + # Compare + my @raw = get_data($in); + my @processed = get_data('out'); + my $bytes = scalar(@raw); + if ($td->runtest("bytes in data", + {$td->STRING => scalar(@processed)}, + {$td->STRING => $bytes})) { - $checked_data = 1; - my $delta = abs(ord($raw[$i]) - ord($processed[$i])); - if ($delta > 10) + ++$checked_data; + my $mismatch = 0; + for (my $i = 0; $i < scalar(@raw); ++$i) { - ++$mismatch; + my $delta = abs(ord($raw[$i]) - ord($processed[$i])); + if ($delta > 10) + { + ++$mismatch; + } } + my $threshold = int($mismatch_fraction * $bytes); + $td->runtest("data is close enough", + {$td->STRING => $mismatch <= $threshold ? 'pass' : 'fail'}, + {$td->STRING => 'pass'}); } - $td->runtest("data is close enough", - {$td->STRING => $mismatch}, - {$td->STRING => '0'}); } cleanup(); -$td->report(3 + $checked_data); +$td->report(6 + $checked_data); sub cleanup { |