godot/thirdparty/basis_universal/transcoder/basisu_transcoder_internal.h

// basisu_transcoder_internal.h - Universal texture format transcoder library.
// Copyright (C) 2019-2024 Binomial LLC. All Rights Reserved.
//
// Important: If compiling with gcc, be sure strict aliasing is disabled: -fno-strict-aliasing
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#ifdef _MSC_VER
#pragma warning (disable: 4127) //  conditional expression is constant
#endif

// v1.50: Added UASTC HDR support
#define BASISD_LIB_VERSION
#define BASISD_VERSION_STRING

#ifdef _DEBUG
#define BASISD_BUILD_DEBUG
#else
#define BASISD_BUILD_RELEASE
#endif

#include "basisu.h"

#define BASISD_znew

namespace basisu
{
	extern bool g_debug_printf;
}

namespace basist
{
	// Low-level formats directly supported by the transcoder (other supported texture formats are combinations of these low-level block formats).
	// You probably don't care about these enum's unless you are going pretty low-level and calling the transcoder to decode individual slices.
	enum class block_format
	{};

	const int COLOR5_PAL0_PREV_HI =, COLOR5_PAL0_DELTA_LO =, COLOR5_PAL0_DELTA_HI =;
	const int COLOR5_PAL1_PREV_HI =, COLOR5_PAL1_DELTA_LO =, COLOR5_PAL1_DELTA_HI =;
	const int COLOR5_PAL2_PREV_HI =, COLOR5_PAL2_DELTA_LO =, COLOR5_PAL2_DELTA_HI =;
	const int COLOR5_PAL_MIN_DELTA_B_RUNLEN =, COLOR5_PAL_DELTA_5_RUNLEN_VLC_BITS =;

	const uint32_t ENDPOINT_PRED_TOTAL_SYMBOLS =;
	const uint32_t ENDPOINT_PRED_REPEAT_LAST_SYMBOL =;
	const uint32_t ENDPOINT_PRED_MIN_REPEAT_COUNT =;
	const uint32_t ENDPOINT_PRED_COUNT_VLC_BITS =;

	const uint32_t NUM_ENDPOINT_PREDS =;// BASISU_ARRAY_SIZE(g_endpoint_preds);
	const uint32_t CR_ENDPOINT_PRED_INDEX =;
	const uint32_t NO_ENDPOINT_PRED_INDEX =;//NUM_ENDPOINT_PREDS;
	const uint32_t MAX_SELECTOR_HISTORY_BUF_SIZE =;
	const uint32_t SELECTOR_HISTORY_BUF_RLE_COUNT_THRESH =;
	const uint32_t SELECTOR_HISTORY_BUF_RLE_COUNT_BITS =;
	const uint32_t SELECTOR_HISTORY_BUF_RLE_COUNT_TOTAL =;
		
	uint16_t crc16(const void *r, size_t size, uint16_t crc);
		
	class huffman_decoding_table
	{};

	class bitwise_decoder
	{};

	inline uint32_t basisd_rand(uint32_t seed)
	{}

	// Returns random number in [0,limit). Max limit is 0xFFFF.
	inline uint32_t basisd_urand(uint32_t& seed, uint32_t limit)
	{}

	class approx_move_to_front
	{};

	struct decoder_etc_block;
	
	inline uint8_t clamp255(int32_t i)
	{}

	enum eNoClamp
	{};

	struct color32
	{};

	struct endpoint
	{};

	struct selector
	{};

	bool basis_block_format_is_uncompressed(block_format tex_type);

	//------------------------------------

	half_float;

	const double MIN_DENORM_HALF_FLOAT =; // smallest positive subnormal number
	const double MIN_HALF_FLOAT =; // smallest positive normal number
	const double MAX_HALF_FLOAT =; // largest normal number

	inline uint32_t get_bits(uint32_t val, int low, int high)
	{}

	inline bool is_half_inf_or_nan(half_float v)
	{}

	inline bool is_half_denorm(half_float v)
	{}

	inline int get_half_exp(half_float v)
	{}

	inline int get_half_mantissa(half_float v)
	{}

	inline float get_half_mantissaf(half_float v)
	{}

	inline int get_half_sign(half_float v)
	{}

	inline bool half_is_signed(half_float v)
	{}

#if 0
	int hexp = get_half_exp(Cf);
	float hman = get_half_mantissaf(Cf);
	int hsign = get_half_sign(Cf);
	float k = powf(2.0f, hexp) * hman * hsign;
	if (is_half_inf_or_nan(Cf))
		k = std::numeric_limits<float>::quiet_NaN();
#endif

	half_float float_to_half(float val);

	inline float half_to_float(half_float hval)
	{}

	// Originally from bc6h_enc.h

	void bc6h_enc_init();

	const uint32_t MAX_BLOG16_VAL =;

	// BC6H internals
	const uint32_t NUM_BC6H_MODES =;
	const uint32_t BC6H_LAST_MODE_INDEX =;
	const uint32_t BC6H_FIRST_1SUBSET_MODE_INDEX =; // in the MS docs, this is "mode 11" (where the first mode is 1), 60 bits for endpoints (10.10, 10.10, 10.10), 63 bits for weights
	const uint32_t TOTAL_BC6H_PARTITION_PATTERNS =;

	extern const uint8_t g_bc6h_mode_sig_bits[NUM_BC6H_MODES][4]; // base, r, g, b

	struct bc6h_bit_layout
	{};

	const uint32_t MAX_BC6H_LAYOUT_INDEX =;
	extern const bc6h_bit_layout g_bc6h_bit_layouts[NUM_BC6H_MODES][MAX_BC6H_LAYOUT_INDEX];

	extern const uint8_t g_bc6h_2subset_patterns[TOTAL_BC6H_PARTITION_PATTERNS][4][4]; // [y][x]

	extern const uint8_t g_bc6h_weight3[8];
	extern const uint8_t g_bc6h_weight4[16];

	extern const int8_t g_bc6h_mode_lookup[32];
		
	// Converts b16 to half float
	inline half_float bc6h_blog16_to_half(uint32_t comp)
	{}

	const uint32_t MAX_BC6H_HALF_FLOAT_AS_UINT =;

	// Inverts bc6h_blog16_to_half().
	// Returns the nearest blog16 given a half value. 
	inline uint32_t bc6h_half_to_blog16(half_float h)
	{}

	struct bc6h_block
	{};

	void bc6h_enc_block_mode10(bc6h_block* pPacked_block, const half_float pEndpoints[3][2], const uint8_t* pWeights);
	void bc6h_enc_block_1subset_4bit_weights(bc6h_block* pPacked_block, const half_float pEndpoints[3][2], const uint8_t* pWeights);
	void bc6h_enc_block_1subset_mode9_3bit_weights(bc6h_block* pPacked_block, const half_float pEndpoints[3][2], const uint8_t* pWeights);
	void bc6h_enc_block_1subset_3bit_weights(bc6h_block* pPacked_block, const half_float pEndpoints[3][2], const uint8_t* pWeights);
	void bc6h_enc_block_2subset_mode9_3bit_weights(bc6h_block* pPacked_block, uint32_t common_part_index, const half_float pEndpoints[2][3][2], const uint8_t* pWeights); // pEndpoints[subset][comp][lh_index]
	void bc6h_enc_block_2subset_3bit_weights(bc6h_block* pPacked_block, uint32_t common_part_index, const half_float pEndpoints[2][3][2], const uint8_t* pWeights); // pEndpoints[subset][comp][lh_index]
	bool bc6h_enc_block_solid_color(bc6h_block* pPacked_block, const half_float pColor[3]);
		
} // namespace basist