godot/thirdparty/basis_universal/encoder/basisu_astc_hdr_enc.h

// basisu_astc_hdr_enc.h
#pragma once
#include "basisu_enc.h"
#include "basisu_gpu_texture.h"
#include "../transcoder/basisu_astc_helpers.h"
#include "../transcoder/basisu_astc_hdr_core.h"

namespace basisu
{
	// This MUST be called before encoding any blocks.
	void astc_hdr_enc_init();

	const uint32_t MODE11_FIRST_ISE_RANGE =, MODE11_LAST_ISE_RANGE =;
	const uint32_t MODE7_PART1_FIRST_ISE_RANGE =, MODE7_PART1_LAST_ISE_RANGE =;
	const uint32_t MODE7_PART2_FIRST_ISE_RANGE =, MODE7_PART2_LAST_ISE_RANGE =;
	const uint32_t MODE11_PART2_FIRST_ISE_RANGE =, MODE11_PART2_LAST_ISE_RANGE =;
	const uint32_t MODE11_TOTAL_SUBMODES =; // plus an extra hidden submode, directly encoded, for direct, so really 9 (see tables 99/100 of the ASTC spec)
	const uint32_t MODE7_TOTAL_SUBMODES =;
		
	struct astc_hdr_codec_options
	{};

	struct astc_hdr_pack_results
	{};
			
	void interpolate_qlog12_colors(
		const int e[2][3],
		basist::half_float* pDecoded_half,
		vec3F* pDecoded_float,
		uint32_t n, uint32_t ise_weight_range);
		
	bool get_astc_hdr_mode_11_block_colors(
		const uint8_t* pEndpoints,
		basist::half_float* pDecoded_half,
		vec3F* pDecoded_float,
		uint32_t n, uint32_t ise_weight_range, uint32_t ise_endpoint_range);
		
	bool get_astc_hdr_mode_7_block_colors(
		const uint8_t* pEndpoints,
		basist::half_float* pDecoded_half,
		vec3F* pDecoded_float,
		uint32_t n, uint32_t ise_weight_range, uint32_t ise_endpoint_range);

	double eval_selectors(
		uint32_t num_pixels,
		uint8_t* pWeights,
		const basist::half_float* pBlock_pixels_half,
		uint32_t num_weight_levels,
		const basist::half_float* pDecoded_half,
		const astc_hdr_codec_options& coptions,
		uint32_t usable_selector_bitmask = UINT32_MAX);

	double compute_block_error(const basist::half_float* pOrig_block, const basist::half_float* pPacked_block, const astc_hdr_codec_options& coptions);

	// Encodes a 4x4 ASTC HDR block given a 4x4 array of source block pixels/texels.
	// Supports solid color blocks, mode 11 (all submodes), mode 7/1 partition (all submodes), 
	// and mode 7/2 partitions (all submodes) - 30 patterns, only the ones also in common with the BC6H format.
	// The packed ASTC weight grid dimensions are currently always 4x4 texels, but may be also 3x3 in the future.
	// This function is thread safe, i.e. it may be called from multiple encoding threads simultanously with different blocks.
	// 
	// Parameters:
	// pRGBPixels - An array of 48 (16 RGB) floats: the 4x4 block to pack
	// pPacked_block - A pointer to the packed ASTC HDR block
	// coptions - Codec options
	// pInternal_results - An optional pointer to details about how the block was packed, for statistics/debugging purposes. May be nullptr.
	// 
	// Requirements: 
	// astc_hdr_enc_init() MUST have been called first to initialized the codec.
	// Input pixels are checked and cannot be NaN's, Inf's, signed, or too large (greater than MAX_HALF_FLOAT, or 65504). 
	// Normal values and denormals are okay.
	bool astc_hdr_enc_block(
		const float* pRGBPixels,
		const astc_hdr_codec_options& coptions,
		basisu::vector<astc_hdr_pack_results> &all_results);

	bool astc_hdr_pack_results_to_block(basist::astc_blk& dst_blk, const astc_hdr_pack_results& results);
		
	bool astc_hdr_refine_weights(const basist::half_float* pSource_block, astc_hdr_pack_results& cur_results, const astc_hdr_codec_options& coptions, float bc6h_weight, bool* pImproved_flag);

	struct astc_hdr_block_stats
	{};
		
} // namespace basisu