summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2017-07-17 21:45:54 +0200
committerDidier Raboud <odyx@debian.org>2017-07-17 21:45:54 +0200
commit337ffefc0bdf252749c81ebb9255556d54c3e632 (patch)
tree5d769771acb1ce6b14d5be80ca7775c2d279b404 /test
parentaedf3e93e811c6c9d504274172861d266e1c5c97 (diff)
New upstream version 5.2.13
Diffstat (limited to 'test')
-rw-r--r--test/bjc-unprint.c7
-rw-r--r--test/curve.c2
-rw-r--r--test/escp2-weavetest.c2
-rw-r--r--test/gen-printer-list.c1
-rwxr-xr-xtest/parse-escp21
-rw-r--r--test/pixma_parse.c105
-rw-r--r--test/pixma_parse.h6
7 files changed, 71 insertions, 53 deletions
diff --git a/test/bjc-unprint.c b/test/bjc-unprint.c
index bb1d070..182e686 100644
--- a/test/bjc-unprint.c
+++ b/test/bjc-unprint.c
@@ -62,7 +62,7 @@ typedef struct bitimage_t_ {
} bitimage_t;
typedef struct level_t_ {
- /* Max number of bits per ink so far known is 8
+ /* Max number of bits per ink so far known is 8
Thus max number of levels is 256 (including value 0)
*/
int levelvals[256]; /* number of occurrences of each level */
@@ -176,8 +176,8 @@ int rle_decode(unsigned char *inbuf, int n, unsigned char *outbuf,int max, level
int o= 0;
int i=0,j,num;
- /* Results of the decoding are in the output buffer already.
- We want to organize the decoded numbers to see
+ /* Results of the decoding are in the output buffer already.
+ We want to organize the decoded numbers to see
the total number of levels, and their values.
*/
/*fprintf(stderr,"rle_decode: decoding scanline\n");*/
@@ -553,4 +553,3 @@ int main(int argc, char **argv)
return 0;
}
-
diff --git a/test/curve.c b/test/curve.c
index 405ae7b..4a643de 100644
--- a/test/curve.c
+++ b/test/curve.c
@@ -232,7 +232,7 @@ static const stp_curve_point_t reverse_piecewise_sat_adjustment[] =
{ 1.00, 2},
};
-const char *small_piecewise_curve =
+const char *small_piecewise_curve =
"<?xml version=\"1.0\"?>\n"
"<gutenprint xmlns=\"http://gimp-print.sourceforge.net/xsd/gp.xsd-1.0\"\n"
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
diff --git a/test/escp2-weavetest.c b/test/escp2-weavetest.c
index ad6eb03..4c57d4e 100644
--- a/test/escp2-weavetest.c
+++ b/test/escp2-weavetest.c
@@ -397,7 +397,7 @@ run_weavetest_from_stdin(void)
{
/* Assume that we're running within run-weavetest, and */
/* print out the heartbeat */
-
+
if (previous_strategy != strategy)
{
printf("%s%d:", previous_strategy == -1 ? "" : "\n", strategy);
diff --git a/test/gen-printer-list.c b/test/gen-printer-list.c
index 679856c..5eb8047 100644
--- a/test/gen-printer-list.c
+++ b/test/gen-printer-list.c
@@ -48,4 +48,3 @@ main(int argc, char **argv)
}
return 0;
}
-
diff --git a/test/parse-escp2 b/test/parse-escp2
index a0ce69f..abe6ae5 100755
--- a/test/parse-escp2
+++ b/test/parse-escp2
@@ -589,4 +589,3 @@ while (! $atend) {
}
print "\n" if $curpos > 1;
-
diff --git a/test/pixma_parse.c b/test/pixma_parse.c
index 872a7cd..19ec8e2 100644
--- a/test/pixma_parse.c
+++ b/test/pixma_parse.c
@@ -1,5 +1,5 @@
/******************************************************************************
- * pixma_parse.c parser for Canon BJL printjobs
+ * pixma_parse.c parser for Canon BJL printjobs
* Copyright (c) 2005 - 2007 Sascha Sommer <saschasommer@freenet.de>.
*
* This program is free software; you can redistribute it and/or modify
@@ -30,7 +30,7 @@
#include "pixma_parse.h"
-/*TODO:
+/*TODO:
1. change color loops to search for each named color rather than using a predefined order.
2. keep iP6700 workaround, but check what happens with the real printer.
*/
@@ -40,7 +40,7 @@ FILE* fout;
/* nextcmd(): find a command in a printjob
* commands in the printjob start with either ESC[ or ESC(
- * ESC@ (go to neutral mode) and 0xc (form feed) are handled directly
+ * ESC@ (go to neutral mode) and 0xc (form feed) are handled directly
* params:
* infile: handle to the printjob
* cmd: the command type
@@ -52,7 +52,7 @@ FILE* fout;
* 1 when EOF has been reached
* -1 when an error occurred
*/
-static int nextcmd( FILE *infile,unsigned char* cmd,unsigned char *buf, unsigned int *cnt, unsigned int *xml_read)
+static int nextcmd( FILE *infile,unsigned char* cmd,unsigned char *buf, unsigned int *cnt, unsigned int *xml_read,unsigned int startxmllen,unsigned int endxmllen)
{
unsigned char c1,c2;
unsigned int startxml, endxml;
@@ -66,14 +66,14 @@ static int nextcmd( FILE *infile,unsigned char* cmd,unsigned char *buf, unsigned
if (c1 == 60 ){ /* "<" for XML start */
if (*xml_read==0){
/* start */
- startxml=680-1;
- fread(buf,1,startxml,infile); /* 1 less than 680 */
+ startxml=startxmllen-1;
+ fread(buf,1,startxml,infile); /* 1 less than startxmllen */
fprintf(fout,"nextcmd: read starting XML %d %d\n", *xml_read, startxml);
*xml_read=1;
}else if (*xml_read==1) {
/* end */
- endxml=263-1;
- fread(buf,1,endxml,infile); /* 1 less than 263*/
+ endxml=endxmllen-1;
+ fread(buf,1,endxml,infile); /* 1 less than endxmllen */
fprintf(fout,"nextcmd: read ending XML %d %d\n", *xml_read, endxml);
*xml_read=2;
}
@@ -146,7 +146,7 @@ static int valid_color(unsigned char color){
}
-/* eight2ten()
+/* eight2ten()
* decompression routine for canons 10to8 compression that stores 5 3-valued pixels in 8-bit
*/
static int eight2ten(unsigned char* inbuffer,unsigned char* outbuffer,int num_bytes,int outbuffer_size){
@@ -249,7 +249,7 @@ static int Raster(image_t* img,unsigned char* buffer,unsigned int len,unsigned c
#endif
/* if(!color){
- printf("no matching color for %c (0x%x, %i) in the database => ignoring %i bytes\n",color_name,color_name,color_name, len);
+ printf("no matching color for %c (0x%x, %i) in the database => ignoring %i bytes\n",color_name,color_name,color_name, len);
} */
if (DEBUG) {
fprintf(fout,"DEBUG enter Raster len=%i,color=%c\n",len,color_name);
@@ -260,9 +260,9 @@ static int Raster(image_t* img,unsigned char* buffer,unsigned int len,unsigned c
int c = *buf;
++buf;
--len;
-
+
/*printf("DEBUG top of while loop len=%i\n",len);*/
-
+
if(c >= 128)
c -=256;
if(c== -128){ /* end of line => decode and copy things here */
@@ -471,7 +471,7 @@ static void write_line(image_t*img,FILE* fp,int pos_y){
}
/* update statistics */
(img->color[i].dots)[img->color[i].value] += 1;
- /* set to 1 if the level is used */
+ /* set to 1 if the level is used */
(img->color[i].usedlevels)[img->color[i].value]=1;
}
/* calculate CMYK values */
@@ -497,7 +497,7 @@ static void write_line(image_t*img,FILE* fp,int pos_y){
if(x > img->image_right)
img->image_right = x;
}
-
+
/* clip values */
if(lK > 255)
lK = 255;
@@ -509,9 +509,9 @@ static void write_line(image_t*img,FILE* fp,int pos_y){
lY = 255;
/* convert to RGB */
/* 0 == black, 255 == white */
- line[x*3]=255 - lC - lK;
- line[x*3+1]=255 - lM -lK;
- line[x*3+2]=255 - lY -lK;
+ line[x*3]=255 - lC - lK;
+ line[x*3+1]=255 - lM -lK;
+ line[x*3+2]=255 - lY -lK;
++img->dots;
}
@@ -530,11 +530,11 @@ static void write_ppm(image_t* img,FILE* fp){
for(i=0;i<MAX_COLORS;i++){
/*img->color[i].dots=calloc(1,sizeof(int)*(img->color[i].level+1));*/
img->color[i].dots=calloc(1,sizeof(int)*(1<<((img->color[i].bpp)+1)));
- }
+ }
/* allocate buffers for levels used*/
for(i=0;i<MAX_COLORS;i++){
img->color[i].usedlevels=calloc(1,sizeof(int)*(1<<((img->color[i].bpp)+1)));
- }
+ }
/* write header */
fputs("P6\n", fp);
@@ -547,7 +547,7 @@ static void write_ppm(image_t* img,FILE* fp){
for(i=0;i<img->height;i++){
write_line(img,fp,i);
}
-
+
/* output some statistics */
printf("statistics:\n");
for(i=0;i<MAX_COLORS;i++){
@@ -574,13 +574,13 @@ static void write_ppm(image_t* img,FILE* fp){
img->image_left = img->image_left * 72.0 / img->xres ;
img->image_right = img->image_right * 72.0 / img->xres ;
printf("top %u bottom %u left %u right %u\n",img->image_top,img->image_bottom,img->image_left,img->image_right);
- printf("width %u height %u\n",img->image_right - img->image_left,img->image_bottom - img->image_top);
+ printf("width %u height %u\n",img->image_right - img->image_left,img->image_bottom - img->image_top);
/* clean up */
for(i=0;i<MAX_COLORS;i++){
if(img->color[i].dots)
free(img->color[i].dots);
- }
+ }
}
@@ -591,7 +591,7 @@ static unsigned int read_uint32(unsigned char* a){
/* process a printjob command by command */
-static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned int maxh){
+static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned int maxh,unsigned int startxmllen,unsigned int endxmllen){
image_t* img=calloc(1,sizeof(image_t));
unsigned char* buf=malloc(0xFFFF);
int returnv=0;
@@ -604,7 +604,7 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
while(!returnv && !feof(in)){
unsigned char cmd;
unsigned int cnt = 0;
- if((returnv = nextcmd(in,&cmd,buf,&cnt,&xml_read)))
+ if((returnv = nextcmd(in,&cmd,buf,&cnt,&xml_read,startxmllen,endxmllen)))
break;
switch(cmd){
case 'c':
@@ -694,12 +694,12 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
}
for(i=0;i<num_colors;i++){
- if(i<MAX_COLORS){
+ if(i<MAX_COLORS){
img->color[i].name=order[i];
img->color[i].compression=buf[3+i*3] >> 5;
img->color[i].bpp=buf[3+i*3] & 31;
img->color[i].level=(buf[3+i*3+1] << 8) + buf[3+i*3+2];/* check this carefully */
-
+
/* work around for levels not matching (bpp gives more) */
/*if ((img->color[i].level == 3) && (img->color[i].bpp == 2)) {
printf("WARNING: color %c bpp %i declared levels %i, setting to 4 for testing \n",img->color[i].name,img->color[i].bpp,img->color[i].level);
@@ -710,7 +710,7 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
/* printf("WARNING: color %c bpp %i declared levels %i, setting to 16 for testing \n",img->color[i].name,img->color[i].bpp,img->color[i].level);
img->color[i].level = 16;
} */
-
+
/* this is not supposed to give accurate images */
/* if(i<4) */ /* set to actual colors CMYK */
if((img->color[i].name =='K')||(img->color[i].name =='C')||(img->color[i].name =='M')||(img->color[i].name =='Y') ) {
@@ -718,7 +718,7 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
/*if (i>7)*/
/*img->color[i].density -= 128; */
/* see if can subtract something from CMYK where 0x80 involved */
- }
+ }
else
img->color[i].density = 128; /*128+96;*/ /* try to add 0x80 to sub-channels for MP450 hi-quality mode */
/*
@@ -733,7 +733,7 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
order[i+1] = 'y';
black_found = 1;
img->color[i].density = 255;
- }
+ }
*/
/* %c*/
fprintf(fout," Color %c Compression: %i bpp %i level %i\n",img->color[i].name,
@@ -742,17 +742,17 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
fprintf(fout," Color %i out of bounds!\n", i);
/*printf(" Color ignoring setting %x %x %x\n",buf[3+i*3],buf[3+i*3+1],buf[3+i*3+2]);*/
}
-
+
}
-
-
+
+
}else if(buf[0]==0x1 && buf[1]==0x0 && buf[2]==0x1){
- fprintf(fout," 1bit-per pixel\n");
+ fprintf(fout," 1bit-per pixel\n");
num_colors = cnt*3; /*no idea yet! 3 for iP4000 */
/*num_colors=9;*/
/*for(i=0;i<MAX_COLORS;i++){*/
for(i=0;i<num_colors;i++){
- if(i<MAX_COLORS){
+ if(i<MAX_COLORS){
/* usual */
char order[]="CMYKcmyk";
/* const char order[]="CMYKcmykHRGABDEFIJLMNOPQSTUVWXZabdef";*/
@@ -878,7 +878,7 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
if(img->lines_per_block){
img->height += (buf[0]*256+buf[1])*img->lines_per_block;
img->cur_color=0;
- }else
+ }else
img->height += (buf[0]*256+buf[1]);
break;
default: /* Last but not least completely unknown commands */
@@ -894,7 +894,7 @@ static int process(FILE* in, FILE* out,int verbose,unsigned int maxw,unsigned in
if(returnv < -2){ /* was < 0 : work around to see what we get */
fprintf(fout,"error: parsing the printjob failed error %i\n",returnv);
} else {
-
+
fprintf(fout,"created bit image with width %i height %i\n",img->width,img->height);
if(maxh > 0){
fprintf(fout,"limiting height to %u\n",maxh);
@@ -936,6 +936,8 @@ static void display_usage(void){
printf(" -v: verbose print ESC e),F) and A) commands\n");
printf(" -x width: cut the output ppm to the given width\n");
printf(" -y height: cut the output ppm to the given height\n");
+ printf(" -s if XML prolog is present, define number of bytes (default 680) \n");
+ printf(" -e if XML epilog is present, define number of bytes (default 263) \n");
printf(" -h: display this help\n");
}
@@ -945,15 +947,20 @@ int main(int argc,char* argv[]){
int verbose = 0;
unsigned int maxh=0;
unsigned int maxw=0;
+ unsigned int startxmllen, endxmllen;
+
char* filename_in=NULL,*filename_out=NULL;
FILE *in,*out=NULL;
int i;
+ startxmllen=680; // 1086; 732; 680; embedded parameters varies with driver -- TODO: parse XML separately
+ endxmllen=263; // default value
+
if (DEBUG)
fout = stderr; /* unbuffered */
else
fout = stdout; /* buffered */
-
+
printf("pixma_parse - parser for Canon BJL printjobs (c) 2005-2007 Sascha Sommer <saschasommer@freenet.de>\n");
/* parse args */
@@ -963,7 +970,7 @@ int main(int argc,char* argv[]){
verbose = 1;
}else if(argv[i][1] == 'h'){
display_usage();
- return 0;
+ return 0;
}else if(argv[i][1] == 'y'){
if(argc > i+1){
++i;
@@ -980,6 +987,22 @@ int main(int argc,char* argv[]){
display_usage();
return 1;
}
+ }else if(argv[i][1] == 's'){
+ if(argc > i+1){
+ ++i;
+ startxmllen = atoi(argv[i]);
+ }else{
+ display_usage();
+ return 1;
+ }
+ }else if(argv[i][1] == 'e'){
+ if(argc > i+1){
+ ++i;
+ endxmllen = atoi(argv[i]);
+ }else{
+ display_usage();
+ return 1;
+ }
}else {
printf("unknown parameter %s\n",argv[i]);
return 1;
@@ -1010,13 +1033,13 @@ int main(int argc,char* argv[]){
fclose(in);
return 1;
}
-
+
/* process the printjob */
- process(in,out,verbose,maxw,maxh);
+ process(in,out,verbose,maxw,maxh,startxmllen,endxmllen);
/* cleanup */
fclose(in);
if(out)
fclose(out);
return 0;
-}
+}
diff --git a/test/pixma_parse.h b/test/pixma_parse.h
index 0eda3c0..84dcf85 100644
--- a/test/pixma_parse.h
+++ b/test/pixma_parse.h
@@ -37,7 +37,7 @@
/* Bitstream reader from FFmpeg (http://www.ffmpeg.org)
* libavcodec/bitstream.h
- *
+ *
*/
typedef struct PutBitContext {
@@ -62,7 +62,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
/* printf("put_bits=%d %x\n", n, value); */
-
+
bit_buf = s->bit_buf;
bit_left = s->bit_left;
@@ -302,5 +302,3 @@ typedef struct image_s {
/* static const unsigned char valid_colors[] = {'C','M','Y','K','c','m','y','k',0xa3,0xad}; */
static const unsigned char valid_colors[] = {'C','M','Y','K','c','m','y','k','R','G','H','A','B','D','E','F','I','J','L','M','N','O','P','Q','S','T','U','V','W','X','Z','a','b','d','e','f'};
#endif
-
-