summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-04-18 15:31:43 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-04-18 15:43:07 +0900
commitca0c608b66017d85bcaa3580c32000b7595d8e52 (patch)
treebdf8663c888695d18904a04d29ceb2dd7c22758d
parent7ff410b9f611b0629cad0944150e47288db7e5ec (diff)
rg_etc1: Fix encoding of solid color blocks
The ETC1 encoder is expected to write all 8 bytes of the output data. But in case of a solid color block, it was writing only 1 of the first 3 bytes (R, G, B). So lots of solid blocks were containing invalid data (for instance: R + dR < 0 or > 255).
-rw-r--r--src/static_libs/rg_etc/rg_etc1.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/static_libs/rg_etc/rg_etc1.c b/src/static_libs/rg_etc/rg_etc1.c
index a74b1f1..5be83fd 100644
--- a/src/static_libs/rg_etc/rg_etc1.c
+++ b/src/static_libs/rg_etc/rg_etc1.c
@@ -2088,8 +2088,11 @@ void rg_etc1_pack_block_init()
2088 break; 2088 break;
2089 } 2089 }
2090 } 2090 }
2091 // ERROR CASE NO ASSERT IN EVAS CODE 2091 if (!(best_error <= 255))
2092 if (!(best_error <= 255)) return ; 2092 {
2093 fprintf(stderr, "ETC1: Failed to write the inverse lookup table!\n");
2094 return;
2095 }
2093 rg_etc1_inverse_lookup[inverse_table_index][color] = (uint16)(best_packed_c | (best_error << 8)); 2096 rg_etc1_inverse_lookup[inverse_table_index][color] = (uint16)(best_packed_c | (best_error << 8));
2094 } 2097 }
2095 } 2098 }
@@ -2111,8 +2114,14 @@ void rg_etc1_pack_block_init()
2111static uint64 2114static uint64
2112rg_etc1_pack_block_solid_color(unsigned char *block, const uint8* pColor, rg_etc1_pack_params *pack_params EINA_UNUSED) 2115rg_etc1_pack_block_solid_color(unsigned char *block, const uint8* pColor, rg_etc1_pack_params *pack_params EINA_UNUSED)
2113{ 2116{
2114 // ERROR CASE NO ASSERT IN EVAS CODE 2117 if (!rg_etc1_inverse_lookup[0][255])
2115 if (!rg_etc1_inverse_lookup[0][255]) return 0; 2118 rg_etc1_pack_block_init();
2119
2120 if (!rg_etc1_inverse_lookup[0][255])
2121 {
2122 fprintf(stderr, "ETC1: Inverse lookup table not set!\n");
2123 return 0;
2124 }
2116 2125
2117 static uint s_next_comp[4] = { 1, 2, 0, 1 }; 2126 static uint s_next_comp[4] = { 1, 2, 0, 1 };
2118 2127
@@ -2181,6 +2190,7 @@ rg_etc1_pack_block_solid_color(unsigned char *block, const uint8* pColor, rg_etc
2181 uint best_packed_c0; 2190 uint best_packed_c0;
2182 uint selector_val; 2191 uint selector_val;
2183 2192
2193 block[0] = block[1] = block[2] = 0;
2184 block[3] = (uint8)(((inten | (inten << 3)) << 2) | (diff << 1)); 2194 block[3] = (uint8)(((inten | (inten << 3)) << 2) | (diff << 1));
2185 2195
2186 etc1_selector = rg_etc_selector_index_to_etc1[(best_x >> 4) & 3]; 2196 etc1_selector = rg_etc_selector_index_to_etc1[(best_x >> 4) & 3];