summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/jp2/opj_compress.c14
-rw-r--r--src/bin/jp2/opj_decompress.c18
-rw-r--r--src/bin/jp2/opj_dump.c15
3 files changed, 6 insertions, 41 deletions
diff --git a/src/bin/jp2/opj_compress.c b/src/bin/jp2/opj_compress.c
index 5101d841..24217aa3 100644
--- a/src/bin/jp2/opj_compress.c
+++ b/src/bin/jp2/opj_compress.c
@@ -1588,7 +1588,6 @@ static void info_callback(const char *msg, void *client_data) {
*/
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv) {
- FILE *fout = NULL;
opj_cparameters_t parameters; /* compression parameters */
@@ -1824,16 +1823,8 @@ int main(int argc, char **argv) {
}
opj_setup_encoder(l_codec, &parameters, image);
- /* Open the output file*/
- fout = fopen(parameters.outfile, "wb");
- if (! fout) {
- fprintf(stderr, "Not enable to create output file!\n");
- opj_stream_destroy_v3(l_stream);
- return 1;
- }
-
/* open a byte stream for writing and allocate memory for all tiles */
- l_stream = opj_stream_create_default_file_stream(fout,OPJ_FALSE);
+ l_stream = opj_stream_create_default_file_stream_v3(parameters.outfile,OPJ_FALSE);
if (! l_stream){
return 1;
}
@@ -1853,7 +1844,6 @@ int main(int argc, char **argv) {
if (! opj_write_tile(l_codec,i,l_data,l_data_size,l_stream)) {
fprintf(stderr, "ERROR -> test_tile_encoder: failed to write the tile %d!\n",i);
opj_stream_destroy_v3(l_stream);
- fclose(fout);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return 1;
@@ -1874,7 +1864,6 @@ int main(int argc, char **argv) {
if (!bSuccess) {
opj_stream_destroy_v3(l_stream);
- fclose(fout);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fprintf(stderr, "failed to encode image\n");
@@ -1884,7 +1873,6 @@ int main(int argc, char **argv) {
fprintf(stderr,"Generated outfile %s\n",parameters.outfile);
/* close and free the byte stream */
opj_stream_destroy_v3(l_stream);
- fclose(fout);
/* free remaining compression structures */
opj_destroy_codec(l_codec);
diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c
index e462fb5e..9e4f3103 100644
--- a/src/bin/jp2/opj_decompress.c
+++ b/src/bin/jp2/opj_decompress.c
@@ -676,7 +676,6 @@ static void info_callback(const char *msg, void *client_data) {
/* -------------------------------------------------------------------------- */
int main(int argc, char **argv)
{
- FILE *fsrc = NULL;
opj_dparameters_t parameters; /* decompression parameters */
opj_image_t* image = NULL;
@@ -746,16 +745,10 @@ int main(int argc, char **argv)
/* 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(fsrc,1);
+ l_stream = opj_stream_create_default_file_stream_v3(parameters.infile,1);
if (!l_stream){
- fclose(fsrc);
- fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
+ fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n", parameters.infile);
return EXIT_FAILURE;
}
@@ -796,7 +789,6 @@ int main(int argc, char **argv)
if ( !opj_setup_decoder(l_codec, &parameters) ){
fprintf(stderr, "ERROR -> j2k_dump: failed to setup the decoder\n");
opj_stream_destroy_v3(l_stream);
- fclose(fsrc);
opj_destroy_codec(l_codec);
return EXIT_FAILURE;
}
@@ -806,7 +798,6 @@ int main(int argc, char **argv)
if(! opj_read_header(l_stream, l_codec, &image)){
fprintf(stderr, "ERROR -> opj_decompress: failed to read the header\n");
opj_stream_destroy_v3(l_stream);
- fclose(fsrc);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
return EXIT_FAILURE;
@@ -820,7 +811,6 @@ int main(int argc, char **argv)
opj_stream_destroy_v3(l_stream);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
- fclose(fsrc);
return EXIT_FAILURE;
}
@@ -830,7 +820,6 @@ int main(int argc, char **argv)
opj_destroy_codec(l_codec);
opj_stream_destroy_v3(l_stream);
opj_image_destroy(image);
- fclose(fsrc);
return EXIT_FAILURE;
}
}
@@ -842,7 +831,6 @@ int main(int argc, char **argv)
opj_destroy_codec(l_codec);
opj_stream_destroy_v3(l_stream);
opj_image_destroy(image);
- fclose(fsrc);
return EXIT_FAILURE;
}*/
@@ -851,7 +839,6 @@ int main(int argc, char **argv)
opj_destroy_codec(l_codec);
opj_stream_destroy_v3(l_stream);
opj_image_destroy(image);
- fclose(fsrc);
return EXIT_FAILURE;
}
fprintf(stdout, "tile %d is decoded!\n\n", parameters.tile_index);
@@ -859,7 +846,6 @@ int main(int argc, char **argv)
/* Close the byte stream */
opj_stream_destroy_v3(l_stream);
- fclose(fsrc);
if(image->color_space == OPJ_CLRSPC_SYCC){
color_sycc_to_rgb(image); /* FIXME */
diff --git a/src/bin/jp2/opj_dump.c b/src/bin/jp2/opj_dump.c
index 0fb5d117..23913899 100644
--- a/src/bin/jp2/opj_dump.c
+++ b/src/bin/jp2/opj_dump.c
@@ -401,7 +401,7 @@ static void info_callback(const char *msg, void *client_data) {
/* -------------------------------------------------------------------------- */
int main(int argc, char *argv[])
{
- FILE *fsrc = NULL, *fout = NULL;
+ FILE *fout = NULL;
opj_dparameters_t parameters; /* Decompression parameters */
opj_image_t* image = NULL; /* Image structure */
@@ -486,16 +486,10 @@ int main(int argc, char *argv[])
/* 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(fsrc,1);
+ l_stream = opj_stream_create_default_file_stream_v3(parameters.infile,1);
if (!l_stream){
- fclose(fsrc);
- fprintf(stderr, "ERROR -> failed to create the stream from the file\n");
+ fprintf(stderr, "ERROR -> failed to create the stream from the file %s\n",parameters.infile);
return EXIT_FAILURE;
}
@@ -536,7 +530,6 @@ int main(int argc, char *argv[])
if ( !opj_setup_decoder(l_codec, &parameters) ){
fprintf(stderr, "ERROR -> opj_dump: failed to setup the decoder\n");
opj_stream_destroy_v3(l_stream);
- fclose(fsrc);
opj_destroy_codec(l_codec);
fclose(fout);
return EXIT_FAILURE;
@@ -546,7 +539,6 @@ int main(int argc, char *argv[])
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);
- fclose(fsrc);
opj_destroy_codec(l_codec);
opj_image_destroy(image);
fclose(fout);
@@ -561,7 +553,6 @@ int main(int argc, char *argv[])
/* close the byte stream */
opj_stream_destroy_v3(l_stream);
- fclose(fsrc);
/* free remaining structures */
if (l_codec) {