b8349dfac8
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)
63 lines
1.3 KiB
C++
63 lines
1.3 KiB
C++
// File: crn_dxt5a.h
|
|
// See Copyright Notice and license at the end of inc/crnlib.h
|
|
#pragma once
|
|
#include "crn_dxt.h"
|
|
|
|
namespace crnlib {
|
|
class dxt5_endpoint_optimizer {
|
|
public:
|
|
dxt5_endpoint_optimizer();
|
|
|
|
struct params {
|
|
params()
|
|
: m_block_index(0),
|
|
m_pPixels(NULL),
|
|
m_num_pixels(0),
|
|
m_comp_index(3),
|
|
m_quality(cCRNDXTQualityUber),
|
|
m_use_both_block_types(true) {
|
|
}
|
|
|
|
uint m_block_index;
|
|
|
|
const color_quad_u8* m_pPixels;
|
|
uint m_num_pixels;
|
|
uint m_comp_index;
|
|
|
|
crn_dxt_quality m_quality;
|
|
|
|
bool m_use_both_block_types;
|
|
};
|
|
|
|
struct results {
|
|
uint8* m_pSelectors;
|
|
|
|
uint64 m_error;
|
|
|
|
uint8 m_first_endpoint;
|
|
uint8 m_second_endpoint;
|
|
|
|
uint8 m_block_type; // 1 if 6-alpha, otherwise 8-alpha
|
|
bool m_reordered;
|
|
};
|
|
|
|
bool compute(const params& p, results& r);
|
|
|
|
private:
|
|
const params* m_pParams;
|
|
results* m_pResults;
|
|
|
|
crnlib::vector<uint8> m_unique_values;
|
|
crnlib::vector<uint> m_unique_value_weights;
|
|
|
|
crnlib::vector<uint8> m_trial_selectors;
|
|
crnlib::vector<uint8> m_best_selectors;
|
|
int m_unique_value_map[256];
|
|
|
|
sparse_bit_array m_flags;
|
|
|
|
void evaluate_solution(uint low_endpoint, uint high_endpoint);
|
|
};
|
|
|
|
} // namespace crnlib
|