From 7ff410b9f611b0629cad0944150e47288db7e5ec Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Fri, 18 Apr 2014 13:12:03 +0900 Subject: [PATCH] Edje: Fix ETC1 encoding with EET and Edje There were a few critical issues: - Invalid pointer arithmetics on the input data (char vs. int) - Invalid logic in the pixel duplication code All of these due to bad copy and paste :( Also, use LZ4HC instead of LZ4 when compression is enabled. ETC1 encoding is so damn slow you won't see the difference between LZ4 and LZ4HC compression times. --- src/bin/edje/edje_cc_out.c | 11 ++++++++--- src/lib/eet/eet_image.c | 7 ++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/bin/edje/edje_cc_out.c b/src/bin/edje/edje_cc_out.c index 3302fa6768..7691bab425 100644 --- a/src/bin/edje/edje_cc_out.c +++ b/src/bin/edje/edje_cc_out.c @@ -704,6 +704,7 @@ error_and_abort_image_load_error(Eet_File *ef, const char *file, int error) "bmp", "ico", "tga", + "tgv", NULL }; @@ -754,7 +755,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED) if ((iw->data) && (iw->w > 0) && (iw->h > 0)) { Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS; - int mode, qual; + int mode, qual, comp = 0; snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id); qual = 80; @@ -787,7 +788,11 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED) if (qual < min_quality) qual = min_quality; if (qual > max_quality) qual = max_quality; if (!allow_etc1 || (iw->alpha)) lossy = EET_IMAGE_JPEG; - else lossy = EET_IMAGE_ETC1; + else + { + lossy = EET_IMAGE_ETC1; + comp = !no_comp; + } } if (iw->alpha) { @@ -819,7 +824,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED) bytes = eet_data_image_write(iw->ef, buf, iw->data, iw->w, iw->h, iw->alpha, - 0, qual, lossy); + comp, qual, lossy); if (bytes <= 0) { snprintf(buf2, sizeof(buf2), diff --git a/src/lib/eet/eet_image.c b/src/lib/eet/eet_image.c index d5bda22d66..58e7df59ee 100644 --- a/src/lib/eet/eet_image.c +++ b/src/lib/eet/eet_image.c @@ -995,7 +995,7 @@ eet_data_image_lossless_compressed_convert(int *size, static void * eet_data_image_etc1_compressed_convert(int *size, - const unsigned char *data, + const unsigned char *data8, unsigned int w, unsigned int h, int quality, @@ -1009,6 +1009,7 @@ eet_data_image_etc1_compressed_convert(int *size, unsigned int x, y; unsigned int compress_length; unsigned int real_x, real_y; + unsigned int *data = (unsigned int *) data8; char *comp; char *buffer; void *result; @@ -1106,7 +1107,7 @@ eet_data_image_etc1_compressed_convert(int *size, if (lmax > 0) { - for (k = duplicate_h[0]; k < kmax; k++) + for (k = 0; k < kmax; k++) memcpy(&todo[(k + duplicate_h[0]) * 16 + duplicate_w[0] * 4], &data[(real_y + i + k) * w + real_x + j], 4 * lmax); @@ -1147,7 +1148,7 @@ eet_data_image_etc1_compressed_convert(int *size, if (compression) { - wlen = LZ4_compress(buffer, comp, block_count * 8); + wlen = LZ4_compressHC(buffer, comp, block_count * 8); } else {