{
png_set_packing(png);
}
- // printf("%s:%d:sgnd(%d,%d,%d) w(%d) h(%d) alpha(%d)\n",__FILE__,__LINE__,
- //image->comps[0].sgnd,
- //image->comps[1].sgnd,image->comps[2].sgnd,width,height,has_alpha);
+ /*
+ printf("%s:%d:sgnd(%d,%d,%d) w(%d) h(%d) alpha(%d)\n",__FILE__,__LINE__,
+ image->comps[0].sgnd,
+ image->comps[1].sgnd,image->comps[2].sgnd,width,height,has_alpha);
+ */
adjustR = (image->comps[0].sgnd ? 1 << (image->comps[0].prec - 1) : 0);
adjustG = (image->comps[1].sgnd ? 1 << (image->comps[1].prec - 1) : 0);
opj_codec_t* l_codec = 00;
opj_image_t *image = NULL;
raw_cparameters_t raw_cp;
- OPJ_SIZE_T num_compressed_files = 0;
+ OPJ_SIZE_T num_compressed_files = 0;
char indexfilename[OPJ_PATH_LEN]; /* index file name */
OPJ_BOOL bSuccess;
OPJ_BOOL bUseTiles = OPJ_FALSE; /* OPJ_TRUE */
OPJ_UINT32 l_nb_tiles = 4;
- OPJ_FLOAT64 t = opj_clock();
+ OPJ_FLOAT64 t = opj_clock();
/* set encoding parameters to default values */
opj_set_default_encoder_parameters(¶meters);
if(parameters.cp_matrice) free(parameters.cp_matrice);
if(raw_cp.rawComps) free(raw_cp.rawComps);
- t = opj_clock() - t;
- if (num_compressed_files)
- fprintf(stdout, "encode time: %d ms \n", (int)((t * 1000)/num_compressed_files));
- //getch());
+ t = opj_clock() - t;
+ if (num_compressed_files) {
+ fprintf(stdout, "encode time: %d ms \n", (int)((t * 1000.0)/(OPJ_FLOAT64)num_compressed_files));
+ }
return 0;
}
" Image file Directory path \n"
" -OutFor <PBM|PGM|PPM|PNM|PAM|PGX|PNG|BMP|TIF|RAW|RAWL|TGA>\n"
" REQUIRED only if -ImgDir is used\n"
- " Output format for decompressed images.\n"
- " -i <compressed file>\n"
+ " Output format for decompressed images.\n");
+ fprintf(stdout," -i <compressed file>\n"
" REQUIRED only if an Input image directory is not specified\n"
" Currently accepts J2K-files, JP2-files and JPT-files. The file type\n"
- " is identified based on its suffix.\n"
- " -o <decompressed file>\n"
+ " is identified based on its suffix.\n");
+ fprintf(stdout," -o <decompressed file>\n"
" REQUIRED\n"
" Currently accepts formats specified above (see OutFor option)\n"
" Binary data is written to the file (not ascii). If a PGX\n"
" components: an indice starting from 0 will then be appended to the\n"
" output filename, just before the \"pgx\" extension. If a PGM filename\n"
" is given and there are more than one component, only the first component\n"
- " will be written to the file.\n"
- " -r <reduce factor>\n"
+ " will be written to the file.\n");
+ fprintf(stdout," -r <reduce factor>\n"
" Set the number of highest resolution levels to be discarded. The\n"
" image resolution is effectively divided by 2 to the power of the\n"
" number of discarded levels. The reduce factor is limited by the\n"
" -l <number of quality layers to decode>\n"
" Set the maximum number of quality layers to decode. If there are\n"
" less quality layers than the specified number, all the quality layers\n"
- " are decoded.\n"
- " -x \n"
+ " are decoded.\n");
+ fprintf(stdout," -x \n"
" Create an index file *.Idx (-x index_name.Idx) \n"
" -d <x0,y0,x1,y1>\n"
" OPTIONAL\n"
" -t <tile_number>\n"
" OPTIONAL\n"
" Set the tile number of the decoded tile. Follow the JPEG2000 convention from left-up to bottom-up\n"
- " By default all tiles are decoded.\n"
- " -p <comp 0 precision>[C|S][,<comp 1 precision>[C|S][,...]]\n"
+ " By default all tiles are decoded.\n");
+ fprintf(stdout," -p <comp 0 precision>[C|S][,<comp 1 precision>[C|S][,...]]\n"
" OPTIONAL\n"
" Force the precision (bit depth) of components.\n"
" There shall be at least 1 value. Theres no limit on the number of values (comma separated, last values ignored if too much values).\n"
for(;;)
{
- OPJ_UINT32 prec;
+ int prec;
char mode;
char comma;
int count;
count = 3;
}
if (count == 3) {
- if (prec > 32U) {
+ if ((prec < 1) || (prec > 32)) {
fprintf(stderr,"Invalid precision %d in precision option %s\n", prec, option);
l_result = OPJ_FALSE;
break;
parameters->precision = l_new;
}
- parameters->precision[parameters->nb_precision].prec = prec;
+ parameters->precision[parameters->nb_precision].prec = (OPJ_UINT32)prec;
switch (mode) {
case 'C':
parameters->precision[parameters->nb_precision].mode = OPJ_PREC_MODE_CLIP;
if(failed) remove(parameters.outfile);
}
destroy_parameters(¶meters);
- if (numDecompressedImages)
- fprintf(stdout, "decode time: %d ms \n", (int)( (tCumulative * 1000) / numDecompressedImages));
- //getch();
+ if (numDecompressedImages) {
+ fprintf(stdout, "decode time: %d ms\n", (int)( (tCumulative * 1000.0) / (OPJ_FLOAT64)numDecompressedImages));
+ }
return failed ? EXIT_FAILURE : EXIT_SUCCESS;
}
/*end main*/