fprintf(stdout, " -threads <num_threads>\n"
" Number of threads to use for decoding.\n");
}
+ fprintf(stdout, " -quiet\n"
+ " Disable output from the library and other output.\n");
/* UniPG>> */
#ifdef USE_JPWL
fprintf(stdout, " -W <options>\n"
};
parameters->jpwl_correct = OPJ_TRUE;
if (!(parameter->quiet)) {
- fprintf(stdout, "JPWL correction capability activated\n");
- fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
+ fprintf(stdout, "JPWL correction capability activated\n");
+ fprintf(stdout, "- expecting %d components\n", parameters->jpwl_exp_comps);
}
}
break;
/* cout << "freq = " << ((double) freq.QuadPart) << endl; */
/* t is the high resolution performance counter (see MSDN) */
QueryPerformanceCounter(& t) ;
- return freq.QuadPart ? (t.QuadPart / (OPJ_FLOAT64)freq.QuadPart) : 0;
+ return freq.QuadPart ? ((OPJ_FLOAT64)t.QuadPart / (OPJ_FLOAT64)freq.QuadPart) :
+ 0;
#elif defined(__linux)
struct timespec ts;
clock_gettime(CLOCK_REALTIME, &ts);
*/
static void quiet_callback(const char *msg, void *client_data)
{
+ (void)msg;
+ (void)client_data;
}
static void set_default_parameters(opj_decompress_parameters* parameters)
/*Decoding image one by one*/
for (imageno = 0; imageno < num_images ; imageno++) {
- fprintf(stderr, "\n");
+ if (!parameters.quiet) {
+ fprintf(stderr, "\n");
+ }
if (img_fol.set_imgdir == 1) {
if (get_next_file(imageno, dirptr, &img_fol, ¶meters)) {
}
if (parameters.quiet) {
- /* Set all callbacks to quiet */
- opj_set_info_handler(l_codec, quiet_callback, 00);
- opj_set_warning_handler(l_codec, quiet_callback, 00);
- opj_set_error_handler(l_codec, quiet_callback, 00);
+ /* Set all callbacks to quiet */
+ opj_set_info_handler(l_codec, quiet_callback, 00);
+ opj_set_warning_handler(l_codec, quiet_callback, 00);
+ opj_set_error_handler(l_codec, quiet_callback, 00);
} else {
- /* catch events using our callbacks and give a local context */
- opj_set_info_handler(l_codec, info_callback, 00);
- opj_set_warning_handler(l_codec, warning_callback, 00);
- opj_set_error_handler(l_codec, error_callback, 00);
+ /* catch events using our callbacks and give a local context */
+ opj_set_info_handler(l_codec, info_callback, 00);
+ opj_set_warning_handler(l_codec, warning_callback, 00);
+ opj_set_error_handler(l_codec, error_callback, 00);
}
goto fin;
}
if (!(parameters.quiet)) {
- fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
+ fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
}
}
+ /* FIXME? Shouldn't that situation be considered as an error of */
+ /* opj_decode() / opj_get_decoded_tile() ? */
+ if (image->comps[0].data == NULL) {
+ fprintf(stderr, "ERROR -> opj_decompress: no image data!\n");
+ opj_destroy_codec(l_codec);
+ opj_stream_destroy(l_stream);
+ opj_image_destroy(image);
+ failed = 1;
+ goto fin;
+ }
+
tCumulative += opj_clock() - t;
numDecompressedImages++;
if (imagetopnm(image, parameters.outfile, parameters.split_pnm)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
if (imagetopgx(image, parameters.outfile)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
if (imagetobmp(image, parameters.outfile)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
if (imagetotif(image, parameters.outfile)) {
fprintf(stderr, "[ERROR] Outfile %s not generated\n", parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
fprintf(stderr, "[ERROR] Error generating raw file. Outfile %s not generated\n",
parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
"[ERROR] Error generating rawl file. Outfile %s not generated\n",
parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
fprintf(stderr, "[ERROR] Error generating tga file. Outfile %s not generated\n",
parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
fprintf(stderr, "[ERROR] Error generating png file. Outfile %s not generated\n",
parameters.outfile);
failed = 1;
- } else if (! (parameters.quiet)) {
+ } else if (!(parameters.quiet)) {
fprintf(stdout, "[INFO] Generated Outfile %s\n", parameters.outfile);
}
break;
}
free(dirptr);
}
- if (numDecompressedImages && !(parameters.quiet)) {
+ if (numDecompressedImages && !failed && !(parameters.quiet)) {
fprintf(stdout, "decode time: %d ms\n",
(int)((tCumulative * 1000.0) / (OPJ_FLOAT64)numDecompressedImages));
}