added non-regression tests for j2k_dump function and conformance data

This commit is contained in:
Mickael Savinaud 2011-07-25 16:33:52 +00:00
parent ff6d246efd
commit eea61ee5e4
5 changed files with 302 additions and 25 deletions

View File

@ -8,6 +8,7 @@ What's New for OpenJPEG
July 25, 2011 July 25, 2011
* [mickael] fixed issue 74 for trunk * [mickael] fixed issue 74 for trunk
! [mickael] modify j2k_dump to support output file, needed for non-regression tests ! [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 July 22, 2011
! [mickael] correct some troubles about thirdparty when they are used ! [mickael] correct some troubles about thirdparty when they are used

View File

@ -11,6 +11,8 @@ INCLUDE_DIRECTORIES(${OPENJPEG_SOURCE_DIR}/libopenjpeg
# First thing define the common source: # First thing define the common source:
SET(comparePGXimages_SRCS comparePGXimages.c ${OPENJPEG_SOURCE_DIR}/applications/codec/convert.c) 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 not getopt was found then add it to the exe:
IF(DONT_HAVE_GETOPT) IF(DONT_HAVE_GETOPT)
message("dont have getopt, we will add it") message("dont have getopt, we will add it")
@ -18,6 +20,11 @@ IF(DONT_HAVE_GETOPT)
${comparePGXimages_SRCS} ${comparePGXimages_SRCS}
${OPENJPEG_SOURCE_DIR}/applications/common/getopt.c ${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) ENDIF(DONT_HAVE_GETOPT)
ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS}) ADD_EXECUTABLE(comparePGXimages ${comparePGXimages_SRCS})
@ -27,6 +34,8 @@ TARGET_LINK_LIBRARIES(comparePGXimages ${OPENJPEG_LIBRARY_NAME}
${TIFF_LIBNAME} ${TIFF_LIBNAME}
) )
ADD_EXECUTABLE(compare_dump_files ${compare_dump_files_SRCS})
# No image send to the dashboard if lib PNG is not available. # No image send to the dashboard if lib PNG is not available.
IF(NOT HAVE_LIBPNG) IF(NOT HAVE_LIBPNG)
MESSAGE(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)") MESSAGE(WARNING "Lib PNG seems to be not available: if you want run the non-regression tests with images reported to the dashboard, you need it (try BUILD_THIRDPARTY)")

View File

@ -1,5 +1,5 @@
/* /*
* compareImagesPGX2.c * comparePGXimages.c
* *
* Created on: 8 juil. 2011 * Created on: 8 juil. 2011
* Author: mickael * Author: mickael
@ -10,8 +10,6 @@
#include <math.h> #include <math.h>
#include <string.h> #include <string.h>
//#include <unistd.h>
#include "opj_config.h" #include "opj_config.h"
#include "getopt.h" #include "getopt.h"
@ -19,8 +17,6 @@
#include "format_defs.h" #include "format_defs.h"
#include "convert.h" #include "convert.h"
//#include "commonTesting.h"
double* parseToleranceValues( char* inArg, const int nbcomp); double* parseToleranceValues( char* inArg, const int nbcomp);
void comparePGXimages_help_display(); void comparePGXimages_help_display();
opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separator); opj_image_t* readImageFromFilePGX(char* filename, int nbFilenamePGX, char *separator);
@ -49,6 +45,9 @@ typedef struct test_cmp_parameters
} test_cmp_parameters; } test_cmp_parameters;
/*******************************************************************************
* Command line help function
*******************************************************************************/
void comparePGXimages_help_display() { void comparePGXimages_help_display() {
fprintf(stdout,"\nList of parameters for the comparePGX function \n"); fprintf(stdout,"\nList of parameters for the comparePGX function \n");
fprintf(stdout,"\n"); fprintf(stdout,"\n");
@ -319,6 +318,8 @@ char* createMultiComponentsFilename(const char* inFilename, const int indexF, co
else else
{ {
//printf("Token %c not found\n", token); //printf("Token %c not found\n", token);
outFilename = (char*)malloc(1);
outFilename[0] = '\0';
return outFilename; return outFilename;
} }
@ -657,7 +658,7 @@ int main(int argc, char **argv)
for (it_comp = 0; it_comp < imageDiff->numcomps; it_comp++) for (it_comp = 0; it_comp < imageDiff->numcomps; it_comp++)
{ {
double SE=0,PEAK=0; double SE=0,PEAK=0;
double MSE=0,PSNR=0; double MSE=0;
char *filenamePNGbase_it_comp, *filenamePNGtest_it_comp, *filenamePNGdiff_it_comp; char *filenamePNGbase_it_comp, *filenamePNGtest_it_comp, *filenamePNGdiff_it_comp;
filenamePNGbase_it_comp = (char*) malloc(memsizebasefilename); filenamePNGbase_it_comp = (char*) malloc(memsizebasefilename);

202
tests/compare_dump_files.c Normal file
View File

@ -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;
}

View File

@ -46,10 +46,9 @@ FOREACH(numFileC0P0 RANGE 1 16)
# Manage cases which need to try different resolution reduction # Manage cases which need to try different resolution reduction
IF (numFileC0P0 EQUAL 3 OR numFileC0P0 EQUAL 15) IF (numFileC0P0 EQUAL 3 OR numFileC0P0 EQUAL 15)
get_filename_component(filenameRefSub ${filenameRef} NAME_WE) get_filename_component(filenameRefSub ${filenameRef} NAME_WE)
#r = 0 #r = 0
ADD_TEST(ETS-C0P0-${filenameInput}-r0-decode ADD_TEST(ETS-C0P0-${filenameInput}-r0-decode
${EXECUTABLE_OUTPUT_PATH}/j2k_to_image ${EXECUTABLE_OUTPUT_PATH}/j2k_to_image
-i ${INPUT_CONF}/${filenameInput} -i ${INPUT_CONF}/${filenameInput}
@ -182,10 +181,8 @@ FOREACH(numFileC0P1 RANGE 1 7)
list(GET C0P1_PEAK_list ${numFileC0P1} PEAK_limit) list(GET C0P1_PEAK_list ${numFileC0P1} PEAK_limit)
list(GET C0P1_MSE_list ${numFileC0P1} MSE_limit) list(GET C0P1_MSE_list ${numFileC0P1} MSE_limit)
# Manage cases which need to try different resolution reduction # Manage cases which need to try different resolution reduction
IF (numFileC0P1 EQUAL 4 ) IF (numFileC0P1 EQUAL 4 )
get_filename_component(filenameRefSub ${filenameRef} NAME_WE) get_filename_component(filenameRefSub ${filenameRef} NAME_WE)
#r = 0 #r = 0
@ -418,3 +415,70 @@ FOREACH(numFileC1P1 RANGE 1 7)
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)