From 17e73dca0560013ce00277c8cf399461b26442b9 Mon Sep 17 00:00:00 2001 From: pierre lamot Date: Tue, 20 Jan 2015 15:39:08 +0100 Subject: evas: jpeg decoders alows a difference of 1 bit per component. The required precision of decompressed images allows a difference of 1 bit for each pixel compoment [1] . Such difference has been noticed on OSX when using libjpeg9 from macports. evas_suite images tests has been modified to compare jpeg images with this tolerance. Other image formats are still compare with exact precision [1] http://en.wikipedia.org/wiki/JPEG#Required_precision Signed-off-by: Cedric BAIL --- src/tests/evas/evas_test_image.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/tests/evas/evas_test_image.c') diff --git a/src/tests/evas/evas_test_image.c b/src/tests/evas/evas_test_image.c index ed339e6d14..cb3ff690e6 100644 --- a/src/tests/evas/evas_test_image.c +++ b/src/tests/evas/evas_test_image.c @@ -356,8 +356,9 @@ START_TEST(evas_object_image_all_loader_data) for (i = 0; i < sizeof (exts) / sizeof (exts[0]); i++) { struct stat st; - int w, h, r_w, r_h; + int w, h, s, r_w, r_h, r_s; const uint32_t *d, *r_d; + Evas_Colorspace c, r_c; eina_strbuf_reset(str); @@ -368,6 +369,8 @@ START_TEST(evas_object_image_all_loader_data) evas_object_image_file_set(obj, eina_strbuf_string_get(str), NULL); fail_if(evas_object_image_load_error_get(obj) != EVAS_LOAD_ERROR_NONE); evas_object_image_size_get(obj, &w, &h); + s = evas_object_image_stride_get(obj); + c = evas_object_image_colorspace_get(obj); d = evas_object_image_data_get(obj, EINA_FALSE); eina_strbuf_reset(str); @@ -376,10 +379,26 @@ START_TEST(evas_object_image_all_loader_data) evas_object_image_file_set(ref, eina_strbuf_string_get(str), NULL); fail_if(evas_object_image_load_error_get(ref) != EVAS_LOAD_ERROR_NONE); evas_object_image_size_get(ref, &r_w, &r_h); + r_s = evas_object_image_stride_get(ref); + r_c = evas_object_image_colorspace_get(ref); r_d = evas_object_image_data_get(ref, EINA_FALSE); fail_if(w != r_w || h != r_h); - fail_if(memcmp(d, r_d, w * h * 4)); + fail_if(s != r_s); + fail_if(c != r_c); + fail_if(w*4 != s); + if (strcmp(exts[i], "jpeg") == 0 || strcmp(exts[i], "jpg") == 0) + { + //jpeg norm allows a variation of 1 bit per component + for (int j = 0; j < s * h; j++) + { + fail_if(abs(((char*)d)[j] - ((char*)r_d)[j]) > 1); + } + } + else + { + fail_if(memcmp(d, r_d, w * h * 4)); + } } evas_object_del(obj); -- cgit v1.2.1