From bf2fb239d7a39255fe122db50dd5d03f9baa25ae Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Sat, 13 Jan 2018 14:32:39 -0500 Subject: [PATCH] Rename png_filter -> predictors --- libtests/build.mk | 2 +- libtests/{png_filter.cc => predictors.cc} | 39 +++++++++++------- .../{png_filter.test => predictors.test} | 14 +++---- .../01--32-3-16.data | Bin .../01--32-3-16.decoded | Bin .../02--32-1-8.data | Bin .../02--32-1-8.decoded | Bin .../03--32-3-8.data | Bin .../03--32-3-8.decoded | Bin .../04--32-1-8.data | Bin .../04--32-1-8.decoded | Bin .../05--32-3-8.data | Bin .../05--32-3-8.decoded | Bin .../06--32-1-8.data | Bin .../06--32-1-8.decoded | Bin .../07--32-3-8.data | Bin .../07--32-3-8.decoded | Bin .../08--32-1-8.data | Bin .../08--32-1-8.decoded | Bin .../09--32-3-8.data | Bin .../09--32-3-8.decoded | Bin .../10--32-1-8.data | Bin .../10--32-1-8.decoded | Bin .../11--32-3-8.data | Bin .../11--32-3-8.decoded | Bin .../12--32-1-4.data | Bin .../12--32-1-4.decoded | Bin libtests/qtest/{png_filter => predictors}/in1 | Bin libtests/qtest/{png_filter => predictors}/in2 | Bin .../qtest/{png_filter => predictors}/out1 | Bin .../qtest/{png_filter => predictors}/out2 | Bin 31 files changed, 33 insertions(+), 22 deletions(-) rename libtests/{png_filter.cc => predictors.cc} (56%) rename libtests/qtest/{png_filter.test => predictors.test} (82%) rename libtests/qtest/{png_filter => predictors}/01--32-3-16.data (100%) rename libtests/qtest/{png_filter => predictors}/01--32-3-16.decoded (100%) rename libtests/qtest/{png_filter => predictors}/02--32-1-8.data (100%) rename libtests/qtest/{png_filter => predictors}/02--32-1-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/03--32-3-8.data (100%) rename libtests/qtest/{png_filter => predictors}/03--32-3-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/04--32-1-8.data (100%) rename libtests/qtest/{png_filter => predictors}/04--32-1-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/05--32-3-8.data (100%) rename libtests/qtest/{png_filter => predictors}/05--32-3-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/06--32-1-8.data (100%) rename libtests/qtest/{png_filter => predictors}/06--32-1-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/07--32-3-8.data (100%) rename libtests/qtest/{png_filter => predictors}/07--32-3-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/08--32-1-8.data (100%) rename libtests/qtest/{png_filter => predictors}/08--32-1-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/09--32-3-8.data (100%) rename libtests/qtest/{png_filter => predictors}/09--32-3-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/10--32-1-8.data (100%) rename libtests/qtest/{png_filter => predictors}/10--32-1-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/11--32-3-8.data (100%) rename libtests/qtest/{png_filter => predictors}/11--32-3-8.decoded (100%) rename libtests/qtest/{png_filter => predictors}/12--32-1-4.data (100%) rename libtests/qtest/{png_filter => predictors}/12--32-1-4.decoded (100%) rename libtests/qtest/{png_filter => predictors}/in1 (100%) rename libtests/qtest/{png_filter => predictors}/in2 (100%) rename libtests/qtest/{png_filter => predictors}/out1 (100%) rename libtests/qtest/{png_filter => predictors}/out2 (100%) diff --git a/libtests/build.mk b/libtests/build.mk index baa34125..4579241d 100644 --- a/libtests/build.mk +++ b/libtests/build.mk @@ -11,8 +11,8 @@ BINS_libtests = \ input_source \ lzw \ md5 \ - png_filter \ pointer_holder \ + predictors \ qutil \ random \ rc4 \ diff --git a/libtests/png_filter.cc b/libtests/predictors.cc similarity index 56% rename from libtests/png_filter.cc rename to libtests/predictors.cc index 7494cb7a..fe2b90f4 100644 --- a/libtests/png_filter.cc +++ b/libtests/predictors.cc @@ -8,17 +8,26 @@ #include #include -void run(char const* filename, bool encode, unsigned int columns, +void run(char const* filename, char const* filter, + bool encode, unsigned int columns, int bits_per_sample, int samples_per_pixel) { - // Decode the file FILE* in = QUtil::safe_fopen(filename, "rb"); FILE* o1 = QUtil::safe_fopen("out", "wb"); Pipeline* out = new Pl_StdioFile("out", o1); - Pipeline* pl = new Pl_PNGFilter( - "png", out, - encode ? Pl_PNGFilter::a_encode : Pl_PNGFilter::a_decode, - columns, samples_per_pixel, bits_per_sample); + Pipeline* pl = 0; + if (strcmp(filter, "png") == 0) + { + pl = new Pl_PNGFilter( + "png", out, + encode ? Pl_PNGFilter::a_encode : Pl_PNGFilter::a_decode, + columns, samples_per_pixel, bits_per_sample); + } + else + { + std::cerr << "unknown filter " << filter << std::endl; + exit(2); + } assert((2 * (columns + 1)) < 1024); unsigned char buf[1024]; size_t len; @@ -55,22 +64,24 @@ void run(char const* filename, bool encode, unsigned int columns, int main(int argc, char* argv[]) { - if (argc != 6) + if (argc != 7) { - std::cerr << "Usage: png_filter {en,de}code filename" + std::cerr << "Usage: predictor {png|tiff} {en,de}code filename" << " columns samples-per-pixel bits-per-sample" << std::endl; exit(2); } - bool encode = (strcmp(argv[1], "encode") == 0); - char* filename = argv[2]; - int columns = QUtil::string_to_int(argv[3]); - int samples_per_pixel = QUtil::string_to_int(argv[4]); - int bits_per_sample = QUtil::string_to_int(argv[5]); + char* filter = argv[1]; + bool encode = (strcmp(argv[2], "encode") == 0); + char* filename = argv[3]; + int columns = QUtil::string_to_int(argv[4]); + int samples_per_pixel = QUtil::string_to_int(argv[5]); + int bits_per_sample = QUtil::string_to_int(argv[6]); try { - run(filename, encode, columns, bits_per_sample, samples_per_pixel); + run(filename, filter, encode, + columns, bits_per_sample, samples_per_pixel); } catch (std::exception& e) { diff --git a/libtests/qtest/png_filter.test b/libtests/qtest/predictors.test similarity index 82% rename from libtests/qtest/png_filter.test rename to libtests/qtest/predictors.test index ff3cef54..f0553472 100644 --- a/libtests/qtest/png_filter.test +++ b/libtests/qtest/predictors.test @@ -5,16 +5,16 @@ use strict; use File::Copy; use Digest::MD5; -chdir("png_filter") or die "chdir testdir failed: $!\n"; +chdir("predictors") or die "chdir testdir failed: $!\n"; require TestDriver; -my $td = new TestDriver('png_filter'); +my $td = new TestDriver('predictors'); cleanup(); $td->runtest("decode columns = 4", - {$td->COMMAND => "png_filter decode in1 4 1 8"}, + {$td->COMMAND => "predictors png decode in1 4 1 8"}, {$td->STRING => "done\n", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); @@ -24,7 +24,7 @@ $td->runtest("check output", {$td->FILE => "out1"}); $td->runtest("decode columns = 5", - {$td->COMMAND => "png_filter decode in2 5 1 8"}, + {$td->COMMAND => "predictors png decode in2 5 1 8"}, {$td->STRING => "done\n", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); @@ -34,7 +34,7 @@ $td->runtest("check output", {$td->FILE => "out2"}); $td->runtest("encode columns = 4", - {$td->COMMAND => "png_filter encode out1 4 1 8"}, + {$td->COMMAND => "predictors png encode out1 4 1 8"}, {$td->STRING => "done\n", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); @@ -44,7 +44,7 @@ $td->runtest("check output", {$td->FILE => "in1"}); $td->runtest("encode columns = 5", - {$td->COMMAND => "png_filter encode out2 5 1 8"}, + {$td->COMMAND => "predictors png encode out2 5 1 8"}, {$td->STRING => "done\n", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); @@ -75,7 +75,7 @@ foreach my $i (@other) my $samples_per_pixel = $2; my $bits_per_sample = $3; $td->runtest("decode $i", - {$td->COMMAND => "png_filter decode $i.data" . + {$td->COMMAND => "predictors png decode $i.data" . " $columns $samples_per_pixel $bits_per_sample"}, {$td->STRING => "done\n", $td->EXIT_STATUS => 0}, diff --git a/libtests/qtest/png_filter/01--32-3-16.data b/libtests/qtest/predictors/01--32-3-16.data similarity index 100% rename from libtests/qtest/png_filter/01--32-3-16.data rename to libtests/qtest/predictors/01--32-3-16.data diff --git a/libtests/qtest/png_filter/01--32-3-16.decoded b/libtests/qtest/predictors/01--32-3-16.decoded similarity index 100% rename from libtests/qtest/png_filter/01--32-3-16.decoded rename to libtests/qtest/predictors/01--32-3-16.decoded diff --git a/libtests/qtest/png_filter/02--32-1-8.data b/libtests/qtest/predictors/02--32-1-8.data similarity index 100% rename from libtests/qtest/png_filter/02--32-1-8.data rename to libtests/qtest/predictors/02--32-1-8.data diff --git a/libtests/qtest/png_filter/02--32-1-8.decoded b/libtests/qtest/predictors/02--32-1-8.decoded similarity index 100% rename from libtests/qtest/png_filter/02--32-1-8.decoded rename to libtests/qtest/predictors/02--32-1-8.decoded diff --git a/libtests/qtest/png_filter/03--32-3-8.data b/libtests/qtest/predictors/03--32-3-8.data similarity index 100% rename from libtests/qtest/png_filter/03--32-3-8.data rename to libtests/qtest/predictors/03--32-3-8.data diff --git a/libtests/qtest/png_filter/03--32-3-8.decoded b/libtests/qtest/predictors/03--32-3-8.decoded similarity index 100% rename from libtests/qtest/png_filter/03--32-3-8.decoded rename to libtests/qtest/predictors/03--32-3-8.decoded diff --git a/libtests/qtest/png_filter/04--32-1-8.data b/libtests/qtest/predictors/04--32-1-8.data similarity index 100% rename from libtests/qtest/png_filter/04--32-1-8.data rename to libtests/qtest/predictors/04--32-1-8.data diff --git a/libtests/qtest/png_filter/04--32-1-8.decoded b/libtests/qtest/predictors/04--32-1-8.decoded similarity index 100% rename from libtests/qtest/png_filter/04--32-1-8.decoded rename to libtests/qtest/predictors/04--32-1-8.decoded diff --git a/libtests/qtest/png_filter/05--32-3-8.data b/libtests/qtest/predictors/05--32-3-8.data similarity index 100% rename from libtests/qtest/png_filter/05--32-3-8.data rename to libtests/qtest/predictors/05--32-3-8.data diff --git a/libtests/qtest/png_filter/05--32-3-8.decoded b/libtests/qtest/predictors/05--32-3-8.decoded similarity index 100% rename from libtests/qtest/png_filter/05--32-3-8.decoded rename to libtests/qtest/predictors/05--32-3-8.decoded diff --git a/libtests/qtest/png_filter/06--32-1-8.data b/libtests/qtest/predictors/06--32-1-8.data similarity index 100% rename from libtests/qtest/png_filter/06--32-1-8.data rename to libtests/qtest/predictors/06--32-1-8.data diff --git a/libtests/qtest/png_filter/06--32-1-8.decoded b/libtests/qtest/predictors/06--32-1-8.decoded similarity index 100% rename from libtests/qtest/png_filter/06--32-1-8.decoded rename to libtests/qtest/predictors/06--32-1-8.decoded diff --git a/libtests/qtest/png_filter/07--32-3-8.data b/libtests/qtest/predictors/07--32-3-8.data similarity index 100% rename from libtests/qtest/png_filter/07--32-3-8.data rename to libtests/qtest/predictors/07--32-3-8.data diff --git a/libtests/qtest/png_filter/07--32-3-8.decoded b/libtests/qtest/predictors/07--32-3-8.decoded similarity index 100% rename from libtests/qtest/png_filter/07--32-3-8.decoded rename to libtests/qtest/predictors/07--32-3-8.decoded diff --git a/libtests/qtest/png_filter/08--32-1-8.data b/libtests/qtest/predictors/08--32-1-8.data similarity index 100% rename from libtests/qtest/png_filter/08--32-1-8.data rename to libtests/qtest/predictors/08--32-1-8.data diff --git a/libtests/qtest/png_filter/08--32-1-8.decoded b/libtests/qtest/predictors/08--32-1-8.decoded similarity index 100% rename from libtests/qtest/png_filter/08--32-1-8.decoded rename to libtests/qtest/predictors/08--32-1-8.decoded diff --git a/libtests/qtest/png_filter/09--32-3-8.data b/libtests/qtest/predictors/09--32-3-8.data similarity index 100% rename from libtests/qtest/png_filter/09--32-3-8.data rename to libtests/qtest/predictors/09--32-3-8.data diff --git a/libtests/qtest/png_filter/09--32-3-8.decoded b/libtests/qtest/predictors/09--32-3-8.decoded similarity index 100% rename from libtests/qtest/png_filter/09--32-3-8.decoded rename to libtests/qtest/predictors/09--32-3-8.decoded diff --git a/libtests/qtest/png_filter/10--32-1-8.data b/libtests/qtest/predictors/10--32-1-8.data similarity index 100% rename from libtests/qtest/png_filter/10--32-1-8.data rename to libtests/qtest/predictors/10--32-1-8.data diff --git a/libtests/qtest/png_filter/10--32-1-8.decoded b/libtests/qtest/predictors/10--32-1-8.decoded similarity index 100% rename from libtests/qtest/png_filter/10--32-1-8.decoded rename to libtests/qtest/predictors/10--32-1-8.decoded diff --git a/libtests/qtest/png_filter/11--32-3-8.data b/libtests/qtest/predictors/11--32-3-8.data similarity index 100% rename from libtests/qtest/png_filter/11--32-3-8.data rename to libtests/qtest/predictors/11--32-3-8.data diff --git a/libtests/qtest/png_filter/11--32-3-8.decoded b/libtests/qtest/predictors/11--32-3-8.decoded similarity index 100% rename from libtests/qtest/png_filter/11--32-3-8.decoded rename to libtests/qtest/predictors/11--32-3-8.decoded diff --git a/libtests/qtest/png_filter/12--32-1-4.data b/libtests/qtest/predictors/12--32-1-4.data similarity index 100% rename from libtests/qtest/png_filter/12--32-1-4.data rename to libtests/qtest/predictors/12--32-1-4.data diff --git a/libtests/qtest/png_filter/12--32-1-4.decoded b/libtests/qtest/predictors/12--32-1-4.decoded similarity index 100% rename from libtests/qtest/png_filter/12--32-1-4.decoded rename to libtests/qtest/predictors/12--32-1-4.decoded diff --git a/libtests/qtest/png_filter/in1 b/libtests/qtest/predictors/in1 similarity index 100% rename from libtests/qtest/png_filter/in1 rename to libtests/qtest/predictors/in1 diff --git a/libtests/qtest/png_filter/in2 b/libtests/qtest/predictors/in2 similarity index 100% rename from libtests/qtest/png_filter/in2 rename to libtests/qtest/predictors/in2 diff --git a/libtests/qtest/png_filter/out1 b/libtests/qtest/predictors/out1 similarity index 100% rename from libtests/qtest/png_filter/out1 rename to libtests/qtest/predictors/out1 diff --git a/libtests/qtest/png_filter/out2 b/libtests/qtest/predictors/out2 similarity index 100% rename from libtests/qtest/png_filter/out2 rename to libtests/qtest/predictors/out2