godot/thirdparty/basis_universal/encoder/pvpngreader.cpp

// pngreader.cpp - Public Domain - see unlicense at bottom of file.
//
// Notes: 
// This is ancient code from ~1995 ported to C++. It was originally written for a 
// DOS app with very limited memory. It's not as fast as it should be, but it works. 
// The low-level PNG reader class was written assuming the PNG file could not fit 
// entirely into memory, which dictated how it was written/structured.
// It has been modified to use either zlib or miniz.
// It supports all PNG color types/bit depths/interlacing, however 16-bit/component 
// images are converted to 8-bit.
// TRNS chunks are converted to alpha as needed.
// GAMA chunk is read, but not applied.

#include "../transcoder/basisu.h"

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

#include "pvpngreader.h"

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <vector>
#include <assert.h>

#define PVPNG_IDAT_CRC_CHECKING
#define PVPNG_ADLER32_CHECKING

namespace pv_png
{

const uint32_t MIN_PNG_SIZE =;

template <typename S> inline S maximum(S a, S b) {}
template <typename S> inline S minimum(S a, S b) {}

template <typename T> inline void clear_obj(T& obj) {}

#define MAX_SUPPORTED_RES
#define FALSE
#define TRUE
#define PNG_MAX_ALLOC_BLOCKS

enum
{};

#define PNG_COLOR_TYPE_PAL_MASK
#define PNG_COLOR_TYPE_COL_MASK
#define PNG_COLOR_TYPE_ALP_MASK

#define PNG_INFLATE_SRC_BUF_SIZE

struct ihdr_struct
{};

class png_file
{};

class png_memory_file : public png_file
{};

class png_readonly_memory_file : public png_file
{};

#ifdef _MSC_VER
#define ftell64
#define fseek64
#else
#define ftell64
#define fseek64
#endif

class png_cfile : public png_file
{};

// This low-level helper class handles the actual decoding of PNG files.
class png_decoder
{};

void png_decoder::uninitialize()
{}

int png_decoder::terminate(int status)
{}

void* png_decoder::png_malloc(uint32_t len)
{}

void* png_decoder::png_calloc(uint32_t len)
{}

int png_decoder::block_read(void* buf, uint32_t len)
{}

int64_t png_decoder::block_read_dword()
{}

int png_decoder::fetch_next_chunk_data(uint8_t* buf, int bytes)
{}

int png_decoder::fetch_next_chunk_byte()
{}

int png_decoder::fetch_next_chunk_word()
{}

int64_t png_decoder::fetch_next_chunk_dword()
{}

int png_decoder::fetch_next_chunk_init()
{}

int png_decoder::unchunk_data(uint8_t* buf, uint32_t bytes, uint32_t* ptr_bytes_read)
{}

inline void png_decoder::adam7_write_pixel_8(int x, int y, int c)
{}

inline void png_decoder::adam7_write_pixel_16(int x, int y, int r, int g)
{}

inline void png_decoder::adam7_write_pixel_24(int x, int y, int r, int g, int b)
{}

inline void png_decoder::adam7_write_pixel_32(int x, int y, int r, int g, int b, int a)
{}

static void PixelDePack2(void* src, void* dst, int numbytes)
{}

static void PixelDePack16(void* src, void* dst, int numbytes)
{}

static int unpack_grey_1(uint8_t* src, uint8_t* dst, int pixels, png_decoder *pwi)
{}

static int unpack_grey_2(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_grey_4(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_grey_8(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_grey_16(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_grey_16_2(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_true_8(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_true_16(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_grey_alpha_8(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_grey_alpha_16(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_true_alpha_8(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

static int unpack_true_alpha_16(uint8_t* src, uint8_t* dst, int pixels, png_decoder* pwi)
{}

void png_decoder::unpredict_sub(uint8_t* lst, uint8_t* cur, uint32_t bytes, int bpp)
{}

void png_decoder::unpredict_up(uint8_t* lst, uint8_t* cur, uint32_t bytes, int bpp)
{}

void png_decoder::unpredict_average(uint8_t* lst, uint8_t* cur, uint32_t bytes, int bpp)
{}

inline uint8_t png_decoder::paeth_predictor(int a, int b, int c)
{}

void png_decoder::unpredict_paeth(uint8_t* lst, uint8_t* cur, uint32_t bytes, int bpp)
{}

int png_decoder::adam7_pass_size(int size, int start, int step)
{}

// TRUE if no more data, negative on error, FALSE if OK
int png_decoder::decompress_line(uint32_t* bytes_decoded)
{}

int png_decoder::find_iend_chunk()
{}

int png_decoder::png_decode(void** ppImg_ptr, uint32_t* pImg_len)
{}

void png_decoder::png_decode_end()
{}

int png_decoder::png_decode_start()
{}

void png_decoder::calc_gamma_table()
{}

void png_decoder::create_grey_palette()
{}

int png_decoder::read_signature()
{}

int png_decoder::read_ihdr_chunk()
{}

int png_decoder::read_bkgd_chunk()
{}

int png_decoder::read_gama_chunk()
{}

int png_decoder::read_trns_chunk()
{}

int png_decoder::read_plte_chunk()
{}

int png_decoder::find_idat_chunk()
{}

png_decoder::png_decoder()
{}

png_decoder::~png_decoder()
{}

void png_decoder::clear()
{}

int png_decoder::png_scan(png_file *pFile)
{}

static inline uint8_t get_709_luma(uint32_t r, uint32_t g, uint32_t b)
{}

bool get_png_info(const void* pImage_buf, size_t buf_size, png_info &info)
{}

void* load_png(const void* pImage_buf, size_t buf_size, uint32_t desired_chans, uint32_t& width, uint32_t& height, uint32_t& num_chans)
{}

} // namespace pv_png

/*
	This is free and unencumbered software released into the public domain.

	Anyone is free to copy, modify, publish, use, compile, sell, or
	distribute this software, either in source code form or as a compiled
	binary, for any purpose, commercial or non-commercial, and by any
	means.

	In jurisdictions that recognize copyright laws, the author or authors
	of this software dedicate any and all copyright interest in the
	software to the public domain. We make this dedication for the benefit
	of the public at large and to the detriment of our heirs and
	successors. We intend this dedication to be an overt act of
	relinquishment in perpetuity of all present and future rights to this
	software under copyright law.

	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
	EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
	IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
	OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
	ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
	OTHER DEALINGS IN THE SOFTWARE.

	For more information, please refer to <http://unlicense.org/>

	Richard Geldreich, Jr.
	1/20/2022
*/