From 40ecba4172722533916c359fcfe5a43dcd0801ea Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 7 Sep 2017 17:46:55 -0400 Subject: 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. --- libtests/qtest/dct.test | 51 +++++++++++++++++++++++------------------ libtests/qtest/dct/big-rawdata | Bin 0 -> 1769472 bytes 2 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 libtests/qtest/dct/big-rawdata (limited to 'libtests/qtest') 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 { diff --git a/libtests/qtest/dct/big-rawdata b/libtests/qtest/dct/big-rawdata new file mode 100644 index 00000000..1f1c9333 Binary files /dev/null and b/libtests/qtest/dct/big-rawdata differ -- cgit v1.2.3-54-g00ecf