mirror of
https://github.com/qpdf/qpdf.git
synced 2025-01-30 18:38:52 +00:00
Rename png_filter -> predictors
This commit is contained in:
parent
661ed1d28e
commit
bf2fb239d7
@ -11,8 +11,8 @@ BINS_libtests = \
|
||||
input_source \
|
||||
lzw \
|
||||
md5 \
|
||||
png_filter \
|
||||
pointer_holder \
|
||||
predictors \
|
||||
qutil \
|
||||
random \
|
||||
rc4 \
|
||||
|
@ -8,17 +8,26 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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)
|
||||
{
|
@ -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},
|
Loading…
x
Reference in New Issue
Block a user