Skip to content

Commit

Permalink
Merge pull request #579 from mayeut/lossless
Browse files Browse the repository at this point in the history
Correct lossless issue on linux x86
Fix #571
  • Loading branch information
mayeut committed Sep 11, 2015
2 parents 4f5ec07 + bac2c9e commit 5d95355
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/openjp2/tcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ void opj_tcd_makelayer( opj_tcd_t *tcd,
n = passno + 1;
continue;
}
if (dd / dr >= thresh)
if (thresh - (dd / dr) < DBL_EPSILON) /* do not rely on float equality, check with DBL_EPSILON margin */
n = passno + 1;
}

Expand Down
4 changes: 1 addition & 3 deletions tests/compare_images.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static void compare_images_help_display(void)
fprintf(stdout,"\n");
fprintf(stdout," -b \t REQUIRED \t filename to the reference/baseline PGX/TIF/PNM image \n");
fprintf(stdout," -t \t REQUIRED \t filename to the test PGX/TIF/PNM image\n");
fprintf(stdout," -n \t REQUIRED \t number of component of the image (used to generate correct filename)\n");
fprintf(stdout," -n \t REQUIRED \t number of component of the image (used to generate correct filename, not used when both input files are TIF)\n");
fprintf(stdout," -m \t OPTIONAL \t list of MSE tolerances, separated by : (size must correspond to the number of component) of \n");
fprintf(stdout," -p \t OPTIONAL \t list of PEAK tolerances, separated by : (size must correspond to the number of component) \n");
fprintf(stdout," -s \t OPTIONAL \t 1 or 2 filename separator to take into account PGX/PNM image with different components, "
Expand Down Expand Up @@ -279,8 +279,6 @@ static opj_image_t* readImageFromFileTIF(const char* filename, int nbFilenamePGX
return NULL;
}

/* \postconditions */
assert( image_read->numcomps == 1 || image_read->numcomps == 3 );
return image_read;
}

Expand Down
20 changes: 20 additions & 0 deletions tests/nonregression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,26 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST})
)
endif()
endif(JPYLYZER_EXECUTABLE)

# If lossless compression (simple test is 4 arguments), decompress & compare
list(LENGTH CMD_ARG_LIST_2 ARG_COUNT)
if (ARG_COUNT EQUAL 4)
# can we compare with the input image ?
if (${INPUT_FILENAME_NAME} MATCHES "\\.tif$")
add_test(NAME NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode
COMMAND opj_decompress -i ${OUTPUT_FILENAME} -o ${OUTPUT_FILENAME}.lossless.tif
)
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode PROPERTIES
DEPENDS NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-encode
)
add_test(NAME NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-compare
COMMAND compare_images -b ${INPUT_FILENAME} -t ${OUTPUT_FILENAME}.lossless.tif -n 1 -d
)
set_tests_properties(NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-compare PROPERTIES
DEPENDS NR-ENC-${INPUT_FILENAME_NAME}-${IT_TEST_ENC}-lossless-decode
)
endif()
endif()
endif()

# DECODER TEST SUITE
Expand Down
3 changes: 3 additions & 0 deletions tests/nonregression/test_suite.ctest.in
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ opj_compress -i @INPUT_NR_PATH@/pngsuite/ftp0n2c08.png -o @TEMP_PATH@/ftp0n2c08.
opj_compress -i @INPUT_NR_PATH@/pngsuite/ftp0n3p08.png -o @TEMP_PATH@/ftp0n3p08.png.jp2
opj_compress -i @INPUT_NR_PATH@/pngsuite/ftp1n3p08.png -o @TEMP_PATH@/ftp1n3p08.png.jp2

# issue 571 Lossless is not lossless on linux x86
opj_compress -i @INPUT_NR_PATH@/issue571.tif -o @TEMP_PATH@/issue571.tif.j2k

# DECODER TEST SUITE
opj_decompress -i @INPUT_NR_PATH@/Bretagne2.j2k -o @TEMP_PATH@/Bretagne2.j2k.pgx
opj_decompress -i @INPUT_NR_PATH@/_00042.j2k -o @TEMP_PATH@/_00042.j2k.pgx
Expand Down

0 comments on commit 5d95355

Please sign in to comment.