Commit bf2fb239d7a39255fe122db50dd5d03f9baa25ae
1 parent
661ed1d2
Rename png_filter -> predictors
Showing
31 changed files
with
33 additions
and
22 deletions
libtests/build.mk
libtests/png_filter.cc renamed to libtests/predictors.cc
| @@ -8,17 +8,26 @@ | @@ -8,17 +8,26 @@ | ||
| 8 | #include <string.h> | 8 | #include <string.h> |
| 9 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| 10 | 10 | ||
| 11 | -void run(char const* filename, bool encode, unsigned int columns, | 11 | +void run(char const* filename, char const* filter, |
| 12 | + bool encode, unsigned int columns, | ||
| 12 | int bits_per_sample, int samples_per_pixel) | 13 | int bits_per_sample, int samples_per_pixel) |
| 13 | { | 14 | { |
| 14 | - // Decode the file | ||
| 15 | FILE* in = QUtil::safe_fopen(filename, "rb"); | 15 | FILE* in = QUtil::safe_fopen(filename, "rb"); |
| 16 | FILE* o1 = QUtil::safe_fopen("out", "wb"); | 16 | FILE* o1 = QUtil::safe_fopen("out", "wb"); |
| 17 | Pipeline* out = new Pl_StdioFile("out", o1); | 17 | Pipeline* out = new Pl_StdioFile("out", o1); |
| 18 | - Pipeline* pl = new Pl_PNGFilter( | ||
| 19 | - "png", out, | ||
| 20 | - encode ? Pl_PNGFilter::a_encode : Pl_PNGFilter::a_decode, | ||
| 21 | - columns, samples_per_pixel, bits_per_sample); | 18 | + Pipeline* pl = 0; |
| 19 | + if (strcmp(filter, "png") == 0) | ||
| 20 | + { | ||
| 21 | + pl = new Pl_PNGFilter( | ||
| 22 | + "png", out, | ||
| 23 | + encode ? Pl_PNGFilter::a_encode : Pl_PNGFilter::a_decode, | ||
| 24 | + columns, samples_per_pixel, bits_per_sample); | ||
| 25 | + } | ||
| 26 | + else | ||
| 27 | + { | ||
| 28 | + std::cerr << "unknown filter " << filter << std::endl; | ||
| 29 | + exit(2); | ||
| 30 | + } | ||
| 22 | assert((2 * (columns + 1)) < 1024); | 31 | assert((2 * (columns + 1)) < 1024); |
| 23 | unsigned char buf[1024]; | 32 | unsigned char buf[1024]; |
| 24 | size_t len; | 33 | size_t len; |
| @@ -55,22 +64,24 @@ void run(char const* filename, bool encode, unsigned int columns, | @@ -55,22 +64,24 @@ void run(char const* filename, bool encode, unsigned int columns, | ||
| 55 | 64 | ||
| 56 | int main(int argc, char* argv[]) | 65 | int main(int argc, char* argv[]) |
| 57 | { | 66 | { |
| 58 | - if (argc != 6) | 67 | + if (argc != 7) |
| 59 | { | 68 | { |
| 60 | - std::cerr << "Usage: png_filter {en,de}code filename" | 69 | + std::cerr << "Usage: predictor {png|tiff} {en,de}code filename" |
| 61 | << " columns samples-per-pixel bits-per-sample" | 70 | << " columns samples-per-pixel bits-per-sample" |
| 62 | << std::endl; | 71 | << std::endl; |
| 63 | exit(2); | 72 | exit(2); |
| 64 | } | 73 | } |
| 65 | - bool encode = (strcmp(argv[1], "encode") == 0); | ||
| 66 | - char* filename = argv[2]; | ||
| 67 | - int columns = QUtil::string_to_int(argv[3]); | ||
| 68 | - int samples_per_pixel = QUtil::string_to_int(argv[4]); | ||
| 69 | - int bits_per_sample = QUtil::string_to_int(argv[5]); | 74 | + char* filter = argv[1]; |
| 75 | + bool encode = (strcmp(argv[2], "encode") == 0); | ||
| 76 | + char* filename = argv[3]; | ||
| 77 | + int columns = QUtil::string_to_int(argv[4]); | ||
| 78 | + int samples_per_pixel = QUtil::string_to_int(argv[5]); | ||
| 79 | + int bits_per_sample = QUtil::string_to_int(argv[6]); | ||
| 70 | 80 | ||
| 71 | try | 81 | try |
| 72 | { | 82 | { |
| 73 | - run(filename, encode, columns, bits_per_sample, samples_per_pixel); | 83 | + run(filename, filter, encode, |
| 84 | + columns, bits_per_sample, samples_per_pixel); | ||
| 74 | } | 85 | } |
| 75 | catch (std::exception& e) | 86 | catch (std::exception& e) |
| 76 | { | 87 | { |
libtests/qtest/png_filter.test renamed to libtests/qtest/predictors.test
| @@ -5,16 +5,16 @@ use strict; | @@ -5,16 +5,16 @@ use strict; | ||
| 5 | use File::Copy; | 5 | use File::Copy; |
| 6 | use Digest::MD5; | 6 | use Digest::MD5; |
| 7 | 7 | ||
| 8 | -chdir("png_filter") or die "chdir testdir failed: $!\n"; | 8 | +chdir("predictors") or die "chdir testdir failed: $!\n"; |
| 9 | 9 | ||
| 10 | require TestDriver; | 10 | require TestDriver; |
| 11 | 11 | ||
| 12 | -my $td = new TestDriver('png_filter'); | 12 | +my $td = new TestDriver('predictors'); |
| 13 | 13 | ||
| 14 | cleanup(); | 14 | cleanup(); |
| 15 | 15 | ||
| 16 | $td->runtest("decode columns = 4", | 16 | $td->runtest("decode columns = 4", |
| 17 | - {$td->COMMAND => "png_filter decode in1 4 1 8"}, | 17 | + {$td->COMMAND => "predictors png decode in1 4 1 8"}, |
| 18 | {$td->STRING => "done\n", | 18 | {$td->STRING => "done\n", |
| 19 | $td->EXIT_STATUS => 0}, | 19 | $td->EXIT_STATUS => 0}, |
| 20 | $td->NORMALIZE_NEWLINES); | 20 | $td->NORMALIZE_NEWLINES); |
| @@ -24,7 +24,7 @@ $td->runtest("check output", | @@ -24,7 +24,7 @@ $td->runtest("check output", | ||
| 24 | {$td->FILE => "out1"}); | 24 | {$td->FILE => "out1"}); |
| 25 | 25 | ||
| 26 | $td->runtest("decode columns = 5", | 26 | $td->runtest("decode columns = 5", |
| 27 | - {$td->COMMAND => "png_filter decode in2 5 1 8"}, | 27 | + {$td->COMMAND => "predictors png decode in2 5 1 8"}, |
| 28 | {$td->STRING => "done\n", | 28 | {$td->STRING => "done\n", |
| 29 | $td->EXIT_STATUS => 0}, | 29 | $td->EXIT_STATUS => 0}, |
| 30 | $td->NORMALIZE_NEWLINES); | 30 | $td->NORMALIZE_NEWLINES); |
| @@ -34,7 +34,7 @@ $td->runtest("check output", | @@ -34,7 +34,7 @@ $td->runtest("check output", | ||
| 34 | {$td->FILE => "out2"}); | 34 | {$td->FILE => "out2"}); |
| 35 | 35 | ||
| 36 | $td->runtest("encode columns = 4", | 36 | $td->runtest("encode columns = 4", |
| 37 | - {$td->COMMAND => "png_filter encode out1 4 1 8"}, | 37 | + {$td->COMMAND => "predictors png encode out1 4 1 8"}, |
| 38 | {$td->STRING => "done\n", | 38 | {$td->STRING => "done\n", |
| 39 | $td->EXIT_STATUS => 0}, | 39 | $td->EXIT_STATUS => 0}, |
| 40 | $td->NORMALIZE_NEWLINES); | 40 | $td->NORMALIZE_NEWLINES); |
| @@ -44,7 +44,7 @@ $td->runtest("check output", | @@ -44,7 +44,7 @@ $td->runtest("check output", | ||
| 44 | {$td->FILE => "in1"}); | 44 | {$td->FILE => "in1"}); |
| 45 | 45 | ||
| 46 | $td->runtest("encode columns = 5", | 46 | $td->runtest("encode columns = 5", |
| 47 | - {$td->COMMAND => "png_filter encode out2 5 1 8"}, | 47 | + {$td->COMMAND => "predictors png encode out2 5 1 8"}, |
| 48 | {$td->STRING => "done\n", | 48 | {$td->STRING => "done\n", |
| 49 | $td->EXIT_STATUS => 0}, | 49 | $td->EXIT_STATUS => 0}, |
| 50 | $td->NORMALIZE_NEWLINES); | 50 | $td->NORMALIZE_NEWLINES); |
| @@ -75,7 +75,7 @@ foreach my $i (@other) | @@ -75,7 +75,7 @@ foreach my $i (@other) | ||
| 75 | my $samples_per_pixel = $2; | 75 | my $samples_per_pixel = $2; |
| 76 | my $bits_per_sample = $3; | 76 | my $bits_per_sample = $3; |
| 77 | $td->runtest("decode $i", | 77 | $td->runtest("decode $i", |
| 78 | - {$td->COMMAND => "png_filter decode $i.data" . | 78 | + {$td->COMMAND => "predictors png decode $i.data" . |
| 79 | " $columns $samples_per_pixel $bits_per_sample"}, | 79 | " $columns $samples_per_pixel $bits_per_sample"}, |
| 80 | {$td->STRING => "done\n", | 80 | {$td->STRING => "done\n", |
| 81 | $td->EXIT_STATUS => 0}, | 81 | $td->EXIT_STATUS => 0}, |
libtests/qtest/png_filter/01--32-3-16.data renamed to libtests/qtest/predictors/01--32-3-16.data
No preview for this file type
libtests/qtest/png_filter/01--32-3-16.decoded renamed to libtests/qtest/predictors/01--32-3-16.decoded
No preview for this file type
libtests/qtest/png_filter/02--32-1-8.data renamed to libtests/qtest/predictors/02--32-1-8.data
No preview for this file type
libtests/qtest/png_filter/02--32-1-8.decoded renamed to libtests/qtest/predictors/02--32-1-8.decoded
No preview for this file type
libtests/qtest/png_filter/03--32-3-8.data renamed to libtests/qtest/predictors/03--32-3-8.data
No preview for this file type
libtests/qtest/png_filter/03--32-3-8.decoded renamed to libtests/qtest/predictors/03--32-3-8.decoded
No preview for this file type
libtests/qtest/png_filter/04--32-1-8.data renamed to libtests/qtest/predictors/04--32-1-8.data
No preview for this file type
libtests/qtest/png_filter/04--32-1-8.decoded renamed to libtests/qtest/predictors/04--32-1-8.decoded
No preview for this file type
libtests/qtest/png_filter/05--32-3-8.data renamed to libtests/qtest/predictors/05--32-3-8.data
No preview for this file type
libtests/qtest/png_filter/05--32-3-8.decoded renamed to libtests/qtest/predictors/05--32-3-8.decoded
No preview for this file type
libtests/qtest/png_filter/06--32-1-8.data renamed to libtests/qtest/predictors/06--32-1-8.data
No preview for this file type
libtests/qtest/png_filter/06--32-1-8.decoded renamed to libtests/qtest/predictors/06--32-1-8.decoded
No preview for this file type
libtests/qtest/png_filter/07--32-3-8.data renamed to libtests/qtest/predictors/07--32-3-8.data
No preview for this file type
libtests/qtest/png_filter/07--32-3-8.decoded renamed to libtests/qtest/predictors/07--32-3-8.decoded
No preview for this file type
libtests/qtest/png_filter/08--32-1-8.data renamed to libtests/qtest/predictors/08--32-1-8.data
No preview for this file type
libtests/qtest/png_filter/08--32-1-8.decoded renamed to libtests/qtest/predictors/08--32-1-8.decoded
No preview for this file type
libtests/qtest/png_filter/09--32-3-8.data renamed to libtests/qtest/predictors/09--32-3-8.data
No preview for this file type
libtests/qtest/png_filter/09--32-3-8.decoded renamed to libtests/qtest/predictors/09--32-3-8.decoded
No preview for this file type
libtests/qtest/png_filter/10--32-1-8.data renamed to libtests/qtest/predictors/10--32-1-8.data
No preview for this file type
libtests/qtest/png_filter/10--32-1-8.decoded renamed to libtests/qtest/predictors/10--32-1-8.decoded
No preview for this file type
libtests/qtest/png_filter/11--32-3-8.data renamed to libtests/qtest/predictors/11--32-3-8.data
No preview for this file type
libtests/qtest/png_filter/11--32-3-8.decoded renamed to libtests/qtest/predictors/11--32-3-8.decoded
No preview for this file type
libtests/qtest/png_filter/12--32-1-4.data renamed to libtests/qtest/predictors/12--32-1-4.data
No preview for this file type
libtests/qtest/png_filter/12--32-1-4.decoded renamed to libtests/qtest/predictors/12--32-1-4.decoded
No preview for this file type
libtests/qtest/png_filter/in1 renamed to libtests/qtest/predictors/in1
No preview for this file type
libtests/qtest/png_filter/in2 renamed to libtests/qtest/predictors/in2
No preview for this file type
libtests/qtest/png_filter/out1 renamed to libtests/qtest/predictors/out1
No preview for this file type
libtests/qtest/png_filter/out2 renamed to libtests/qtest/predictors/out2
No preview for this file type