fprintf correctly redirected to stderr or stdout

This commit is contained in:
Francois-Olivier Devaux
2004-11-15 12:41:35 +00:00
parent 0a879e2207
commit 1bdb07cefe
7 changed files with 508 additions and 358 deletions

View File

@@ -56,152 +56,152 @@
void help_display()
{
printf("HELP\n----\n\n");
printf("- the -h option displays this help information on screen\n\n");
fprintf(stdout,"HELP\n----\n\n");
fprintf(stdout,"- the -h option displays this help information on screen\n\n");
printf("List of parameters for the coder JPEG 2000:\n");
printf("\n");
printf("REMARKS:\n");
printf("---------\n");
printf("\n");
printf
("The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
printf
("COD and QCD never appear in the tile_header.\n");
printf("\n");
printf
("- This coder can encode a mega image, a test was made on a 24000x24000 pixels \n");
printf
("color image. You need enough disk space memory (twice the original) to encode \n");
printf
("the image,i.e. for a 1.5 GB image you need a minimum of 3GB of disk memory)\n");
printf("\n");
printf("By default:\n");
printf("------------\n");
printf("\n");
printf(" * Lossless\n");
printf(" * 1 tile\n");
printf(" * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
printf(" * Size of code-block : 64 x 64\n");
printf(" * Number of resolutions: 6\n");
printf(" * No SOP marker in the codestream\n");
printf(" * No EPH marker in the codestream\n");
printf(" * No sub-sampling in x or y direction\n");
printf(" * No mode switch activated\n");
printf(" * Progression order: LRCP\n");
printf(" * No index file\n");
printf(" * No ROI upshifted\n");
printf(" * No offset of the origin of the image\n");
printf(" * No offset of the origin of the tiles\n");
printf(" * Reversible DWT 5-3\n");
printf("\n");
printf("Parameters:\n");
printf("------------\n");
printf("\n");
printf
("Required Parameters (except with -h):\n");
printf("\n");
printf
("-i : source file (-i source.pnm also *.pgm, *.ppm) \n");
printf("\n");
printf
("-o : destination file (-o dest.j2k or .jp2) \n");
printf("\n");
printf
("Optional Parameters:\n");
printf("\n");
printf("-h : display the help information \n ");
printf("\n");
printf("-r : different compression ratios for successive layers (-r 20,10,5)\n ");
printf(" - The rate specified for each quality level is the desired \n");
printf(" compression factor.\n");
printf(" Example: -r 20,10,1 means quality 1: compress 20x, \n");
printf(" quality 2: compress 10x and quality 3: compress lossless\n");
printf("\n");
printf(" (options -r and -q cannot be used together)\n ");
printf("\n");
fprintf(stdout,"List of parameters for the coder JPEG 2000:\n");
fprintf(stdout,"\n");
fprintf(stdout,"REMARKS:\n");
fprintf(stdout,"---------\n");
fprintf(stdout,"\n");
fprintf
(stdout,"The markers written to the main_header are : SOC SIZ COD QCD COM.\n");
fprintf
(stdout,"COD and QCD never appear in the tile_header.\n");
fprintf(stdout,"\n");
fprintf
(stdout,"- This coder can encode a mega image, a test was made on a 24000x24000 pixels \n");
fprintf
(stdout,"color image. You need enough disk space memory (twice the original) to encode \n");
fprintf
(stdout,"the image,i.e. for a 1.5 GB image you need a minimum of 3GB of disk memory)\n");
fprintf(stdout,"\n");
fprintf(stdout,"By default:\n");
fprintf(stdout,"------------\n");
fprintf(stdout,"\n");
fprintf(stdout," * Lossless\n");
fprintf(stdout," * 1 tile\n");
fprintf(stdout," * Size of precinct : 2^15 x 2^15 (means 1 precinct)\n");
fprintf(stdout," * Size of code-block : 64 x 64\n");
fprintf(stdout," * Number of resolutions: 6\n");
fprintf(stdout," * No SOP marker in the codestream\n");
fprintf(stdout," * No EPH marker in the codestream\n");
fprintf(stdout," * No sub-sampling in x or y direction\n");
fprintf(stdout," * No mode switch activated\n");
fprintf(stdout," * Progression order: LRCP\n");
fprintf(stdout," * No index file\n");
fprintf(stdout," * No ROI upshifted\n");
fprintf(stdout," * No offset of the origin of the image\n");
fprintf(stdout," * No offset of the origin of the tiles\n");
fprintf(stdout," * Reversible DWT 5-3\n");
fprintf(stdout,"\n");
fprintf(stdout,"Parameters:\n");
fprintf(stdout,"------------\n");
fprintf(stdout,"\n");
fprintf
(stdout,"Required Parameters (except with -h):\n");
fprintf(stdout,"\n");
fprintf
(stdout,"-i : source file (-i source.pnm also *.pgm, *.ppm) \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-o : destination file (-o dest.j2k or .jp2) \n");
fprintf(stdout,"\n");
fprintf
(stdout,"Optional Parameters:\n");
fprintf(stdout,"\n");
fprintf(stdout,"-h : display the help information \n ");
fprintf(stdout,"\n");
fprintf(stdout,"-r : different compression ratios for successive layers (-r 20,10,5)\n ");
fprintf(stdout," - The rate specified for each quality level is the desired \n");
fprintf(stdout," compression factor.\n");
fprintf(stdout," Example: -r 20,10,1 means quality 1: compress 20x, \n");
fprintf(stdout," quality 2: compress 10x and quality 3: compress lossless\n");
fprintf(stdout,"\n");
fprintf(stdout," (options -r and -q cannot be used together)\n ");
fprintf(stdout,"\n");
printf("-q : different psnr for successive layers (-q 30,40,50) \n ");
fprintf(stdout,"-q : different psnr for successive layers (-q 30,40,50) \n ");
printf(" (options -r and -q cannot be used together)\n ");
fprintf(stdout," (options -r and -q cannot be used together)\n ");
printf("\n");
printf("-n : number of resolutions (-n 3) \n");
printf("\n");
printf("-b : size of code block (-b 32,32) \n");
printf("\n");
printf("-c : size of precinct (-c 128,128) \n");
printf("\n");
printf("-t : size of tile (-t 512,512) \n");
printf("\n");
printf
("-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
printf("\n");
printf
("-s : subsampling factor (-s 2,2) [-s X,Y] \n");
printf(" Remark: subsampling bigger than 2 can produce error\n");
printf("\n");
printf
("-SOP : write SOP marker before each packet \n");
printf("\n");
printf
("-EPH : write EPH marker after each header packet \n");
printf("\n");
printf
("-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
printf
(" 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
printf
(" Indicate multiple modes by adding their values. \n");
printf
(" ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
printf("\n");
printf
("-x : create an index file *.Idx (-x index_name.Idx) \n");
printf("\n");
printf
("-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
printf
(" for component c=%%d [%%d = 0,1,2]\n");
printf
(" with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
printf("\n");
printf
("-d : offset of the origin of the image (-d 150,300) \n");
printf("\n");
printf
("-T : offset of the origin of the tiles (-T 100,75) \n");
printf("\n");
printf("-I : use the irreversible DWT 9-7 (-I) \n");
printf("\n");
printf("IMPORTANT:\n");
printf("-----------\n");
printf("\n");
printf("The index file has the structure below:\n");
printf("---------------------------------------\n");
printf("\n");
printf("Image_height Image_width\n");
printf("progression order\n");
printf("Tiles_size_X Tiles_size_Y\n");
printf("Components_nb\n");
printf("Layers_nb\n");
printf("decomposition_levels\n");
printf("[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
printf(" [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
printf("Main_header_end_position\n");
printf("Codestream_size\n");
printf("Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
printf("Tile_1 '' '' '' '' '' ''\n");
printf("...\n");
printf("Tile_Nt '' '' '' '' '' ''\n");
printf("Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
printf("...\n");
printf("Tpacket_Np '' '' '' '' '' '' '' ''\n");
fprintf(stdout,"\n");
fprintf(stdout,"-n : number of resolutions (-n 3) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-b : size of code block (-b 32,32) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-c : size of precinct (-c 128,128) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-t : size of tile (-t 512,512) \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-p : progression order (-p LRCP) [LRCP, RLCP, RPCL, PCRL, CPRL] \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-s : subsampling factor (-s 2,2) [-s X,Y] \n");
fprintf(stdout," Remark: subsampling bigger than 2 can produce error\n");
fprintf(stdout,"\n");
fprintf
(stdout,"-SOP : write SOP marker before each packet \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-EPH : write EPH marker after each header packet \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-M : mode switch (-M 3) [1=BYPASS(LAZY) 2=RESET 4=RESTART(TERMALL)\n");
fprintf
(stdout," 8=VSC 16=ERTERM(SEGTERM) 32=SEGMARK(SEGSYM)] \n");
fprintf
(stdout," Indicate multiple modes by adding their values. \n");
fprintf
(stdout," ex: RESTART(4) + RESET(2) + SEGMARK(32) = -M 38\n");
fprintf(stdout,"\n");
fprintf
(stdout,"-x : create an index file *.Idx (-x index_name.Idx) \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-ROI : c=%%d,U=%%d : quantization indices upshifted \n");
fprintf
(stdout," for component c=%%d [%%d = 0,1,2]\n");
fprintf
(stdout," with a value of U=%%d [0 <= %%d <= 37] (i.e. -ROI:c=0,U=25) \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-d : offset of the origin of the image (-d 150,300) \n");
fprintf(stdout,"\n");
fprintf
(stdout,"-T : offset of the origin of the tiles (-T 100,75) \n");
fprintf(stdout,"\n");
fprintf(stdout,"-I : use the irreversible DWT 9-7 (-I) \n");
fprintf(stdout,"\n");
fprintf(stdout,"IMPORTANT:\n");
fprintf(stdout,"-----------\n");
fprintf(stdout,"\n");
fprintf(stdout,"The index file has the structure below:\n");
fprintf(stdout,"---------------------------------------\n");
fprintf(stdout,"\n");
fprintf(stdout,"Image_height Image_width\n");
fprintf(stdout,"progression order\n");
fprintf(stdout,"Tiles_size_X Tiles_size_Y\n");
fprintf(stdout,"Components_nb\n");
fprintf(stdout,"Layers_nb\n");
fprintf(stdout,"decomposition_levels\n");
fprintf(stdout,"[Precincts_size_X_res_Nr Precincts_size_Y_res_Nr]...\n");
fprintf(stdout," [Precincts_size_X_res_0 Precincts_size_Y_res_0]\n");
fprintf(stdout,"Main_header_end_position\n");
fprintf(stdout,"Codestream_size\n");
fprintf(stdout,"Tile_0 start_pos end_Theader end_pos TotalDisto NumPix MaxMSE\n");
fprintf(stdout,"Tile_1 '' '' '' '' '' ''\n");
fprintf(stdout,"...\n");
fprintf(stdout,"Tile_Nt '' '' '' '' '' ''\n");
fprintf(stdout,"Tpacket_0 Tile layer res. comp. prec. start_pos end_pos disto\n");
fprintf(stdout,"...\n");
fprintf(stdout,"Tpacket_Np '' '' '' '' '' '' '' ''\n");
printf("MaxDisto\n");
fprintf(stdout,"MaxDisto\n");
printf("TotalDisto\n\n");
fprintf(stdout,"TotalDisto\n\n");
}
int give_progression(char progression[4])