godot/thirdparty/basis_universal/encoder/basisu_enc.cpp

// basisu_enc.cpp
// Copyright (C) 2019-2021 Binomial LLC. All Rights Reserved.
//
// 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.
#include "basisu_enc.h"
#include "basisu_resampler.h"
#include "basisu_resampler_filters.h"
#include "basisu_etc.h"
#include "../transcoder/basisu_transcoder.h"
#include "basisu_bc7enc.h"
#include "jpgd.h"
#include "pvpngreader.h"
#include "basisu_opencl.h"
#include <vector>

#define MINIZ_HEADER_FILE_ONLY
#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#include "basisu_miniz.h"

#if defined(_WIN32)
// For QueryPerformanceCounter/QueryPerformanceFrequency
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif

namespace basisu
{
	uint64_t interval_timer::g_init_ticks, interval_timer::g_freq;
	double interval_timer::g_timer_freq;
#if BASISU_SUPPORT_SSE
	bool g_cpu_supports_sse41;
#endif

	uint8_t g_hamming_dist[256] =;

	// This is a Public Domain 8x8 font from here:
	// https://github.com/dhepper/font8x8/blob/master/font8x8_basic.h
	const uint8_t g_debug_font8x8_basic[127 - 32 + 1][8] =;

	bool g_library_initialized;
	std::mutex g_encoder_init_mutex;

	// Encoder library initialization (just call once at startup)
	void basisu_encoder_init(bool use_opencl, bool opencl_force_serialization)
	{}

	void basisu_encoder_deinit()
	{}

	void error_vprintf(const char* pFmt, va_list args)
	{}

	void error_printf(const char *pFmt, ...)
	{}

#if defined(_WIN32)
	inline void query_counter(timer_ticks* pTicks)
	{
		QueryPerformanceCounter(reinterpret_cast<LARGE_INTEGER*>(pTicks));
	}
	inline void query_counter_frequency(timer_ticks* pTicks)
	{
		QueryPerformanceFrequency(reinterpret_cast<LARGE_INTEGER*>(pTicks));
	}
#elif defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__EMSCRIPTEN__)
#include <sys/time.h>
	inline void query_counter(timer_ticks* pTicks)
	{
		struct timeval cur_time;
		gettimeofday(&cur_time, NULL);
		*pTicks = static_cast<unsigned long long>(cur_time.tv_sec) * 1000000ULL + static_cast<unsigned long long>(cur_time.tv_usec);
	}
	inline void query_counter_frequency(timer_ticks* pTicks)
	{
		*pTicks = 1000000;
	}
#elif defined(__GNUC__)
#include <sys/timex.h>
	inline void query_counter(timer_ticks* pTicks)
	{}
	inline void query_counter_frequency(timer_ticks* pTicks)
	{}
#else
#error TODO
#endif
				
	interval_timer::interval_timer() :{}

	void interval_timer::start()
	{}

	void interval_timer::stop()
	{}

	double interval_timer::get_elapsed_secs() const
	{}
		
	void interval_timer::init()
	{}

	timer_ticks interval_timer::get_ticks()
	{}

	double interval_timer::ticks_to_secs(timer_ticks ticks)
	{}
		
	const uint32_t MAX_32BIT_ALLOC_SIZE =;
		
	bool load_tga(const char* pFilename, image& img)
	{}

	bool load_png(const uint8_t *pBuf, size_t buf_size, image &img, const char *pFilename)
	{}
		
	bool load_png(const char* pFilename, image& img)
	{}

	bool load_jpg(const char *pFilename, image& img)
	{}

	bool load_image(const char* pFilename, image& img)
	{}
	
	bool save_png(const char* pFilename, const image &img, uint32_t image_save_flags, uint32_t grayscale_comp)
	{}
		
	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)
	{}

	float linear_to_srgb(float l)
	{}

	float srgb_to_linear(float s)
	{}

	bool image_resample(const image &src, image &dst, bool srgb,
		const char *pFilter, float filter_scale, 
		bool wrapping,
		uint32_t first_comp, uint32_t num_comps)
	{}

	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)
	{}

	sym_freq *canonical_huffman_radix_sort_syms(uint32_t num_syms, sym_freq *pSyms0, sym_freq *pSyms1)
	{}

	bool huffman_encoding_table::init(uint32_t num_syms, const uint16_t *pFreq, uint32_t max_code_size)
	{}

	bool huffman_encoding_table::init(uint32_t num_syms, const uint32_t *pSym_freq, uint32_t max_code_size)
	{}

	void bitwise_coder::end_nonzero_run(uint16_vec &syms, uint32_t &run_size, uint32_t len)
	{}

	void bitwise_coder::end_zero_run(uint16_vec &syms, uint32_t &run_size)
	{}

	uint32_t bitwise_coder::emit_huffman_table(const huffman_encoding_table &tab)
	{}

	bool huffman_test(int rand_seed)
	{}

	void palette_index_reorderer::init(uint32_t num_indices, const uint32_t *pIndices, uint32_t num_syms, pEntry_dist_func pDist_func, void *pCtx, float dist_func_weight)
	{}

	void palette_index_reorderer::prepare_hist(uint32_t num_syms, uint32_t num_indices, const uint32_t *pIndices)
	{}

	void palette_index_reorderer::find_initial(uint32_t num_syms)
	{}

	void palette_index_reorderer::find_next_entry(uint32_t &best_entry, double &best_count, pEntry_dist_func pDist_func, void *pCtx, float dist_func_weight)
	{}

	float palette_index_reorderer::pick_side(uint32_t num_syms, uint32_t entry_to_move, pEntry_dist_func pDist_func, void *pCtx, float dist_func_weight)
	{}

	void image_metrics::calc(const image &a, const image &b, uint32_t first_chan, uint32_t total_chans, bool avg_comp_error, bool use_601_luma)
	{}

	void fill_buffer_with_random_bytes(void *pBuf, size_t size, uint32_t seed)
	{}

	uint32_t hash_hsieh(const uint8_t *pBuf, size_t len)
	{}

	job_pool::job_pool(uint32_t num_threads) :{}

	job_pool::~job_pool()
	{}
				
	void job_pool::add_job(const std::function<void()>& job)
	{}

	void job_pool::add_job(std::function<void()>&& job)
	{}

	void job_pool::wait_for_all()
	{}

	void job_pool::job_thread(uint32_t index)
	{}

	// .TGA image loading
	#pragma pack(push)
	#pragma pack(1)
	struct tga_header
	{};
	#pragma pack(pop)

	const uint32_t MAX_TGA_IMAGE_SIZE =;

	enum tga_image_type
	{};

	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)
	{}

	void image::debug_text(uint32_t x_ofs, uint32_t y_ofs, uint32_t scale_x, uint32_t scale_y, const color_rgba& fg, const color_rgba* pBG, bool alpha_only, const char* pFmt, ...)
	{}
		
} // namespace basisu