From 4f5ec07c315872bdee0885be085ebf57cede2db9 Mon Sep 17 00:00:00 2001 From: mayeut Date: Wed, 9 Sep 2015 23:38:46 +0200 Subject: Remove C++ comment --- src/bin/common/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/bin/common/color.c b/src/bin/common/color.c index 98a4cec8..d38f3372 100644 --- a/src/bin/common/color.c +++ b/src/bin/common/color.c @@ -581,7 +581,7 @@ void color_apply_conversion(opj_image_t *image) row = (int*)image->icc_profile_buf; enumcs = row[0]; - if(enumcs == 14)// CIELab + if(enumcs == 14) /* CIELab */ { int *L, *a, *b, *red, *green, *blue; int *src0, *src1, *src2, *dst0, *dst1, *dst2; -- cgit v1.2.3 From 5f02757eef51dc834401e2ba5500312a9edab95e Mon Sep 17 00:00:00 2001 From: mayeut Date: Thu, 10 Sep 2015 00:39:23 +0200 Subject: Correct lossless issue on linux x86 Update uclouvain/openjpeg#571 --- src/lib/openjp2/tcd.c | 4 ++-- tests/compare_images.c | 2 +- tests/nonregression/CMakeLists.txt | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 8f1c9410..df9272ff 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -268,7 +268,7 @@ void opj_tcd_makelayer( opj_tcd_t *tcd, n = passno + 1; continue; } - if (dd / dr >= thresh) + if (dd / dr > thresh) n = passno + 1; } @@ -565,7 +565,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd, opj_t2_destroy(t2); } else { success = OPJ_TRUE; - goodthresh = min; + goodthresh = min - DBL_MAX; /* do not rely on float equality for lossless transform */ } if (!success) { diff --git a/tests/compare_images.c b/tests/compare_images.c index cb1b1301..fa15d13e 100644 --- a/tests/compare_images.c +++ b/tests/compare_images.c @@ -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, " diff --git a/tests/nonregression/CMakeLists.txt b/tests/nonregression/CMakeLists.txt index 2527f8cb..5ce37c81 100644 --- a/tests/nonregression/CMakeLists.txt +++ b/tests/nonregression/CMakeLists.txt @@ -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 -- cgit v1.2.3 From ccdce606f1baa945e5c717064bc17e8218b7cb29 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 10 Sep 2015 15:10:14 +0200 Subject: Fix threshold calculation It doesn't change the outcome of the test suite, that's weird... --- src/lib/openjp2/tcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index df9272ff..d227e388 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -565,7 +565,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd, opj_t2_destroy(t2); } else { success = OPJ_TRUE; - goodthresh = min - DBL_MAX; /* do not rely on float equality for lossless transform */ + goodthresh = min - DBL_EPSILON; /* do not rely on float equality for lossless transform */ } if (!success) { -- cgit v1.2.3 From ee0f3138482fc5ef44f92e6164206bc8df34efe4 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Thu, 10 Sep 2015 15:46:51 +0200 Subject: Update check in opj_tcd_makelayer to be robust to different float precisions --- src/lib/openjp2/tcd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index d227e388..32db260b 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -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; } @@ -565,7 +565,7 @@ OPJ_BOOL opj_tcd_rateallocate( opj_tcd_t *tcd, opj_t2_destroy(t2); } else { success = OPJ_TRUE; - goodthresh = min - DBL_EPSILON; /* do not rely on float equality for lossless transform */ + goodthresh = min; } if (!success) { -- cgit v1.2.3 From bac2c9e0a37a79a35e39cbe18572ec40bcfc3f29 Mon Sep 17 00:00:00 2001 From: Matthieu Darbois Date: Fri, 11 Sep 2015 14:17:30 +0200 Subject: Change test in opj_tcd_makelayer Remove float equality test. Such a test has no meaning. --- src/lib/openjp2/tcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/openjp2/tcd.c b/src/lib/openjp2/tcd.c index 32db260b..2fccff1c 100644 --- a/src/lib/openjp2/tcd.c +++ b/src/lib/openjp2/tcd.c @@ -268,7 +268,7 @@ void opj_tcd_makelayer( opj_tcd_t *tcd, n = passno + 1; continue; } - if (thresh - (dd / dr) <= DBL_EPSILON) /* do not rely on float equality, check with DBL_EPSILON margin */ + if (thresh - (dd / dr) < DBL_EPSILON) /* do not rely on float equality, check with DBL_EPSILON margin */ n = passno + 1; } -- cgit v1.2.3 From 49cbc11a194d41876da05481b05989248b35f8f6 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 13 Sep 2015 14:42:56 +0200 Subject: Correct leak in color_cielab_to_rgb --- src/bin/common/color.c | 8 ++++---- src/bin/common/color.h | 2 +- src/bin/jp2/opj_decompress.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/bin/common/color.c b/src/bin/common/color.c index d38f3372..f4fe7f10 100644 --- a/src/bin/common/color.c +++ b/src/bin/common/color.c @@ -599,13 +599,13 @@ void color_apply_conversion(opj_image_t *image) transform = cmsCreateTransform(in, TYPE_Lab_DBL, out, TYPE_RGB_16, INTENT_PERCEPTUAL, 0); -#ifdef HAVE_LIBLCMS2 +#ifdef OPJ_HAVE_LIBLCMS2 cmsCloseProfile(in); cmsCloseProfile(out); #endif if(transform == NULL) { -#ifdef HAVE_LIBLCMS1 +#ifdef OPJ_HAVE_LIBLCMS1 cmsCloseProfile(in); cmsCloseProfile(out); #endif @@ -662,7 +662,7 @@ void color_apply_conversion(opj_image_t *image) *blue++ = RGB[2]; } cmsDeleteTransform(transform); -#ifdef HAVE_LIBLCMS1 +#ifdef OPJ_HAVE_LIBLCMS1 cmsCloseProfile(in); cmsCloseProfile(out); #endif @@ -681,7 +681,7 @@ void color_apply_conversion(opj_image_t *image) fprintf(stderr,"%s:%d:\n\tenumCS %d not handled. Ignoring.\n", __FILE__,__LINE__, enumcs); }// color_apply_conversion() -#endif // HAVE_LIBLCMS2 || HAVE_LIBLCMS1 +#endif // OPJ_HAVE_LIBLCMS2 || OPJ_HAVE_LIBLCMS1 void color_cmyk_to_rgb(opj_image_t *image) { diff --git a/src/bin/common/color.h b/src/bin/common/color.h index c329f87f..0cd78e89 100644 --- a/src/bin/common/color.h +++ b/src/bin/common/color.h @@ -40,7 +40,7 @@ extern void color_sycc_to_rgb(opj_image_t *img); extern void color_apply_icc_profile(opj_image_t *image); -extern void color_apply_conversion(opj_image_t *image); +extern void color_cielab_to_rgb(opj_image_t *image); extern void color_cmyk_to_rgb(opj_image_t *image); extern void color_esycc_to_rgb(opj_image_t *image); diff --git a/src/bin/jp2/opj_decompress.c b/src/bin/jp2/opj_decompress.c index ac17b69d..da566ac2 100644 --- a/src/bin/jp2/opj_decompress.c +++ b/src/bin/jp2/opj_decompress.c @@ -1371,7 +1371,7 @@ int main(int argc, char **argv) if(image->icc_profile_len) color_apply_icc_profile(image); else - color_apply_conversion(image); + color_cielab_to_rgb(image); #endif free(image->icc_profile_buf); image->icc_profile_buf = NULL; image->icc_profile_len = 0; -- cgit v1.2.3 From c8a31176590fe1666bf821bc1479f28cb25b5f6a Mon Sep 17 00:00:00 2001 From: mayeut Date: Sun, 13 Sep 2015 14:51:00 +0200 Subject: Fix function name --- src/bin/common/color.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/bin/common/color.c b/src/bin/common/color.c index f4fe7f10..3b0eb97b 100644 --- a/src/bin/common/color.c +++ b/src/bin/common/color.c @@ -562,7 +562,7 @@ fprintf(stderr,"%s:%d:color_apply_icc_profile\n\tcmsCreateTransform failed. " #endif }/* color_apply_icc_profile() */ -void color_apply_conversion(opj_image_t *image) +void color_cielab_to_rgb(opj_image_t *image) { int *row; int enumcs, numcomps; -- cgit v1.2.3