godot/thirdparty/basis_universal/encoder/3rdparty/android_astc_decomp.cpp

// File: android_astc_decomp.cpp

/*-------------------------------------------------------------------------
 * drawElements Quality Program Tester Core
 * ----------------------------------------
 *
 * Copyright 2016 The Android Open Source Project
 *
 * 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.
 *
 * rg: Removed external dependencies, minor fix to decompress() so it converts non-sRGB
 * output to 8-bits correctly. I've compared this decoder's output
 * vs. astc-codec with random inputs.
 * 
 *//*!
 * \file
 * \brief ASTC Utilities.
 *//*--------------------------------------------------------------------*/
#include "android_astc_decomp.h"
#include <assert.h>
#include <algorithm>
#include <fenv.h>
#include <math.h>

#define DE_LENGTH_OF_ARRAY(x)
#define DE_UNREF(x)

deUint8;
deInt8;
deUint32;
deInt32;
deUint16;
deInt16;
deInt64;
deUint64;

#define DE_ASSERT

#ifdef _MSC_VER
#pragma warning (disable:4505) // unreferenced local function has been removed
#elif defined(__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif

namespace basisu_astc
{
    template <typename S> inline S maximum(S a, S b) {}
    template <typename S> inline S maximum(S a, S b, S c) {}
    template <typename S> inline S maximum(S a, S b, S c, S d) {}

    static bool inBounds(int v, int l, int h)
    {}

    static bool inRange(int v, int l, int h)
    {}

    template<typename T>
    static inline T max(T a, T b)
    {}

    template<typename T>
    static inline T min(T a, T b)
    {}

    template<typename T>
    static inline T clamp(T a, T l, T h)
    {}

    struct UVec4
    {};

    struct IVec4
    {};

    struct IVec3
    {};

    static uint32_t deDivRoundUp32(uint32_t a, uint32_t b)
    {}

    static bool deInBounds32(uint32_t v, uint32_t l, uint32_t h)
    {}

namespace astc 
{

vector;

namespace
{

// Common utilities
enum
{};

inline deUint32 getBit (deUint32 src, int ndx)
{}

inline deUint32 getBits (deUint32 src, int low, int high)
{}

inline bool isBitSet (deUint32 src, int ndx)
{}

inline deUint32 reverseBits (deUint32 src, int numBits)
{}

inline deUint32 bitReplicationScale (deUint32 src, int numSrcBits, int numDstBits)
{}

inline deInt32 signExtend (deInt32 src, int numSrcBits)
{}

deFloat16;

inline bool isFloat16InfOrNan (deFloat16 v)
{}

float deFloat16To32(deFloat16 val16)
{}

enum ISEMode
{};

struct ISEParams
{};

inline int computeNumRequiredBits (const ISEParams& iseParams, int numValues)
{}

ISEParams computeMaximumRangeISEParams (int numAvailableBits, int numValuesInSequence)
{}

inline int computeNumColorEndpointValues (deUint32 endpointMode)
{}

// Decompression utilities
enum DecompressResult
{};

// A helper for getting bits from a 128-bit block.
class Block128
{};

// A helper for sequential access into a Block128.
class BitAccessStream
{};

struct ISEDecodedResult
{};

// Data from an ASTC block's "block mode" part (i.e. bits [0,10]).
struct ASTCBlockMode
{};

inline int computeNumWeights (const ASTCBlockMode& mode)
{}

struct ColorEndpointPair
{};

struct TexelWeightPair
{};

ASTCBlockMode getASTCBlockMode (deUint32 blockModeData)
{}

inline void setASTCErrorColorBlock (void* dst, int blockWidth, int blockHeight, bool isSRGB)
{}

DecompressResult decodeVoidExtentBlock (void* dst, const Block128& blockData, int blockWidth, int blockHeight, bool isSRGB, bool isLDRMode)
{}

void decodeColorEndpointModes (deUint32* endpointModesDst, const Block128& blockData, int numPartitions, int extraCemBitsStart)
{}

int computeNumColorEndpointValues (const deUint32* endpointModes, int numPartitions)
{}

void decodeISETritBlock (ISEDecodedResult* dst, int numValues, BitAccessStream& data, int numBits)
{}

void decodeISEQuintBlock (ISEDecodedResult* dst, int numValues, BitAccessStream& data, int numBits)
{}

inline void decodeISEBitBlock (ISEDecodedResult* dst, BitAccessStream& data, int numBits)
{}

void decodeISE (ISEDecodedResult* dst, int numValues, BitAccessStream& data, const ISEParams& params)
{}

void unquantizeColorEndpoints (deUint32* dst, const ISEDecodedResult* iseResults, int numEndpoints, const ISEParams& iseParams)
{}

inline void bitTransferSigned (deInt32& a, deInt32& b)
{}

inline UVec4 clampedRGBA (const IVec4& rgba)
{}

inline IVec4 blueContract (int r, int g, int b, int a)
{}

inline bool isColorEndpointModeHDR (deUint32 mode)
{}

void decodeHDREndpointMode7 (UVec4& e0, UVec4& e1, deUint32 v0, deUint32 v1, deUint32 v2, deUint32 v3)
{}

void decodeHDREndpointMode11 (UVec4& e0, UVec4& e1, deUint32 v0, deUint32 v1, deUint32 v2, deUint32 v3, deUint32 v4, deUint32 v5)
{}

void decodeHDREndpointMode15(UVec4& e0, UVec4& e1, deUint32 v0, deUint32 v1, deUint32 v2, deUint32 v3, deUint32 v4, deUint32 v5, deUint32 v6In, deUint32 v7In)
{}

void decodeColorEndpoints (ColorEndpointPair* dst, const deUint32* unquantizedEndpoints, const deUint32* endpointModes, int numPartitions)
{}

void computeColorEndpoints (ColorEndpointPair* dst, const Block128& blockData, const deUint32* endpointModes, int numPartitions, int numColorEndpointValues, const ISEParams& iseParams, int numBitsAvailable)
{}

void unquantizeWeights (deUint32 dst[64], const ISEDecodedResult* weightGrid, const ASTCBlockMode& blockMode)
{}

void interpolateWeights (TexelWeightPair* dst, const deUint32 (&unquantizedWeights) [64], int blockWidth, int blockHeight, const ASTCBlockMode& blockMode)
{}

void computeTexelWeights (TexelWeightPair* dst, const Block128& blockData, int blockWidth, int blockHeight, const ASTCBlockMode& blockMode)
{}

inline deUint32 hash52 (deUint32 v)
{}

int computeTexelPartition (deUint32 seedIn, deUint32 xIn, deUint32 yIn, deUint32 zIn, int numPartitions, bool smallBlock)
{}

DecompressResult setTexelColors (void* dst, ColorEndpointPair* colorEndpoints, TexelWeightPair* texelWeights, int ccs, deUint32 partitionIndexSeed,
                                 int numPartitions, int blockWidth, int blockHeight, bool isSRGB, bool isLDRMode, const deUint32* colorEndpointModes)
{}

DecompressResult decompressBlock (void* dst, const Block128& blockData, int blockWidth, int blockHeight, bool isSRGB, bool isLDR)
{}

// Returns -1 on error, 0 if LDR, 1 if HDR
int isHDR(const Block128& blockData, int blockWidth, int blockHeight)
{}

half_float;

half_float float_to_half(float val, bool toward_zero)
{}

float half_to_float(half_float hval)
{}

} // anonymous

// See https://registry.khronos.org/DataFormat/specs/1.3/dataformat.1.3.inline.html#_hdr_endpoint_decoding
static void convert_to_half_prec(uint32_t n, float* pVals)
{}

bool decompress_ldr(uint8_t *pDst, const uint8_t * data, bool isSRGB, int blockWidth, int blockHeight)
{}

bool decompress_hdr(float* pDstRGBA, const uint8_t* data, int blockWidth, int blockHeight)
{}

bool is_hdr(const uint8_t* data, int blockWidth, int blockHeight, bool &is_hdr)
{}

} // astc

} // basisu_astc

#if defined(__GNUC__)
#pragma GCC diagnostic pop
#endif