Only checks 4 tables.
| 15735 | |
| 15736 | // Only checks 4 tables. |
| 15737 | static void pack_eac(eac_block& blk, const uint8_t* pPixels, uint32_t stride) |
| 15738 | { |
| 15739 | uint32_t min_alpha = 255, max_alpha = 0; |
| 15740 | for (uint32_t i = 0; i < 16; i++) |
| 15741 | { |
| 15742 | const uint32_t a = pPixels[i * stride]; |
| 15743 | if (a < min_alpha) min_alpha = a; |
| 15744 | if (a > max_alpha) max_alpha = a; |
| 15745 | } |
| 15746 | |
| 15747 | if (min_alpha == max_alpha) |
| 15748 | { |
| 15749 | pack_eac_solid_block(blk, min_alpha); |
| 15750 | return; |
| 15751 | } |
| 15752 | |
| 15753 | const uint32_t alpha_range = max_alpha - min_alpha; |
| 15754 | |
| 15755 | const uint32_t SINGLE_TABLE_THRESH = 5; |
| 15756 | if (alpha_range <= SINGLE_TABLE_THRESH) |
| 15757 | { |
| 15758 | // If alpha_range <= 5 table 13 is lossless |
| 15759 | int base = clamp255((int)max_alpha - 2); |
| 15760 | |
| 15761 | blk.m_base = base; |
| 15762 | blk.m_multiplier = 1; |
| 15763 | blk.m_table = 13; |
| 15764 | |
| 15765 | base -= 3; |
| 15766 | |
| 15767 | uint64_t packed_sels = 0; |
| 15768 | for (uint32_t i = 0; i < 16; i++) |
| 15769 | { |
| 15770 | const int a = pPixels[i * stride]; |
| 15771 | |
| 15772 | static const uint8_t s_sels[6] = { 2, 1, 0, 4, 5, 6 }; |
| 15773 | |
| 15774 | int sel = a - base; |
| 15775 | assert(sel >= 0 && sel <= 5); |
| 15776 | |
| 15777 | packed_sels |= (static_cast<uint64_t>(s_sels[sel]) << s_etc2_eac_bit_ofs[i]); |
| 15778 | } |
| 15779 | |
| 15780 | blk.set_selector_bits(packed_sels); |
| 15781 | |
| 15782 | return; |
| 15783 | } |
| 15784 | |
| 15785 | const uint32_t T0 = 2, T1 = 8, T2 = 11, T3 = 13; |
| 15786 | static const uint8_t s_tables[4] = { T0, T1, T2, T3 }; |
| 15787 | |
| 15788 | int base[4], mul[4]; |
| 15789 | uint32_t mul_or = 0; |
| 15790 | for (uint32_t i = 0; i < 4; i++) |
| 15791 | { |
| 15792 | const uint32_t table = s_tables[i]; |
| 15793 | |
| 15794 | const float range = (float)(g_eac_modifier_table[table][ETC2_EAC_MAX_VALUE_SELECTOR] - g_eac_modifier_table[table][ETC2_EAC_MIN_VALUE_SELECTOR]); |
nothing calls this directly
no test coverage detected