added non-regression tests for j2k_dump function and conformance data
This commit is contained in:
parent
ff6d246efd
commit
eea61ee5e4
1
CHANGES
1
CHANGES
|
@ -8,6 +8,7 @@ What's New for OpenJPEG
|
|||
July 25, 2011
|
||||
* [mickael] fixed issue 74 for trunk
|
||||
! [mickael] modify j2k_dump to support output file, needed for non-regression tests
|
||||
+! [mickael] added non-regression tests for j2k_dump function and conformance data
|
||||
|
||||
July 22, 2011
|
||||
! [mickael] correct some troubles about thirdparty when they are used
|
||||
|
|
|
@ -11,6 +11,8 @@ INCLUDE_DIRECTORIES(${OPENJPEG_SOURCE_DIR}/libopenjpeg
|
|||
# First thing define the common source:
|
||||
SET(comparePGXimages_SRCS comparePGXimages.c ${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c)
|
||||
|
||||
SET(compare_dump_files_SRCS compare_dump_files.c)
|
||||
|
||||
# If not getopt was found then add it to the exe:
|
||||
IF(DONT_HAVE_GETOPT)
|
||||
message("dont have getopt, we will add it")
|
||||
|
@ -18,6 +20,11 @@ IF(DONT_HAVE_GETOPT)
|
|||
${comparePGXimages_SRCS}
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
||||
)
|
||||
|
||||
SET(compare_dump_files_SRCS
|
||||
${compare_dump_files_SRCS}
|
||||
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c
|
||||
)
|
||||
ENDIF(DONT_HAVE_GETOPT)
|
||||
|
||||
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
|
||||
|
@ -26,6 +33,8 @@ TARGET_LINK_LIBRARIES(comparePGXimages ${OPENJPEG_LIBRARY_NAME}
|
|||
${PNG_LIBNAME}
|
||||
${TIFF_LIBNAME}
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(compare_dump_files ${compare_dump_files_SRCS})
|
||||
|
||||
# No image send to the dashboard if lib PNG is not available.
|
||||
IF(NOT HAVE_LIBPNG)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* compareImagesPGX2.c
|
||||
* comparePGXimages.c
|
||||
*
|
||||
* Created on: 8 juil. 2011
|
||||
* Author: mickael
|
||||
|
@ -10,8 +10,6 @@
|
|||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
//#include <unistd.h>
|
||||
|
||||
#include "opj_config.h"
|
||||
#include "getopt.h"
|
||||
|
||||
|
@ -19,8 +17,6 @@
|
|||
#include "format_defs.h"
|
||||
#include "convert.h"
|
||||
|
||||
//#include "commonTesting.h"
|
||||
|
||||
double* parseToleranceValues( char* inArg, const int nbcomp);
|
||||
void comparePGXimages_help_display();
|
||||
opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separator);
|
||||
|
@ -49,6 +45,9 @@ typedef struct test_cmp_parameters
|
|||
|
||||
} test_cmp_parameters;
|
||||
|
||||
/*******************************************************************************
|
||||
* Command line help function
|
||||
*******************************************************************************/
|
||||
void comparePGXimages_help_display() {
|
||||
fprintf(stdout,"\nList of parameters for the comparePGX function \n");
|
||||
fprintf(stdout,"\n");
|
||||
|
@ -319,6 +318,8 @@ char* createMultiComponentsFilename(const char* inFilename, const int indexF, co
|
|||
else
|
||||
{
|
||||
//printf("Token %c not found\n", token);
|
||||
outFilename = (char*)malloc(1);
|
||||
outFilename[0] = '\0';
|
||||
return outFilename;
|
||||
}
|
||||
|
||||
|
@ -657,7 +658,7 @@ int main(int argc, char **argv)
|
|||
for (it_comp = 0; it_comp < imageDiff->numcomps; it_comp++)
|
||||
{
|
||||
double SE=0,PEAK=0;
|
||||
double MSE=0,PSNR=0;
|
||||
double MSE=0;
|
||||
char *filenamePNGbase_it_comp, *filenamePNGtest_it_comp, *filenamePNGdiff_it_comp;
|
||||
|
||||
filenamePNGbase_it_comp = (char*) malloc(memsizebasefilename);
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* compare_dump_files.c
|
||||
*
|
||||
* Created on: 25 juil. 2011
|
||||
* Author: mickael
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "getopt.h"
|
||||
|
||||
typedef struct test_cmp_parameters
|
||||
{
|
||||
/** */
|
||||
char* base_filename;
|
||||
/** */
|
||||
char* test_filename;
|
||||
} test_cmp_parameters;
|
||||
|
||||
/*******************************************************************************
|
||||
* Command line help function
|
||||
*******************************************************************************/
|
||||
void compare_dump_files_help_display() {
|
||||
fprintf(stdout,"\nList of parameters for the compare_dump_files function \n");
|
||||
fprintf(stdout,"\n");
|
||||
fprintf(stdout," -b \t REQUIRED \t filename to the reference/baseline dump file \n");
|
||||
fprintf(stdout," -t \t REQUIRED \t filename to the test dump file image\n");
|
||||
fprintf(stdout,"\n");
|
||||
}
|
||||
/*******************************************************************************
|
||||
* Parse command line
|
||||
*******************************************************************************/
|
||||
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
|
||||
param->base_filename = NULL;
|
||||
param->test_filename = NULL;
|
||||
|
||||
opterr = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, optlist)) != -1)
|
||||
switch (c)
|
||||
{
|
||||
case 'b':
|
||||
sizemembasefile = (int)strlen(optarg)+1;
|
||||
param->base_filename = (char*) malloc(sizemembasefile);
|
||||
param->base_filename[0] = '\0';
|
||||
strncpy(param->base_filename, optarg, strlen(optarg));
|
||||
param->base_filename[strlen(optarg)] = '\0';
|
||||
//printf("param->base_filename = %s [%d / %d]\n", param->base_filename, strlen(param->base_filename), sizemembasefile );
|
||||
break;
|
||||
case 't':
|
||||
sizememtestfile = (int) strlen(optarg) + 1;
|
||||
param->test_filename = (char*) malloc(sizememtestfile);
|
||||
param->test_filename[0] = '\0';
|
||||
strncpy(param->test_filename, optarg, strlen(optarg));
|
||||
param->test_filename[strlen(optarg)] = '\0';
|
||||
//printf("param->test_filename = %s [%d / %d]\n", param->test_filename, strlen(param->test_filename), sizememtestfile);
|
||||
break;
|
||||
case '?':
|
||||
if ( (optopt == 'b') || (optopt == 't') )
|
||||
fprintf(stderr, "Option -%c requires an argument.\n", optopt);
|
||||
else
|
||||
if (isprint(optopt)) fprintf(stderr, "Unknown option `-%c'.\n", optopt);
|
||||
else fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
|
||||
return 1;
|
||||
default:
|
||||
fprintf(stderr, "WARNING -> this option is not valid \"-%c %s\"\n", c, optarg);
|
||||
break;
|
||||
}
|
||||
|
||||
if (optind != argc)
|
||||
{
|
||||
for (index = optind; index < argc; index++)
|
||||
fprintf(stderr,"Non-option argument %s\n", argv[index]);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
/*******************************************************************************
|
||||
* MAIN
|
||||
*******************************************************************************/
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_cmp_parameters inParam;
|
||||
FILE *fbase=NULL, *ftest=NULL;
|
||||
char chbase, chtest;
|
||||
int same = 1;
|
||||
unsigned long l=1, pos;
|
||||
|
||||
if( parse_cmdline_cmp(argc, argv, &inParam) == EXIT_FAILURE )
|
||||
{
|
||||
compare_dump_files_help_display();
|
||||
if (!inParam.base_filename) free(inParam.base_filename);
|
||||
if (!inParam.test_filename) free(inParam.test_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
// Display Parameters
|
||||
printf("******Parameters********* \n");
|
||||
printf(" base_filename = %s\n"
|
||||
" test_filename = %s\n",
|
||||
inParam.base_filename, inParam.test_filename);
|
||||
printf("************************* \n");
|
||||
|
||||
/* open base file */
|
||||
printf("Try to open: %s for reading ... ", inParam.base_filename);
|
||||
if((fbase = fopen(inParam.base_filename, "rb"))==NULL)
|
||||
{
|
||||
printf("Failed.\n");
|
||||
free(inParam.base_filename);
|
||||
free(inParam.test_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Ok.\n");
|
||||
|
||||
/* open test file */
|
||||
printf("Try to open: %s for reading ... ", inParam.test_filename);
|
||||
if((ftest = fopen(inParam.test_filename, "rb"))==NULL)
|
||||
{
|
||||
printf("Failed.\n");
|
||||
fclose(fbase);
|
||||
free(inParam.base_filename);
|
||||
free(inParam.test_filename);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
printf("Ok.\n");
|
||||
|
||||
pos=ftell(fbase);
|
||||
|
||||
while(!feof(fbase))
|
||||
{
|
||||
chbase = fgetc(fbase);
|
||||
if(ferror(fbase))
|
||||
{
|
||||
printf("Error reading base file.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
chtest = fgetc(ftest);
|
||||
if(ferror(ftest))
|
||||
{
|
||||
printf("Error reading test file.\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if(chbase != chtest)
|
||||
{
|
||||
size_t nbytes = 2048;
|
||||
char* strbase, *strtest;
|
||||
int nbytes_read_base, nbytes_read_test;
|
||||
|
||||
printf("Files differ at line %lu:\n", l);
|
||||
fseek(fbase,pos,SEEK_SET);
|
||||
fseek(ftest,pos,SEEK_SET);
|
||||
|
||||
strbase = (char *) malloc(nbytes + 1);
|
||||
strtest = (char *) malloc(nbytes + 1);
|
||||
nbytes_read_base = getline(&strbase, &nbytes, fbase);
|
||||
nbytes_read_test = getline(&strtest, &nbytes, ftest);
|
||||
strbase[nbytes_read_base-1] = '\0';
|
||||
strtest[nbytes_read_test-1] = '\0';
|
||||
printf("<%s> vs. <%s>\n", strbase, strtest);
|
||||
|
||||
free(strbase);
|
||||
free(strtest);
|
||||
same = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chbase == '\n')
|
||||
{
|
||||
l++;
|
||||
pos = ftell(fbase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Close File
|
||||
fclose(fbase);
|
||||
fclose(ftest);
|
||||
|
||||
// Free memory
|
||||
free(inParam.base_filename);
|
||||
free(inParam.test_filename);
|
||||
|
||||
if(same)
|
||||
{
|
||||
printf("\n***** TEST SUCCEED: Files are the same. *****\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
else return EXIT_FAILURE;
|
||||
}
|
|
@ -46,10 +46,9 @@ FOREACH(numFileC0P0 RANGE 1 16)
|
|||
|
||||
# Manage cases which need to try different resolution reduction
|
||||
IF (numFileC0P0 EQUAL 3 OR numFileC0P0 EQUAL 15)
|
||||
|
||||
get_filename_component(filenameRefSub ${filenameRef} NAME_WE)
|
||||
|
||||
#r = 0
|
||||
|
||||
ADD_TEST(ETS-C0P0-${filenameInput}-r0-decode
|
||||
${EXECUTABLE_OUTPUT_PATH}/j2k_to_image
|
||||
-i ${INPUT_CONF}/${filenameInput}
|
||||
|
@ -83,7 +82,7 @@ FOREACH(numFileC0P0 RANGE 1 16)
|
|||
SET_TESTS_PROPERTIES(NR-C0P0-${filenameInput}-r0-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C0P0-${filenameInput}-r0-decode)
|
||||
|
||||
|
||||
#r = 1
|
||||
ADD_TEST(ETS-C0P0-${filenameInput}-r1-decode
|
||||
${EXECUTABLE_OUTPUT_PATH}/j2k_to_image
|
||||
|
@ -117,7 +116,7 @@ FOREACH(numFileC0P0 RANGE 1 16)
|
|||
|
||||
SET_TESTS_PROPERTIES(NR-C0P0-${filenameInput}-r1-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C0P0-${filenameInput}-r1-decode)
|
||||
ETS-C0P0-${filenameInput}-r1-decode)
|
||||
|
||||
ELSE(numFileC0P0 EQUAL 3 OR numFileC0P0 EQUAL 15)
|
||||
|
||||
|
@ -154,7 +153,7 @@ FOREACH(numFileC0P0 RANGE 1 16)
|
|||
SET_TESTS_PROPERTIES(NR-C0P0-${filenameInput}-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C0P0-${filenameInput}-decode)
|
||||
|
||||
|
||||
ENDIF(numFileC0P0 EQUAL 3 OR numFileC0P0 EQUAL 15)
|
||||
|
||||
ENDFOREACH(numFileC0P0)
|
||||
|
@ -181,13 +180,11 @@ FOREACH(numFileC0P1 RANGE 1 7)
|
|||
list(GET CP1_nbC_list ${numFileC0P1} nbComponents)
|
||||
list(GET C0P1_PEAK_list ${numFileC0P1} PEAK_limit)
|
||||
list(GET C0P1_MSE_list ${numFileC0P1} MSE_limit)
|
||||
|
||||
|
||||
# Manage cases which need to try different resolution reduction
|
||||
IF (numFileC0P1 EQUAL 4 )
|
||||
|
||||
get_filename_component(filenameRefSub ${filenameRef} NAME_WE)
|
||||
|
||||
|
||||
#r = 0
|
||||
ADD_TEST(ETS-C0P1-${filenameInput}-r0-decode
|
||||
${EXECUTABLE_OUTPUT_PATH}/j2k_to_image
|
||||
|
@ -221,8 +218,8 @@ FOREACH(numFileC0P1 RANGE 1 7)
|
|||
|
||||
SET_TESTS_PROPERTIES(NR-C0P1-${filenameInput}-r0-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C0P1-${filenameInput}-r0-decode)
|
||||
|
||||
ETS-C0P1-${filenameInput}-r0-decode)
|
||||
|
||||
#r = 3
|
||||
ADD_TEST(ETS-C0P1-${filenameInput}-r3-decode
|
||||
${EXECUTABLE_OUTPUT_PATH}/j2k_to_image
|
||||
|
@ -256,8 +253,8 @@ FOREACH(numFileC0P1 RANGE 1 7)
|
|||
|
||||
SET_TESTS_PROPERTIES(NR-C0P1-${filenameInput}-r3-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C0P1-${filenameInput}-r3-decode)
|
||||
|
||||
ETS-C0P1-${filenameInput}-r3-decode)
|
||||
|
||||
ELSE(numFileC0P1 EQUAL 4)
|
||||
|
||||
ADD_TEST(ETS-C0P1-${filenameInput}-decode
|
||||
|
@ -292,8 +289,8 @@ FOREACH(numFileC0P1 RANGE 1 7)
|
|||
|
||||
SET_TESTS_PROPERTIES(NR-C0P1-${filenameInput}-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C0P1-${filenameInput}-decode)
|
||||
|
||||
ETS-C0P1-${filenameInput}-decode)
|
||||
|
||||
ENDIF(numFileC0P1 EQUAL 4)
|
||||
|
||||
ENDFOREACH(numFileC0P1)
|
||||
|
@ -358,8 +355,8 @@ FOREACH(numFileC1P0 RANGE 1 16)
|
|||
|
||||
SET_TESTS_PROPERTIES(NR-C1P0-${filenameInput}-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C1P0-${filenameInput}-decode)
|
||||
|
||||
ETS-C1P0-${filenameInput}-decode)
|
||||
|
||||
ENDFOREACH(numFileC1P0)
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
|
@ -402,7 +399,7 @@ FOREACH(numFileC1P1 RANGE 1 7)
|
|||
|
||||
SET_TESTS_PROPERTIES(ETS-C1P1-${filenameInput}-compare2ref
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C1P1-${filenameInput}-decode)
|
||||
ETS-C1P1-${filenameInput}-decode)
|
||||
|
||||
ADD_TEST(NR-C1P1-${filenameInput}-compare2base
|
||||
${EXECUTABLE_OUTPUT_PATH}/comparePGXimages
|
||||
|
@ -415,6 +412,73 @@ FOREACH(numFileC1P1 RANGE 1 7)
|
|||
|
||||
SET_TESTS_PROPERTIES(NR-C1P1-${filenameInput}-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-C1P1-${filenameInput}-decode)
|
||||
ETS-C1P1-${filenameInput}-decode)
|
||||
|
||||
ENDFOREACH(numFileC1P1)
|
||||
ENDFOREACH(numFileC1P1)
|
||||
|
||||
#--------------------------------------------------------------------------#
|
||||
#--------------------------------------------------------------------------#
|
||||
#--------------------------------------------------------------------------#
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Tests about dump of profile 0 file
|
||||
# try to dump image and codestream informations into a file
|
||||
# non regression comparison this file to the baseline
|
||||
|
||||
FOREACH(numFileP0 RANGE 1 16)
|
||||
|
||||
# Build filenames
|
||||
IF(${numFileP0} LESS 10)
|
||||
SET( filenameInput p0_0${numFileP0}.j2k )
|
||||
ELSE(${numFileP0} LESS 10)
|
||||
SET( filenameInput p0_${numFileP0}.j2k )
|
||||
ENDIF(${numFileP0} LESS 10)
|
||||
get_filename_component(filenameRefSub ${filenameInput} NAME_WE)
|
||||
|
||||
|
||||
ADD_TEST(NR-${filenameInput}-dump
|
||||
${EXECUTABLE_OUTPUT_PATH}/j2k_dump
|
||||
-i ${INPUT_CONF}/${filenameInput}
|
||||
-o ${TEMP}/${filenameInput}.txt
|
||||
)
|
||||
|
||||
ADD_TEST(NR-${filenameInput}-compare_dump2base
|
||||
${EXECUTABLE_OUTPUT_PATH}/compare_dump_files
|
||||
-b ${BASELINE_NR}/opj_${filenameRefSub}.txt
|
||||
-t ${TEMP}/${filenameInput}.txt
|
||||
)
|
||||
|
||||
SET_TESTS_PROPERTIES(NR-${filenameInput}-compare_dump2base
|
||||
PROPERTIES DEPENDS
|
||||
NR-${filenameInput}-dump)
|
||||
|
||||
ENDFOREACH(numFileP0 RANGE 1 16)
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Tests about dump of profile 1 file
|
||||
# try to dump image and codestream informations into a file
|
||||
# non regression comparison this file to the baseline
|
||||
|
||||
FOREACH(numFileP1 RANGE 1 7)
|
||||
|
||||
# Build filenames
|
||||
SET( filenameInput p1_0${numFileP1}.j2k )
|
||||
get_filename_component(filenameInputSub ${filenameInput} NAME_WE)
|
||||
|
||||
ADD_TEST(NR-${filenameInput}-dump
|
||||
${EXECUTABLE_OUTPUT_PATH}/j2k_dump
|
||||
-i ${INPUT_CONF}/${filenameInput}
|
||||
-o ${TEMP}/${filenameInput}.txt
|
||||
)
|
||||
|
||||
ADD_TEST(NR-${filenameInput}-compare_dump2base
|
||||
${EXECUTABLE_OUTPUT_PATH}/compare_dump_files
|
||||
-b ${BASELINE_NR}/opj_${filenameInputSub}.txt
|
||||
-t ${TEMP}/${filenameInput}.txt
|
||||
)
|
||||
|
||||
SET_TESTS_PROPERTIES(NR-${filenameInput}-compare_dump2base
|
||||
PROPERTIES DEPENDS
|
||||
NR-${filenameInput}-dump)
|
||||
|
||||
ENDFOREACH(numFileP1 RANGE 1 7)
|
Loading…
Reference in New Issue