/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
- FILE *fout = NULL;
+ FILE *fsrc = NULL, *fout = NULL;
opj_dparameters_t parameters; /* Decompression parameters */
opj_image_t* image = NULL; /* Image structure */
/* Read the input file and put it in memory */
/* ---------------------------------------- */
+ fsrc = fopen(parameters.infile, "rb");
+ if (!fsrc) {
+ fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
+ return EXIT_FAILURE;
+ }
- l_stream = opj_stream_create_default_file_stream_v3(parameters.infile,1);
+ l_stream = opj_stream_create_default_file_stream(fsrc,1);
if (!l_stream){
- fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
+ fclose(fsrc);
+ fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
return EXIT_FAILURE;
}
}
default:
fprintf(stderr, "skipping file..\n");
- opj_stream_destroy_v3(l_stream);
+ opj_stream_destroy(l_stream);
continue;
}
/* Setup the decoder decoding parameters using user parameters */
if ( !opj_setup_decoder(l_codec, ¶meters) ){
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
- opj_stream_destroy_v3(l_stream);
+ opj_stream_destroy(l_stream);
+ fclose(fsrc);
opj_destroy_codec(l_codec);
fclose(fout);
return EXIT_FAILURE;
/* Read the main header of the codestream and if necessary the JP2 boxes*/
if(! opj_read_header(l_stream, l_codec, &image)){
fprintf(stderr, "ERROR -> opj_dump: failed to read the header\n");
- opj_stream_destroy_v3(l_stream);
+ opj_stream_destroy(l_stream);
+ fclose(fsrc);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fclose(fout);
cstr_index = opj_get_cstr_index(l_codec);
/* close the byte stream */
- opj_stream_destroy_v3(l_stream);
+ opj_stream_destroy(l_stream);
+ fclose(fsrc);
/* free remaining structures */
if (l_codec) {