[trunk] Add new test suite that run on kakadu conformance images
This commit is contained in:
parent
6b94237679
commit
fa1c2454e6
|
@ -140,6 +140,94 @@ static char* createMultiComponentsFilename(const char* inFilename, const int ind
|
|||
/*******************************************************************************
|
||||
*
|
||||
*******************************************************************************/
|
||||
static opj_image_t* readImageFromFilePPM(const char* filename, int nbFilenamePGX, const char *separator)
|
||||
{
|
||||
int it_file;
|
||||
opj_image_t* image_read = NULL;
|
||||
opj_image_t* image = NULL;
|
||||
opj_cparameters_t parameters;
|
||||
opj_image_cmptparm_t* param_image_read;
|
||||
int** data;
|
||||
|
||||
/* If separator is empty => nb file to read is equal to one*/
|
||||
if ( strlen(separator) == 0 )
|
||||
nbFilenamePGX = 1;
|
||||
|
||||
/* set encoding parameters to default values */
|
||||
opj_set_default_encoder_parameters(¶meters);
|
||||
parameters.decod_format = PXM_DFMT;
|
||||
strcpy(parameters.infile, filename);
|
||||
|
||||
/* Allocate memory*/
|
||||
param_image_read = malloc((size_t)nbFilenamePGX * sizeof(opj_image_cmptparm_t));
|
||||
data = malloc((size_t)nbFilenamePGX * sizeof(*data));
|
||||
|
||||
for (it_file = 0; it_file < nbFilenamePGX; it_file++)
|
||||
{
|
||||
/* Create the right filename*/
|
||||
char *filenameComponentPGX;
|
||||
if (strlen(separator) == 0)
|
||||
{
|
||||
filenameComponentPGX = malloc((strlen(filename) + 1) * sizeof(*filenameComponentPGX));
|
||||
strcpy(filenameComponentPGX, filename);
|
||||
}
|
||||
else
|
||||
filenameComponentPGX = createMultiComponentsFilename(filename, it_file, separator);
|
||||
|
||||
/* Read the tif file corresponding to the component */
|
||||
image_read = pnmtoimage(filenameComponentPGX, ¶meters);
|
||||
if (!image_read)
|
||||
{
|
||||
int it_free_data;
|
||||
fprintf(stderr, "Unable to load pgx file\n");
|
||||
|
||||
free(param_image_read);
|
||||
|
||||
for (it_free_data = 0; it_free_data < it_file; it_free_data++) {
|
||||
free(data[it_free_data]);
|
||||
}
|
||||
free(data);
|
||||
|
||||
free(filenameComponentPGX);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Set the image_read parameters*/
|
||||
param_image_read[it_file].x0 = 0;
|
||||
param_image_read[it_file].y0 = 0;
|
||||
param_image_read[it_file].dx = 0;
|
||||
param_image_read[it_file].dy = 0;
|
||||
param_image_read[it_file].h = image_read->comps->h;
|
||||
param_image_read[it_file].w = image_read->comps->w;
|
||||
param_image_read[it_file].bpp = image_read->comps->bpp;
|
||||
param_image_read[it_file].prec = image_read->comps->prec;
|
||||
param_image_read[it_file].sgnd = image_read->comps->sgnd;
|
||||
|
||||
/* Copy data*/
|
||||
data[it_file] = malloc(param_image_read[it_file].h * param_image_read[it_file].w * sizeof(int));
|
||||
memcpy(data[it_file], image_read->comps->data, image_read->comps->h * image_read->comps->w * sizeof(int));
|
||||
|
||||
/* Free memory*/
|
||||
opj_image_destroy(image_read);
|
||||
free(filenameComponentPGX);
|
||||
}
|
||||
|
||||
image = opj_image_create((OPJ_UINT32)nbFilenamePGX, param_image_read, OPJ_CLRSPC_UNSPECIFIED);
|
||||
for (it_file = 0; it_file < nbFilenamePGX; it_file++)
|
||||
{
|
||||
/* Copy data into output image and free memory*/
|
||||
memcpy(image->comps[it_file].data, data[it_file], image->comps[it_file].h * image->comps[it_file].w * sizeof(int));
|
||||
free(data[it_file]);
|
||||
}
|
||||
|
||||
/* Free memory*/
|
||||
free(param_image_read);
|
||||
free(data);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static opj_image_t* readImageFromFileTIF(const char* filename, int nbFilenamePGX, const char *separator)
|
||||
{
|
||||
int it_file;
|
||||
|
@ -385,6 +473,7 @@ static int get_decod_format(test_cmp_parameters* param)
|
|||
if( strcmp(base_ext,test_ext) != 0 ) return -1;
|
||||
if( strcmp(base_ext,".pgx") == 0 ) return PGX_DFMT;
|
||||
if( strcmp(base_ext,".tif") == 0 ) return TIF_DFMT;
|
||||
if( strcmp(base_ext,".ppm") == 0 ) return PXM_DFMT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -667,8 +756,12 @@ int main(int argc, char **argv)
|
|||
memsizetestfilename = (int)strlen(inParam.test_filename) + 1 + 5 + 2 + 4;
|
||||
|
||||
decod_format = get_decod_format(&inParam);
|
||||
if( decod_format == -1 ) goto cleanup;
|
||||
assert( decod_format == PGX_DFMT || decod_format == TIF_DFMT );
|
||||
if( decod_format == -1 )
|
||||
{
|
||||
fprintf( stderr, "Unhandled file format\n" );
|
||||
goto cleanup;
|
||||
}
|
||||
assert( decod_format == PGX_DFMT || decod_format == TIF_DFMT || decod_format == PXM_DFMT );
|
||||
|
||||
if( decod_format == PGX_DFMT )
|
||||
{
|
||||
|
@ -682,6 +775,12 @@ int main(int argc, char **argv)
|
|||
if ( imageBase == NULL )
|
||||
goto cleanup;
|
||||
}
|
||||
else if( decod_format == PXM_DFMT )
|
||||
{
|
||||
imageBase = readImageFromFilePPM( inParam.base_filename, nbFilenamePGXbase, "");
|
||||
if ( imageBase == NULL )
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
filenamePNGbase = (char*) malloc((size_t)memsizebasefilename);
|
||||
strcpy(filenamePNGbase, inParam.test_filename);
|
||||
|
@ -702,6 +801,12 @@ int main(int argc, char **argv)
|
|||
if ( imageTest == NULL )
|
||||
goto cleanup;
|
||||
}
|
||||
else if( decod_format == PXM_DFMT )
|
||||
{
|
||||
imageTest = readImageFromFilePPM(inParam.test_filename, nbFilenamePGXtest, "");
|
||||
if ( imageTest == NULL )
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
filenamePNGtest = (char*) malloc((size_t)memsizetestfilename);
|
||||
strcpy(filenamePNGtest, inParam.test_filename);
|
||||
|
|
|
@ -472,6 +472,78 @@ foreach(numFileJP2 RANGE 1 9)
|
|||
|
||||
endforeach()
|
||||
|
||||
#--------------------------------------------------------------------------
|
||||
# Tests about Kakadu/J2K file
|
||||
# try to decode
|
||||
# compare to ref file
|
||||
# non regression comparison
|
||||
|
||||
# Tolerances given by ???
|
||||
|
||||
set(kdu_j2k_conf_files
|
||||
a1_mono
|
||||
a2_colr
|
||||
a3_mono
|
||||
a4_colr
|
||||
a5_mono
|
||||
a6_mono_colr
|
||||
b1_mono
|
||||
b2_mono
|
||||
b3_mono
|
||||
c1_mono
|
||||
c2_mono
|
||||
d1_colr
|
||||
d2_colr
|
||||
e1_colr
|
||||
e2_colr
|
||||
f1_mono
|
||||
f2_mono
|
||||
g1_colr
|
||||
g2_colr
|
||||
g3_colr
|
||||
g4_colr
|
||||
)
|
||||
|
||||
foreach(kdu_file ${kdu_j2k_conf_files})
|
||||
|
||||
# Build filenames
|
||||
set( filenameInput "${kdu_file}.j2c" )
|
||||
set( filenameRef "${kdu_file}.ppm" )
|
||||
|
||||
add_test(NAME ETS-KDU-${filenameInput}-decode
|
||||
COMMAND opj_decompress
|
||||
-i ${INPUT_CONF}/${filenameInput}
|
||||
-o ${TEMP}/${filenameInput}.ppm
|
||||
)
|
||||
|
||||
add_test(NAME ETS-KDU-${filenameInput}-compare2ref
|
||||
COMMAND compare_images
|
||||
-b ${BASELINE_CONF}/${filenameRef}
|
||||
-t ${TEMP}/${filenameInput}.ppm
|
||||
-n 3
|
||||
-p 4:4:4
|
||||
-m 4:4:4
|
||||
-s b_t_
|
||||
)
|
||||
|
||||
set_tests_properties(ETS-KDU-${filenameInput}-compare2ref
|
||||
PROPERTIES DEPENDS
|
||||
ETS-KDU-${filenameInput}-decode)
|
||||
|
||||
add_test(NAME NR-KDU-${filenameInput}-compare2base
|
||||
COMMAND compare_images
|
||||
-b ${BASELINE_NR}/opj_${filenameRef}
|
||||
-t ${TEMP}/${filenameInput}.ppm
|
||||
-n 3
|
||||
-d
|
||||
-s b_t_
|
||||
)
|
||||
|
||||
set_tests_properties(NR-KDU-${filenameInput}-compare2base
|
||||
PROPERTIES DEPENDS
|
||||
ETS-KDU-${filenameInput}-decode)
|
||||
endforeach()
|
||||
|
||||
#--------------------------------------------------------------------------#
|
||||
#--------------------------------------------------------------------------#
|
||||
#--------------------------------------------------------------------------#
|
||||
|
|
Loading…
Reference in New Issue