summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-04-18 13:12:03 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-04-18 15:43:07 +0900
commit7ff410b9f611b0629cad0944150e47288db7e5ec (patch)
treea12084c942b022dd0a62808fe4753d463f6b3a4b
parentd531816b1240199b7d3e510cce4238cac79f83a8 (diff)
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.
-rw-r--r--src/bin/edje/edje_cc_out.c11
-rw-r--r--src/lib/eet/eet_image.c7
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 3302fa6..7691bab 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)
704 "bmp", 704 "bmp",
705 "ico", 705 "ico",
706 "tga", 706 "tga",
707 "tgv",
707 NULL 708 NULL
708 }; 709 };
709 710
@@ -754,7 +755,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
754 if ((iw->data) && (iw->w > 0) && (iw->h > 0)) 755 if ((iw->data) && (iw->w > 0) && (iw->h > 0))
755 { 756 {
756 Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS; 757 Eet_Image_Encoding lossy = EET_IMAGE_LOSSLESS;
757 int mode, qual; 758 int mode, qual, comp = 0;
758 759
759 snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id); 760 snprintf(buf, sizeof(buf), "edje/images/%i", iw->img->id);
760 qual = 80; 761 qual = 80;
@@ -787,7 +788,11 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
787 if (qual < min_quality) qual = min_quality; 788 if (qual < min_quality) qual = min_quality;
788 if (qual > max_quality) qual = max_quality; 789 if (qual > max_quality) qual = max_quality;
789 if (!allow_etc1 || (iw->alpha)) lossy = EET_IMAGE_JPEG; 790 if (!allow_etc1 || (iw->alpha)) lossy = EET_IMAGE_JPEG;
790 else lossy = EET_IMAGE_ETC1; 791 else
792 {
793 lossy = EET_IMAGE_ETC1;
794 comp = !no_comp;
795 }
791 } 796 }
792 if (iw->alpha) 797 if (iw->alpha)
793 { 798 {
@@ -819,7 +824,7 @@ data_thread_image(void *data, Ecore_Thread *thread EINA_UNUSED)
819 bytes = eet_data_image_write(iw->ef, buf, 824 bytes = eet_data_image_write(iw->ef, buf,
820 iw->data, iw->w, iw->h, 825 iw->data, iw->w, iw->h,
821 iw->alpha, 826 iw->alpha,
822 0, qual, lossy); 827 comp, qual, lossy);
823 if (bytes <= 0) 828 if (bytes <= 0)
824 { 829 {
825 snprintf(buf2, sizeof(buf2), 830 snprintf(buf2, sizeof(buf2),
diff --git a/src/lib/eet/eet_image.c b/src/lib/eet/eet_image.c
index d5bda22..58e7df5 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,
995 995
996static void * 996static void *
997eet_data_image_etc1_compressed_convert(int *size, 997eet_data_image_etc1_compressed_convert(int *size,
998 const unsigned char *data, 998 const unsigned char *data8,
999 unsigned int w, 999 unsigned int w,
1000 unsigned int h, 1000 unsigned int h,
1001 int quality, 1001 int quality,
@@ -1009,6 +1009,7 @@ eet_data_image_etc1_compressed_convert(int *size,
1009 unsigned int x, y; 1009 unsigned int x, y;
1010 unsigned int compress_length; 1010 unsigned int compress_length;
1011 unsigned int real_x, real_y; 1011 unsigned int real_x, real_y;
1012 unsigned int *data = (unsigned int *) data8;
1012 char *comp; 1013 char *comp;
1013 char *buffer; 1014 char *buffer;
1014 void *result; 1015 void *result;
@@ -1106,7 +1107,7 @@ eet_data_image_etc1_compressed_convert(int *size,
1106 1107
1107 if (lmax > 0) 1108 if (lmax > 0)
1108 { 1109 {
1109 for (k = duplicate_h[0]; k < kmax; k++) 1110 for (k = 0; k < kmax; k++)
1110 memcpy(&todo[(k + duplicate_h[0]) * 16 + duplicate_w[0] * 4], 1111 memcpy(&todo[(k + duplicate_h[0]) * 16 + duplicate_w[0] * 4],
1111 &data[(real_y + i + k) * w + real_x + j], 1112 &data[(real_y + i + k) * w + real_x + j],
1112 4 * lmax); 1113 4 * lmax);
@@ -1147,7 +1148,7 @@ eet_data_image_etc1_compressed_convert(int *size,
1147 1148
1148 if (compression) 1149 if (compression)
1149 { 1150 {
1150 wlen = LZ4_compress(buffer, comp, block_count * 8); 1151 wlen = LZ4_compressHC(buffer, comp, block_count * 8);
1151 } 1152 }
1152 else 1153 else
1153 { 1154 {