[trunk] use the right v2 structure
[openjpeg.git] / tests / test_tile_encoder.c
index 2d8aa22bea95bf7a1cc043466e8d28bf85f734b7..a405d86e9dd81c22db3e081b87cda45943366f0e 100644 (file)
 #include <stdlib.h>
 #include <math.h>
 
-
-#ifdef _WIN32
-#include <windows.h>
-#else
-#include <strings.h>
-#define _stricmp strcasecmp
-#define _strnicmp strncasecmp
-#endif /* _WIN32 */
-
 #include "opj_config.h"
 #include "openjpeg.h"
 #include "stdlib.h"
 /**
 sample error callback expecting a FILE* client object
 */
-void error_callback_file(const char *msg, void *client_data) {
+static void error_callback_file(const char *msg, void *client_data) {
        FILE *stream = (FILE*)client_data;
        fprintf(stream, "[ERROR] %s", msg);
 }
 /**
 sample warning callback expecting a FILE* client object
 */
-void warning_callback_file(const char *msg, void *client_data) {
+static void warning_callback_file(const char *msg, void *client_data) {
        FILE *stream = (FILE*)client_data;
        fprintf(stream, "[WARNING] %s", msg);
 }
 /**
 sample error debug callback expecting no client object
 */
-void error_callback(const char *msg, void *client_data) {
+static void error_callback(const char *msg, void *client_data) {
        (void)client_data;
        fprintf(stdout, "[ERROR] %s", msg);
 }
 /**
 sample warning debug callback expecting no client object
 */
-void warning_callback(const char *msg, void *client_data) {
+static void warning_callback(const char *msg, void *client_data) {
        (void)client_data;
        fprintf(stdout, "[WARNING] %s", msg);
 }
 /**
 sample debug callback expecting no client object
 */
-void info_callback(const char *msg, void *client_data) {
+static void info_callback(const char *msg, void *client_data) {
        (void)client_data;
        fprintf(stdout, "[INFO] %s", msg);
 }
@@ -119,10 +110,11 @@ int main (int argc, char *argv[])
   int tile_width;
   int tile_height;
   int comp_prec;
+  int irreversible;
   char output_file[64];
 
   /* should be test_tile_encoder 3 2000 2000 1000 1000 8 tte1.j2k */
-  if( argc == 8 )
+  if( argc == 9 )
     {
     num_comps = atoi( argv[1] );
     image_width = atoi( argv[2] );
@@ -130,7 +122,8 @@ int main (int argc, char *argv[])
     tile_width = atoi( argv[4] );
     tile_height = atoi( argv[5] );
     comp_prec = atoi( argv[6] );
-    strcpy(output_file, argv[7] );
+    irreversible = atoi( argv[7] );
+    strcpy(output_file, argv[8] );
     }
   else
     {
@@ -140,6 +133,7 @@ int main (int argc, char *argv[])
     tile_width = 1000;
     tile_height = 1000;
     comp_prec = 8;
+    irreversible = 1;
     strcpy(output_file, "test.j2k" );
     }
   if( num_comps > NUM_COMPS_MAX )
@@ -153,7 +147,7 @@ int main (int argc, char *argv[])
 
        fprintf(stdout, "Encoding random values -> keep in mind that this is very hard to compress\n");
        for (i=0;i<l_data_size;++i)     {
-               l_data[i] = i; //rand();
+               l_data[i] = i; /*rand();*/
        }
 
        opj_set_default_encoder_parameters(&l_param);
@@ -178,7 +172,7 @@ int main (int argc, char *argv[])
        l_param.cp_tdy = tile_height;
 
        /* use irreversible encoding ?*/
-       l_param.irreversible = 1;
+       l_param.irreversible = irreversible;
 
        /* do not bother with mct, the rsiz is set when calling opj_set_MCT*/
        /*l_param.cp_rsiz = STD_RSIZ;*/
@@ -246,15 +240,15 @@ int main (int argc, char *argv[])
                ++l_current_param_ptr;
        }
 
-  // should we do j2k or jp2 ?
+  /* should we do j2k or jp2 ?*/
   len = strlen( output_file );
   if( strcmp( output_file + len - 4, ".jp2" ) == 0 )
     {
-    l_codec = opj_create_compress_v2(CODEC_JP2);
+    l_codec = opj_create_compress(CODEC_JP2);
     }
   else
     {
-    l_codec = opj_create_compress_v2(CODEC_J2K);
+    l_codec = opj_create_compress(CODEC_J2K);
     }
        if (!l_codec) {
                return 1;
@@ -277,7 +271,7 @@ int main (int argc, char *argv[])
        l_image->y1 = image_height;
        l_image->color_space = CLRSPC_SRGB;
 
-       if (! opj_setup_encoder_v2(l_codec,&l_param,l_image)) {
+       if (! opj_setup_encoder(l_codec,&l_param,l_image)) {
                fprintf(stderr, "ERROR -> test_tile_encoder: failed to setup the codec!\n");
                opj_destroy_codec(l_codec);
                opj_image_destroy(l_image);
@@ -328,8 +322,10 @@ int main (int argc, char *argv[])
        opj_destroy_codec(l_codec);
        opj_image_destroy(l_image);
 
-       // Print profiling
-       //PROFPRINT();
+       free(l_data);
+
+       /* Print profiling*/
+       /*PROFPRINT();*/
 
        return 0;
 }