projects
/
openjpeg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[trunk] Update missing md5sums
[openjpeg.git]
/
tests
/
compareRAWimages.c
diff --git
a/tests/compareRAWimages.c
b/tests/compareRAWimages.c
index 24738873662d92f604398db67612c7683be830c7..4f18352932edab3b4ec2c30fa9bb184c19302e23 100644
(file)
--- a/
tests/compareRAWimages.c
+++ b/
tests/compareRAWimages.c
@@
-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
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@
-38,8
+38,6
@@
#include "opj_getopt.h"
#include "opj_getopt.h"
-void compareRAWimages_help_display(void);
-
typedef struct test_cmp_parameters
{
/** */
typedef struct test_cmp_parameters
{
/** */
@@
-51,7
+49,7
@@
typedef struct test_cmp_parameters
/*******************************************************************************
* Command line help function
*******************************************************************************/
/*******************************************************************************
* 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");
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,19
+60,19
@@
void compareRAWimages_help_display(void) {
/*******************************************************************************
* Parse command line
*******************************************************************************/
/*******************************************************************************
* 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;
{
int sizemembasefile, sizememtestfile;
int index;
const char optlist[] = "b:t:";
int c;
- /
/ Init parameters
+ /
* Init parameters*/
param->base_filename = NULL;
param->test_filename = NULL;
opj_opterr = 0;
param->base_filename = NULL;
param->test_filename = NULL;
opj_opterr = 0;
- while ((c = getopt(argc, argv, optlist)) != -1)
+ while ((c =
opj_
getopt(argc, argv, optlist)) != -1)
switch (c)
{
case 'b':
switch (c)
{
case 'b':
@@
-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';
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;
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';
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'))
break;
case '?':
if ((opj_optopt == 'b') || (opj_optopt == 't'))
@@
-119,30
+117,65
@@
int parse_cmdline_cmp(int argc, char **argv, test_cmp_parameters* param)
*******************************************************************************/
int main(int argc, char **argv)
{
*******************************************************************************/
int main(int argc, char **argv)
{
+ int pos = 0;
test_cmp_parameters inParam;
FILE *file_test=NULL, *file_base=NULL;
unsigned char equal = 1;
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();
if (parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE)
{
compareRAWimages_help_display();
+
+ /* Free Memory */
+ if (inParam.base_filename){
+ free(inParam.base_filename);
+ inParam.base_filename = NULL;
+ }
+ if (inParam.test_filename){
+ free(inParam.test_filename);
+ inParam.test_filename = NULL;
+ }
+
return EXIT_FAILURE;
}
file_test = fopen(inParam.test_filename, "rb");
if (!file_test) {
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
return EXIT_FAILURE;
}
file_test = fopen(inParam.test_filename, "rb");
if (!file_test) {
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.test_filename);
+
+ /* Free Memory */
+ if (inParam.base_filename){
+ free(inParam.base_filename);
+ inParam.base_filename = NULL;
+ }
+ if (inParam.test_filename){
+ free(inParam.test_filename);
+ inParam.test_filename = NULL;
+ }
+
return EXIT_FAILURE;
}
file_base = fopen(inParam.base_filename, "rb");
if (!file_base) {
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
return EXIT_FAILURE;
}
file_base = fopen(inParam.base_filename, "rb");
if (!file_base) {
fprintf(stderr, "Failed to open %s for reading !!\n", inParam.base_filename);
+
+ /* Free Memory */
+ if (inParam.base_filename){
+ free(inParam.base_filename);
+ inParam.base_filename = NULL;
+ }
+ if (inParam.test_filename){
+ free(inParam.test_filename);
+ inParam.test_filename = NULL;
+ }
+
+ fclose(file_test);
return EXIT_FAILURE;
}
return EXIT_FAILURE;
}
- /
/ Read simultaneously the two files
+ /
* Read simultaneously the two files*/
while (equal)
{
unsigned char value_test = 0;
while (equal)
{
unsigned char value_test = 0;
@@
-150,33
+183,44
@@
int main(int argc, char **argv)
unsigned char value_base = 0;
unsigned char eof_base = 0;
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;
}
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)) {
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;
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;
}
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)
{
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;
}
equal = 0;
}
+ pos++;
+ }
+
+ /* Free Memory */
+ if (inParam.base_filename){
+ free(inParam.base_filename);
+ inParam.base_filename = NULL;
+ }
+ if (inParam.test_filename){
+ free(inParam.test_filename);
+ inParam.test_filename = NULL;
}
fclose(file_test);
}
fclose(file_test);