29constexpr uint32_t
fourccLE(
char a,
char b,
char c,
char d) {
30 return static_cast<uint32_t
>(
static_cast<uint8_t
>(a))
31 | (
static_cast<uint32_t
>(
static_cast<uint8_t
>(b)) << 8)
32 | (
static_cast<uint32_t
>(
static_cast<uint8_t
>(c)) << 16)
33 | (
static_cast<uint32_t
>(
static_cast<uint8_t
>(d)) << 24);
36void appendU32LE(std::vector<uint8_t>& out, uint32_t value);
37void appendU64LE(std::vector<uint8_t>& out, uint64_t value);
71constexpr int bayer(
int side,
int x,
int y) {
72 if (side <= 1)
return 0;
74 const auto half = side / 2;
77 constexpr int quadrant[4] = {0, 2, 3, 1};
78 const auto which = (y >= half ? 2 : 0) + (x >= half ? 1 : 0);
80 return 4 *
bayer(half, x % half, y % half) + quadrant[which];
86 while (side * side < levels && side < 16) side *= 2;
96inline constexpr uint32_t
GL_RGB = 0x1907;
97inline constexpr uint32_t
GL_RGBA = 0x1908;
115constexpr uint64_t
pvrRaw(
char a,
char b,
char c,
char d, uint8_t ba, uint8_t bb, uint8_t bc, uint8_t bd) {
116 return static_cast<uint64_t
>(a) | (
static_cast<uint64_t
>(b) << 8) | (
static_cast<uint64_t
>(c) << 16)
117 | (
static_cast<uint64_t
>(d) << 24) | (
static_cast<uint64_t
>(ba) << 32) | (
static_cast<uint64_t
>(bb) << 40)
118 | (
static_cast<uint64_t
>(bc) << 48) | (
static_cast<uint64_t
>(bd) << 56);
123 return static_cast<size_t>((size.
width + 3) / 4) *
static_cast<size_t>((size.
height + 3) / 4) * 8;
128uint32_t
typeSize(
const Profile& profile);
constexpr int bayer(int side, int x, int y)
constexpr int bayerSideFor(int levels)
constexpr uint64_t pvrRaw(char a, char b, char c, char d, uint8_t ba, uint8_t bb, uint8_t bc, uint8_t bd)
Result< Profile > profileFor(Color color, Size size)
constexpr uint32_t GL_RGB565
Result< Color > colorFromPVR(uint64_t format)
constexpr uint32_t GL_UNSIGNED_BYTE
constexpr uint32_t GL_ETC1_RGB8_OES
Result< Color > colorFromGL(uint32_t glType, uint32_t glFormat, uint32_t glInternal)
constexpr uint32_t VK_FORMAT_R5G6B5_UNORM_PACK16
constexpr size_t etc1Size(Size size)
uint32_t typeSize(const Profile &profile)
constexpr uint32_t VK_FORMAT_R8G8B8A8_UNORM
constexpr uint32_t GL_RGB
Result< Color > colorFromVK(uint32_t format)
constexpr uint32_t GL_UNSIGNED_SHORT_5_6_5
constexpr uint32_t VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK
constexpr uint32_t GL_RGBA8
Result< size_t > payloadSize(Color color, Size size)
constexpr uint32_t GL_RGBA
uint32_t readU32BE(Bytes data, size_t off)
Result< std::vector< uint8_t > > slice(Bytes data, size_t off, size_t len)
uint64_t readU64LE(Bytes data, size_t off)
bool hasBytes(Bytes data, size_t off, size_t len)
void appendU64LE(std::vector< uint8_t > &out, uint64_t value)
constexpr uint32_t fourccLE(char a, char b, char c, char d)
uint32_t readU32LE(Bytes data, size_t off)
void appendU32LE(std::vector< uint8_t > &out, uint32_t value)
bool matches(Bytes data, Bytes magic)
std::expected< T, Error > Result
std::span< const uint8_t > Bytes