#pragma once
#include "../transcoder/basisu.h"
#include "../transcoder/basisu_transcoder_internal.h"
#include <mutex>
#include <atomic>
#include <condition_variable>
#include <functional>
#include <thread>
#include <unordered_map>
#include <ostream>
#if !defined(_WIN32) || defined(__MINGW32__)
#include <libgen.h>
#endif
#define BASISU_USE_HIGH_PRECISION_COLOR_DISTANCE …
#if BASISU_SUPPORT_SSE
extern void update_covar_matrix_16x16_sse41(uint32_t num_vecs, const void* pWeighted_vecs, const void* pOrigin, const uint32_t *pVec_indices, void* pMatrix16x16);
#endif
namespace basisu
{
extern uint8_t g_hamming_dist[256];
extern const uint8_t g_debug_font8x8_basic[127 - 32 + 1][8];
extern bool g_library_initialized;
void basisu_encoder_init(bool use_opencl = false, bool opencl_force_serialization = false);
void basisu_encoder_deinit();
extern void detect_sse41();
#if BASISU_SUPPORT_SSE
extern bool g_cpu_supports_sse41;
#else
const bool g_cpu_supports_sse41 = …;
#endif
void error_vprintf(const char* pFmt, va_list args);
void error_printf(const char *pFmt, ...);
inline uint8_t clamp255(int32_t i)
{ … }
inline int32_t clampi(int32_t value, int32_t low, int32_t high)
{ … }
inline uint8_t mul_8(uint32_t v, uint32_t a)
{ … }
inline uint64_t read_bits(const uint8_t* pBuf, uint32_t& bit_offset, uint32_t codesize)
{ … }
inline uint32_t read_bits32(const uint8_t* pBuf, uint32_t& bit_offset, uint32_t codesize)
{ … }
inline uint32_t bitmix32c(uint32_t v)
{ … }
inline uint32_t bitmix32(uint32_t v)
{ … }
inline uint32_t wang_hash(uint32_t seed)
{ … }
uint32_t hash_hsieh(const uint8_t* pBuf, size_t len);
template <typename Key>
struct bit_hasher
{ … };
class running_stat
{ … };
template <uint32_t N, typename T>
class vec
{ … };
vec4D;
vec3D;
vec2D;
vec1D;
vec4F;
vec3F;
vec2F;
vec1F;
vec16F;
template <uint32_t Rows, uint32_t Cols, typename T>
class matrix
{ … };
template<uint32_t N, typename VectorType>
inline VectorType compute_pca_from_covar(matrix<N, N, float> &cmatrix)
{ … }
template<typename T> inline void indirect_sort(uint32_t num_indices, uint32_t* pIndices, const T* pKeys)
{ … }
template <typename T>
T* radix_sort(uint32_t num_vals, T* pBuf0, T* pBuf1, uint32_t key_ofs, uint32_t key_size)
{ … }
#undef BASISU_GET_KEY
class job_pool
{ … };
class color_rgba_i16
{ … };
class color_rgba
{ … };
color_rgba_vec;
const color_rgba g_black_color(0, 0, 0, 255);
const color_rgba g_black_trans_color(0, 0, 0, 0);
const color_rgba g_white_color(255, 255, 255, 255);
inline int color_distance(int r0, int g0, int b0, int r1, int g1, int b1)
{ … }
inline int color_distance(int r0, int g0, int b0, int a0, int r1, int g1, int b1, int a1)
{ … }
inline int color_distance(const color_rgba &c0, const color_rgba &c1, bool alpha)
{ … }
inline uint32_t color_distance(bool perceptual, const color_rgba &e1, const color_rgba &e2, bool alpha)
{ … }
static inline uint32_t color_distance_la(const color_rgba& a, const color_rgba& b)
{ … }
inline int string_find_right(const std::string& filename, char c)
{ … }
inline std::string string_get_extension(const std::string &filename)
{ … }
inline bool string_remove_extension(std::string &filename)
{ … }
inline std::string string_format(const char* pFmt, ...)
{ … }
inline std::string string_tolower(const std::string& s)
{ … }
inline char *strcpy_safe(char *pDst, size_t dst_len, const char *pSrc)
{ … }
inline bool string_ends_with(const std::string& s, char c)
{ … }
inline bool string_split_path(const char *p, std::string *pDrive, std::string *pDir, std::string *pFilename, std::string *pExt)
{ … }
inline bool is_path_separator(char c)
{ … }
inline bool is_drive_separator(char c)
{ … }
inline void string_combine_path(std::string &dst, const char *p, const char *q)
{ … }
inline void string_combine_path(std::string &dst, const char *p, const char *q, const char *r)
{ … }
inline void string_combine_path_and_extension(std::string &dst, const char *p, const char *q, const char *r, const char *pExt)
{ … }
inline bool string_get_pathname(const char *p, std::string &path)
{ … }
inline bool string_get_filename(const char *p, std::string &filename)
{ … }
class rand
{ … };
class priority_queue
{ … };
template <typename TrainingVectorType>
class tree_vector_quant
{ … };
struct weighted_block_group
{ … };
template<typename Quantizer>
bool generate_hierarchical_codebook_threaded_internal(Quantizer& q,
uint32_t max_codebook_size, uint32_t max_parent_codebook_size,
basisu::vector<uint_vec>& codebook,
basisu::vector<uint_vec>& parent_codebook,
uint32_t max_threads, bool limit_clusterizers, job_pool *pJob_pool)
{ … }
template<typename Quantizer>
bool generate_hierarchical_codebook_threaded(Quantizer& q,
uint32_t max_codebook_size, uint32_t max_parent_codebook_size,
basisu::vector<uint_vec>& codebook,
basisu::vector<uint_vec>& parent_codebook,
uint32_t max_threads, job_pool *pJob_pool,
bool even_odd_input_pairs_equal)
{ … }
class histogram
{ … };
struct sym_freq
{ … };
sym_freq *canonical_huffman_radix_sort_syms(uint32_t num_syms, sym_freq *pSyms0, sym_freq *pSyms1);
void canonical_huffman_calculate_minimum_redundancy(sym_freq *A, int num_syms);
void canonical_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size);
class huffman_encoding_table
{ … };
class bitwise_coder
{ … };
class huff2D
{ … };
bool huffman_test(int rand_seed);
class palette_index_reorderer
{ … };
class image
{ … };
vec4F_vec;
class imagef
{ … };
class image_metrics
{ … };
bool load_png(const uint8_t* pBuf, size_t buf_size, image& img, const char* pFilename = nullptr);
bool load_png(const char* pFilename, image& img);
inline bool load_png(const std::string &filename, image &img) { … }
bool load_tga(const char* pFilename, image& img);
inline bool load_tga(const std::string &filename, image &img) { … }
bool load_jpg(const char *pFilename, image& img);
inline bool load_jpg(const std::string &filename, image &img) { … }
bool load_image(const char* pFilename, image& img);
inline bool load_image(const std::string &filename, image &img) { … }
uint8_t *read_tga(const uint8_t *pBuf, uint32_t buf_size, int &width, int &height, int &n_chans);
uint8_t *read_tga(const char *pFilename, int &width, int &height, int &n_chans);
enum
{ … };
bool save_png(const char* pFilename, const image& img, uint32_t image_save_flags = 0, uint32_t grayscale_comp = 0);
inline bool save_png(const std::string &filename, const image &img, uint32_t image_save_flags = 0, uint32_t grayscale_comp = 0) { … }
bool read_file_to_vec(const char* pFilename, uint8_vec& data);
bool write_data_to_file(const char* pFilename, const void* pData, size_t len);
inline bool write_vec_to_file(const char* pFilename, const uint8_vec& v) { … }
float linear_to_srgb(float l);
float srgb_to_linear(float s);
bool image_resample(const image &src, image &dst, bool srgb = false,
const char *pFilter = "lanczos4", float filter_scale = 1.0f,
bool wrapping = false,
uint32_t first_comp = 0, uint32_t num_comps = 4);
timer_ticks;
class interval_timer
{ … };
template<typename T>
class vector2D
{ … };
inline FILE *fopen_safe(const char *pFilename, const char *pMode)
{ … }
void fill_buffer_with_random_bytes(void *pBuf, size_t size, uint32_t seed = 1);
const uint32_t cPixelBlockWidth = …;
const uint32_t cPixelBlockHeight = …;
const uint32_t cPixelBlockTotalPixels = …;
struct pixel_block
{ … };
pixel_block_vec;
}