From 53971d50be39448c980d842a1fe1f525b4cee597 Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 13 Jan 2018 14:15:20 -0500 Subject: Add Pl_TIFFPredictor --- libtests/libtests.testcov | 1 + libtests/predictors.cc | 8 +++++ libtests/qtest/predictors.test | 38 ++++++++++++++++++++-- libtests/qtest/predictors/tiff-01--16-1-8.data | Bin 0 -> 48 bytes libtests/qtest/predictors/tiff-01--16-1-8.decoded | 3 ++ libtests/qtest/predictors/tiff-02--8-2-4.data | Bin 0 -> 16 bytes libtests/qtest/predictors/tiff-02--8-2-4.decoded | 1 + libtests/qtest/predictors/tiff-03--4-1-16.data | 1 + libtests/qtest/predictors/tiff-03--4-1-16.decoded | 1 + 9 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 libtests/qtest/predictors/tiff-01--16-1-8.data create mode 100644 libtests/qtest/predictors/tiff-01--16-1-8.decoded create mode 100644 libtests/qtest/predictors/tiff-02--8-2-4.data create mode 100644 libtests/qtest/predictors/tiff-02--8-2-4.decoded create mode 100644 libtests/qtest/predictors/tiff-03--4-1-16.data create mode 100644 libtests/qtest/predictors/tiff-03--4-1-16.decoded (limited to 'libtests') diff --git a/libtests/libtests.testcov b/libtests/libtests.testcov index 03ca98a6..8b209281 100644 --- a/libtests/libtests.testcov +++ b/libtests/libtests.testcov @@ -33,3 +33,4 @@ Pl_PNGFilter decodeSub 0 Pl_PNGFilter decodeUp 0 Pl_PNGFilter decodeAverage 0 Pl_PNGFilter decodePaeth 0 +Pl_TIFFPredictor processRow 1 diff --git a/libtests/predictors.cc b/libtests/predictors.cc index fe2b90f4..47efa287 100644 --- a/libtests/predictors.cc +++ b/libtests/predictors.cc @@ -1,4 +1,5 @@ #include +#include #include #include @@ -23,6 +24,13 @@ void run(char const* filename, char const* filter, encode ? Pl_PNGFilter::a_encode : Pl_PNGFilter::a_decode, columns, samples_per_pixel, bits_per_sample); } + else if (strcmp(filter, "tiff") == 0) + { + pl = new Pl_TIFFPredictor( + "png", out, + encode ? Pl_TIFFPredictor::a_encode : Pl_TIFFPredictor::a_decode, + columns, samples_per_pixel, bits_per_sample); + } else { std::cerr << "unknown filter " << filter << std::endl; diff --git a/libtests/qtest/predictors.test b/libtests/qtest/predictors.test index f0553472..98961d1a 100644 --- a/libtests/qtest/predictors.test +++ b/libtests/qtest/predictors.test @@ -53,7 +53,7 @@ $td->runtest("check output", {$td->FILE => "out"}, {$td->FILE => "in2"}); -my @other = ( +my @other_png = ( '01--32-3-16', '02--32-1-8', '03--32-3-8', @@ -68,7 +68,7 @@ my @other = ( '12--32-1-4', ); -foreach my $i (@other) +foreach my $i (@other_png) { $i =~ m/^.*?--(\d+)-(\d+)-(\d+)$/ or die; my $columns = $1; @@ -85,9 +85,41 @@ foreach my $i (@other) {$td->FILE => "$i.decoded"}); } +my @tiff = ( + '01--16-1-8', + '02--8-2-4', + '03--4-1-16', + ); + +foreach my $i (@tiff) +{ + $i =~ m/^.*?--(\d+)-(\d+)-(\d+)$/ or die; + my $columns = $1; + my $samples_per_pixel = $2; + my $bits_per_sample = $3; + $td->runtest("decode tiff $i", + {$td->COMMAND => "predictors tiff decode tiff-$i.data" . + " $columns $samples_per_pixel $bits_per_sample"}, + {$td->STRING => "done\n", + $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + $td->runtest("check output for tiff-$i", + {$td->FILE => "out"}, + {$td->FILE => "tiff-$i.decoded"}); + $td->runtest("encode tiff $i", + {$td->COMMAND => "predictors tiff encode tiff-$i.decoded" . + " $columns $samples_per_pixel $bits_per_sample"}, + {$td->STRING => "done\n", + $td->EXIT_STATUS => 0}, + $td->NORMALIZE_NEWLINES); + $td->runtest("check output for tiff-$i", + {$td->FILE => "out"}, + {$td->FILE => "tiff-$i.data"}); +} + cleanup(); -$td->report(8 + (2 * scalar(@other))); +$td->report(8 + (2 * scalar(@other_png)) + (4 * scalar(@tiff))); sub cleanup { diff --git a/libtests/qtest/predictors/tiff-01--16-1-8.data b/libtests/qtest/predictors/tiff-01--16-1-8.data new file mode 100644 index 00000000..30ba8de7 Binary files /dev/null and b/libtests/qtest/predictors/tiff-01--16-1-8.data differ diff --git a/libtests/qtest/predictors/tiff-01--16-1-8.decoded b/libtests/qtest/predictors/tiff-01--16-1-8.decoded new file mode 100644 index 00000000..a47c5d62 --- /dev/null +++ b/libtests/qtest/predictors/tiff-01--16-1-8.decoded @@ -0,0 +1,3 @@ + +  + WXWVUTSRQG=33467 \ No newline at end of file diff --git a/libtests/qtest/predictors/tiff-02--8-2-4.data b/libtests/qtest/predictors/tiff-02--8-2-4.data new file mode 100644 index 00000000..0861af5a Binary files /dev/null and b/libtests/qtest/predictors/tiff-02--8-2-4.data differ diff --git a/libtests/qtest/predictors/tiff-02--8-2-4.decoded b/libtests/qtest/predictors/tiff-02--8-2-4.decoded new file mode 100644 index 00000000..7386e3ec --- /dev/null +++ b/libtests/qtest/predictors/tiff-02--8-2-4.decoded @@ -0,0 +1 @@ +ª›Œ}__wª›Œ}__w \ No newline at end of file diff --git a/libtests/qtest/predictors/tiff-03--4-1-16.data b/libtests/qtest/predictors/tiff-03--4-1-16.data new file mode 100644 index 00000000..e03d809d --- /dev/null +++ b/libtests/qtest/predictors/tiff-03--4-1-16.data @@ -0,0 +1 @@ +UUÍðd 9[ \ No newline at end of file diff --git a/libtests/qtest/predictors/tiff-03--4-1-16.decoded b/libtests/qtest/predictors/tiff-03--4-1-16.decoded new file mode 100644 index 00000000..7d3c2dd9 --- /dev/null +++ b/libtests/qtest/predictors/tiff-03--4-1-16.decoded @@ -0,0 +1 @@ +UU#E‡eÀÀ \ No newline at end of file -- cgit v1.2.3-54-g00ecf