[trunk] Update missing md5sums
[openjpeg.git] / tests / compareRAWimages.c
index 851dbfff48438faa2b53d58abbef9853cbcbfde2..4f18352932edab3b4ec2c30fa9bb184c19302e23 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Mickael Savinaud, Communications & Systemes <mickael.savinaud@c-s.fr>
+ * Copyright (c) 2011-2012, Centre National d'Etudes Spatiales (CNES), France 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,8 +38,6 @@
 
 #include "opj_getopt.h"
 
-void compareRAWimages_help_display(void);
-
 typedef struct test_cmp_parameters
 {
        /**  */
@@ -51,7 +49,7 @@ typedef struct test_cmp_parameters
 /*******************************************************************************
  * Command line help function
  *******************************************************************************/
-void compareRAWimages_help_display(void) {
+static void compareRAWimages_help_display(void) {
        fprintf(stdout,"\nList of parameters for the comparePGX function  \n");
        fprintf(stdout,"\n");
        fprintf(stdout,"  -b \t REQUIRED \t filename to the reference/baseline RAW image \n");
@@ -62,14 +60,14 @@ void compareRAWimages_help_display(void) {
 /*******************************************************************************
  * Parse command line
  *******************************************************************************/
-int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
+static int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
 {
        int sizemembasefile, sizememtestfile;
        int index;
        const char optlist[] = "b:t:";
        int c;
 
-       // Init parameters
+       /* Init parameters*/
        param->base_filename = NULL;
        param->test_filename = NULL;
 
@@ -83,7 +81,7 @@ int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
                        param->base_filename[0] = '\0';
                        strncpy(param->base_filename, opj_optarg, strlen(opj_optarg));
                        param->base_filename[strlen(opj_optarg)] = '\0';
-                       //printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
+                       /*printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );*/
                        break;
                case 't':
                        sizememtestfile = (int) strlen(opj_optarg) + 1;
@@ -91,7 +89,7 @@ int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
                        param->test_filename[0] = '\0';
                        strncpy(param->test_filename, opj_optarg, strlen(opj_optarg));
                        param->test_filename[strlen(opj_optarg)] = '\0';
-                       //printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
+                       /*printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);*/
                        break;
                case '?':
                        if ((opj_optopt == 'b') || (opj_optopt == 't'))
@@ -119,11 +117,12 @@ int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
  *******************************************************************************/
 int main(int argc, char **argv)
 {
+  int pos = 0;
        test_cmp_parameters inParam;
        FILE *file_test=NULL, *file_base=NULL;
        unsigned char equal = 1;
 
-       // Get parameters from command line
+       /* Get parameters from command line*/
        if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
        {
                compareRAWimages_help_display();
@@ -176,7 +175,7 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
        }
 
-       // Read simultaneously the two files
+       /* Read simultaneously the two files*/
        while (equal)
        {
                unsigned char value_test = 0;
@@ -184,33 +183,34 @@ int main(int argc, char **argv)
                unsigned char value_base = 0;
                unsigned char eof_base = 0;
 
-               // Read one byte
+               /* Read one byte*/
                if (!fread(&value_test, 1, 1, file_test)) {
                        eof_test = 1;
                }
 
-               // Read one byte
+               /* Read one byte*/
                if (!fread(&value_base, 1, 1, file_base)) {
-                       eof_base = 1;;
+                       eof_base = 1;
                }
 
-               // End of file reached by the two files?
+               /* End of file reached by the two files?*/
                if (eof_test && eof_base)
                        break;
 
-               // End of file reached only by one file?
+               /* End of file reached only by one file?*/
                if (eof_test || eof_base)
                {
                        fprintf(stdout,"Files have different sizes.\n");
                        equal = 0;
                }
 
-               // Binary values are equal?
+               /* Binary values are equal?*/
                if (value_test != value_base)
                {
-                       fprintf(stdout,"Binary values read in the file are different.\n");
+                       fprintf(stdout,"Binary values read in the file are different %x vs %x at position %d.\n", value_test, value_base, pos);
                        equal = 0;
                }
+    pos++;
        }
 
        /* Free Memory */