Use block encoding to store intermediate selectors after endpoint quantization

This change simplifies further modification of the code.

Explanation:
This change is required for further optimization of the quantization code.

Testing:
The modified algorithm has been tested on the Kodak test set using 64-bit build with default settings (running on Windows 10, i7-4790, 3.6GHz). All the decompressed test images are identical to the images being compressed and decompressed using original version of Crunch.

[Compressing Kodak set without mipmaps]
Original: 1582222 bytes / 28.935 sec
Modified: 1494501 bytes / 24.528 sec
Improvement: 5.54% (compression ratio) / 15.23% (compression time)

[Compressing Kodak set with mipmaps]
Original: 2065243 bytes / 36.982 sec
Modified: 1945365 bytes / 32.308 sec
Improvement: 5.80% (compression ratio) / 12.64% (compression time)
This commit is contained in:
Alexander Suvorov
2017-05-18 13:44:04 +02:00
parent 1ef829ed6f
commit b8349dfac8
7 changed files with 208 additions and 196 deletions
+8 -1
View File
@@ -341,6 +341,10 @@ void dxt1_endpoint_optimizer::return_solution(results& res, const potential_solu
invert_selectors = (solution.m_coords.m_low_color < solution.m_coords.m_high_color);
}
res.m_alternate_rounding = solution.m_alternate_rounding;
res.m_enforce_selector = solution.m_enforce_selector;
res.m_enforced_selector = solution.m_enforced_selector;
res.m_reordered = invert_selectors;
if (invert_selectors) {
res.m_low_color = solution.m_coords.m_high_color;
res.m_high_color = solution.m_coords.m_low_color;
@@ -1539,11 +1543,13 @@ bool dxt1_endpoint_optimizer::evaluate_solution_uber(
solution.m_error = trial_error;
solution.m_alpha_block = (block_type != 0);
solution.m_selectors = m_trial_selectors;
solution.m_alternate_rounding = alternate_rounding;
solution.m_valid = true;
}
}
if ((!solution.m_alpha_block) && (solution.m_coords.m_low_color == solution.m_coords.m_high_color)) {
solution.m_enforce_selector = !solution.m_alpha_block && solution.m_coords.m_low_color == solution.m_coords.m_high_color;
if (solution.m_enforce_selector) {
uint s;
if ((solution.m_coords.m_low_color & 31) != 31) {
solution.m_coords.m_low_color++;
@@ -1555,6 +1561,7 @@ bool dxt1_endpoint_optimizer::evaluate_solution_uber(
for (uint i = 0; i < m_unique_colors.size(); i++)
solution.m_selectors[i] = static_cast<uint8>(s);
solution.m_enforced_selector = s;
}
if ((pBest_solution) && (solution.m_error < pBest_solution->m_error)) {