fixup! Try to build with AVX2.
[openjpeg.git] / tests / j2k_random_tile_access.c
index 065a955cfacb88ddd5d8a09d2283f473f652fc38..b53c6005c7fd5ef1230548ad5b6972ce84d5fbb4 100644 (file)
@@ -150,9 +150,7 @@ static int infile_format(const char *fname)
 /* -------------------------------------------------------------------------- */
 int main(int argc, char **argv)
 {
-       FILE *fsrc = NULL;
-
-  OPJ_UINT32 index;
+    OPJ_UINT32 index;
        opj_dparameters_t parameters;                   /* decompression parameters */
        opj_image_t* image = NULL;
        opj_stream_t *l_stream = NULL;                          /* Stream */
@@ -175,13 +173,6 @@ int main(int argc, char **argv)
 
        strncpy(parameters.infile, argv[1], OPJ_PATH_LEN - 1);
 
-       /* read the input file */
-       /* ------------------- */
-       fsrc = fopen(parameters.infile, "rb");
-       if (!fsrc) {
-               fprintf(stderr, "ERROR -> failed to open %s for reading\n", parameters.infile);
-               return EXIT_FAILURE;
-       }
 
        /* decode the JPEG2000 stream */
        /* -------------------------- */
@@ -218,18 +209,16 @@ int main(int argc, char **argv)
        opj_set_warning_handler(l_codec, warning_callback,00);
        opj_set_error_handler(l_codec, error_callback,00);
 
-       l_stream = opj_stream_create_default_file_stream(fsrc,1);
+    l_stream = opj_stream_create_default_file_stream(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;
        }
 
        /* Setup the decoder decoding parameters using user parameters */
        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_stream_destroy(l_stream);
                opj_destroy_codec(l_codec);
                return EXIT_FAILURE;
        }
@@ -237,8 +226,7 @@ int main(int argc, char **argv)
        /* 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 -> j2k_to_image: failed to read the header\n");
-               opj_stream_destroy_v3(l_stream);
-               fclose(fsrc);
+               opj_stream_destroy(l_stream);
                opj_destroy_codec(l_codec);
                opj_image_destroy(image);
                return EXIT_FAILURE;
@@ -258,21 +246,19 @@ int main(int argc, char **argv)
        fprintf(stdout, "Decoding tile %d ...\n", tile_index); \
        if(!opj_get_decoded_tile(l_codec, l_stream, image, tile_index )){ \
                fprintf(stderr, "ERROR -> j2k_to_image: failed to decode tile %d\n", tile_index); \
-               opj_stream_destroy_v3(l_stream); \
+               opj_stream_destroy(l_stream); \
                opj_destroy_cstr_info(&cstr_info); \
                opj_destroy_codec(l_codec); \
                opj_image_destroy(image); \
-               fclose(fsrc); \
                return EXIT_FAILURE; \
        } \
   for(index = 0; index < image->numcomps; ++index) { \
     if( image->comps[index].data == NULL ){ \
        fprintf(stderr, "ERROR -> j2k_to_image: failed to decode tile %d\n", tile_index); \
-               opj_stream_destroy_v3(l_stream); \
+               opj_stream_destroy(l_stream); \
                opj_destroy_cstr_info(&cstr_info); \
                opj_destroy_codec(l_codec); \
                opj_image_destroy(image); \
-               fclose(fsrc); \
         return EXIT_FAILURE; \
         } \
   } \
@@ -286,7 +272,7 @@ int main(int argc, char **argv)
        TEST_TILE(tile_lr)
 
        /* Close the byte stream */
-       opj_stream_destroy_v3(l_stream);
+       opj_stream_destroy(l_stream);
 
        /* Destroy code stream info */
        opj_destroy_cstr_info(&cstr_info);
@@ -297,9 +283,6 @@ int main(int argc, char **argv)
        /* Free image data structure */
        opj_image_destroy(image);
 
-       /* Close the input file */
-       fclose(fsrc);
-
        return EXIT_SUCCESS;
 }
 /*end main*/