#include "basisu_uastc_enc.h"
#include "3rdparty/android_astc_decomp.h"
#include "basisu_gpu_texture.h"
#include "basisu_bc7enc.h"
#ifdef _DEBUG
#define BASISU_VALIDATE_UASTC_ENC …
#endif
#define BASISU_SUPPORT_FORCE_MODE …
usingnamespacebasist;
namespace basisu
{
const uint32_t MAX_ENCODE_RESULTS = …;
#if BASISU_VALIDATE_UASTC_ENC
static void validate_func(bool condition, int line)
{
if (!condition)
{
fprintf(stderr, "basisu_uastc_enc: Internal validation failed on line %u!\n", line);
}
}
#define VALIDATE …
#else
#define VALIDATE(c) …
#endif
enum dxt_constants
{ … };
struct dxt1_block
{ … };
#define UASTC_WRITE_MODE_DESCS …
static inline void uastc_write_bits(uint8_t* pBuf, uint32_t& bit_offset, uint64_t code, uint32_t codesize, const char* pDesc)
{ … }
void pack_uastc(basist::uastc_block& blk, const uastc_encode_results& result, const etc_block& etc1_blk, uint32_t etc1_bias, const eac_a8_block& etc_eac_a8_blk, bool bc1_hint0, bool bc1_hint1)
{ … }
static void astc_mode0_or_18(uint32_t mode, const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params, const uint8_t *pForce_selectors = nullptr)
{ … }
static void astc_mode1(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static uint32_t estimate_partition2(uint32_t num_weights, uint32_t num_comps, const uint32_t* pWeights, const color_rgba block[4][4], const uint32_t weights[4])
{ … }
static void astc_mode2(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params, bool estimate_partition)
{ … }
static void astc_mode3(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params, bool estimate_partition)
{ … }
static void astc_mode4(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params, bool estimate_partition)
{ … }
static void astc_mode5(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode6(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode7(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params, bool estimate_partition)
{ … }
static void estimate_partition2_list(uint32_t num_weights, uint32_t num_comps, const uint32_t* pWeights, const color_rgba block[4][4], uint32_t* pParts, uint32_t max_parts, const uint32_t weights[4])
{ … }
static void astc_mode9_or_16(uint32_t mode, const color_rgba source_block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params, uint32_t estimate_partition_list_size)
{ … }
static void astc_mode10(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode11_or_17(uint32_t mode, const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode12(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode13(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode14(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void astc_mode15(const color_rgba block[4][4], uastc_encode_results* pResults, uint32_t& total_results, bc7enc_compress_block_params& comp_params)
{ … }
static void compute_block_error(const color_rgba block[4][4], const color_rgba decoded_block[4][4], uint64_t &total_rgb_err, uint64_t &total_rgba_err, uint64_t &total_la_err)
{ … }
static void compute_bc1_hints(bool &bc1_hint0, bool &bc1_hint1, const uastc_encode_results &best_results, const color_rgba block[4][4], const color_rgba decoded_uastc_block[4][4])
{ … }
struct ycbcr
{ … };
static inline void rgb_to_y_cb_cr(const color_rgba& c, ycbcr& dst)
{ … }
static inline uint64_t color_diff(const ycbcr& a, const ycbcr& b)
{ … }
static inline int gray_distance2(const color_rgba& c, int r, int g, int b)
{ … }
static bool pack_etc1_estimate_flipped(const color_rgba* pSrc_pixels)
{ … }
static void compute_etc1_hints(etc_block& best_etc1_blk, uint32_t& best_etc1_bias, const uastc_encode_results& best_results, const color_rgba block[4][4], const color_rgba decoded_uastc_block[4][4], int level, uint32_t flags)
{ … }
struct uastc_pack_eac_a8_results
{ … };
static uint64_t uastc_pack_eac_a8(uastc_pack_eac_a8_results& results, const uint8_t* pPixels, uint32_t num_pixels, uint32_t base_search_rad, uint32_t mul_search_rad, uint32_t table_mask)
{ … }
const int32_t DEFAULT_BC7_ERROR_WEIGHT = …;
const float UASTC_ERROR_THRESH = …;
static inline float get_uastc_mode_weight(uint32_t mode)
{ … }
void encode_uastc(const uint8_t* pRGBAPixels, uastc_block& output_block, uint32_t flags)
{ … }
static bool uastc_recompute_hints(basist::uastc_block* pBlock, const color_rgba* pBlock_pixels, uint32_t flags, const unpacked_uastc_block *pUnpacked_blk)
{ … }
static const uint8_t g_uastc_mode_selector_bits[TOTAL_UASTC_MODES][2] = …;
static inline uint32_t set_block_bits(uint8_t* pBytes, uint64_t val, uint32_t num_bits, uint32_t cur_ofs)
{ … }
static const uint8_t g_tdefl_small_dist_extra[512] = …;
static const uint8_t g_tdefl_large_dist_extra[128] = …;
static inline uint32_t compute_match_cost_estimate(uint32_t dist)
{ … }
struct selector_bitsequence
{ … };
struct selector_bitsequence_hash
{ … };
class tracked_stat
{ … };
static bool uastc_rdo_blocks(uint32_t first_index, uint32_t last_index, basist::uastc_block* pBlocks, const color_rgba* pBlock_pixels, const uastc_rdo_params& params, uint32_t flags,
uint32_t &total_skipped, uint32_t &total_refined, uint32_t &total_modified, uint32_t &total_smooth)
{ … }
bool uastc_rdo(uint32_t num_blocks, basist::uastc_block* pBlocks, const color_rgba* pBlock_pixels, const uastc_rdo_params& params, uint32_t flags, job_pool* pJob_pool, uint32_t total_jobs)
{ … }
}