Add support for exporting compressed textures in Editor on Linux using detex lib
This commit is contained in:
@@ -47,6 +47,11 @@ public class TextureTool : EngineModule
|
||||
{
|
||||
options.PrivateDependencies.Add("stb");
|
||||
options.SourceFiles.Add(Path.Combine(FolderPath, "TextureTool.stb.cpp"));
|
||||
if (options.Target.IsEditor)
|
||||
{
|
||||
// Use helper lib for decompression
|
||||
options.PrivateDependencies.Add("detex");
|
||||
}
|
||||
}
|
||||
|
||||
options.PublicDefinitions.Add("COMPILE_WITH_TEXTURE_TOOL");
|
||||
|
||||
@@ -44,6 +44,12 @@
|
||||
#define STB_DXT_IMPLEMENTATION
|
||||
#include <ThirdParty/stb/stb_dxt.h>
|
||||
|
||||
#if USE_EDITOR
|
||||
|
||||
#include <ThirdParty/detex/detex.h>
|
||||
|
||||
#endif
|
||||
|
||||
static void stbWrite(void* context, void* data, int size)
|
||||
{
|
||||
auto file = (FileWriteStream*)context;
|
||||
@@ -57,46 +63,142 @@ bool TextureTool::ExportTextureStb(ImageType type, const StringView& path, const
|
||||
LOG(Warning, "Exporting texture arrays and cubemaps is not supported by stb library.");
|
||||
}
|
||||
|
||||
TextureData const* texture = &textureData;
|
||||
|
||||
#if USE_EDITOR
|
||||
// Handle compressed textures
|
||||
TextureData decompressed;
|
||||
if (PixelFormatExtensions::IsCompressed(textureData.Format))
|
||||
{
|
||||
decompressed.Format = PixelFormatExtensions::IsSRGB(textureData.Format) ? PixelFormat::R8G8B8A8_UNorm_sRGB : PixelFormat::R8G8B8A8_UNorm;
|
||||
decompressed.Width = textureData.Width;
|
||||
decompressed.Height = textureData.Height;
|
||||
decompressed.Depth = textureData.Depth;
|
||||
decompressed.Items.Resize(1);
|
||||
decompressed.Items[0].Mips.Resize(1);
|
||||
|
||||
auto decompressedData = decompressed.GetData(0, 0);
|
||||
decompressedData->RowPitch = textureData.Width * sizeof(Color32);
|
||||
decompressedData->Lines = textureData.Height;
|
||||
decompressedData->DepthPitch = decompressedData->RowPitch * decompressedData->Lines;
|
||||
decompressedData->Data.Allocate(decompressedData->DepthPitch);
|
||||
|
||||
Color32 colors[16];
|
||||
int32 blocksWidth = textureData.Width / 4;
|
||||
int32 blocksHeight = textureData.Height / 4;
|
||||
const auto blocksData = texture->GetData(0, 0);
|
||||
byte* decompressedBytes = decompressedData->Data.Get();
|
||||
|
||||
switch (textureData.Format)
|
||||
{
|
||||
case PixelFormat::BC1_UNorm:
|
||||
case PixelFormat::BC1_UNorm_sRGB:
|
||||
{
|
||||
for (int32 yBlock = 0; yBlock < blocksHeight; yBlock++)
|
||||
{
|
||||
for (int32 xBlock = 0; xBlock < blocksWidth; xBlock++)
|
||||
{
|
||||
const byte* block = blocksData->Data.Get() + yBlock * 4 * blocksData->RowPitch + xBlock * 8;
|
||||
detexDecompressBlockBC1(block, 0, 0, (byte*)&colors);
|
||||
for (int32 y = 0; y < 4; y++)
|
||||
{
|
||||
for (int32 x = 0; x < 4; x++)
|
||||
{
|
||||
*((Color32*)decompressedBytes + (yBlock * 4 + y) * textureData.Width + (xBlock * 4 + x)) = colors[y * 4 + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PixelFormat::BC2_UNorm:
|
||||
case PixelFormat::BC2_UNorm_sRGB:
|
||||
{
|
||||
for (int32 yBlock = 0; yBlock < blocksHeight; yBlock++)
|
||||
{
|
||||
for (int32 xBlock = 0; xBlock < blocksWidth; xBlock++)
|
||||
{
|
||||
const byte* block = blocksData->Data.Get() + yBlock * 4 * blocksData->RowPitch + xBlock * 16;
|
||||
detexDecompressBlockBC2(block, 0, 0, (byte*)&colors);
|
||||
for (int32 y = 0; y < 4; y++)
|
||||
{
|
||||
for (int32 x = 0; x < 4; x++)
|
||||
{
|
||||
*((Color32*)decompressedBytes + (yBlock * 4 + y) * textureData.Width + (xBlock * 4 + x)) = colors[y * 4 + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PixelFormat::BC3_UNorm:
|
||||
case PixelFormat::BC3_UNorm_sRGB:
|
||||
{
|
||||
for (int32 yBlock = 0; yBlock < blocksHeight; yBlock++)
|
||||
{
|
||||
for (int32 xBlock = 0; xBlock < blocksWidth; xBlock++)
|
||||
{
|
||||
const byte* block = blocksData->Data.Get() + yBlock * 4 * blocksData->RowPitch + xBlock * 16;
|
||||
detexDecompressBlockBC3(block, 0, 0, (byte*)&colors);
|
||||
for (int32 y = 0; y < 4; y++)
|
||||
{
|
||||
for (int32 x = 0; x < 4; x++)
|
||||
{
|
||||
*((Color32*)decompressedBytes + (yBlock * 4 + y) * textureData.Width + (xBlock * 4 + x)) = colors[y * 4 + x];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG(Warning, "Texture data format {0} is not supported by stb library.", (int32)textureData.Format);
|
||||
return true;
|
||||
}
|
||||
texture = &decompressed;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Convert into RGBA8
|
||||
const auto sampler = GetSampler(textureData.Format);
|
||||
const auto sampler = GetSampler(texture->Format);
|
||||
if (sampler == nullptr)
|
||||
{
|
||||
LOG(Warning, "Texture data format {0} is not supported by stb library.", (int32)textureData.Format);
|
||||
return true;
|
||||
}
|
||||
const auto srcData = textureData.GetData(0, 0);
|
||||
const auto srcData = texture->GetData(0, 0);
|
||||
const int comp = 4;
|
||||
Array<byte> data;
|
||||
bool sRGB = PixelFormatExtensions::IsSRGB(textureData.Format);
|
||||
bool sRGB = PixelFormatExtensions::IsSRGB(texture->Format);
|
||||
if (type == ImageType::HDR)
|
||||
{
|
||||
data.Resize(sizeof(float) * comp * textureData.Width * textureData.Height);
|
||||
data.Resize(sizeof(float) * comp * texture->Width * texture->Height);
|
||||
|
||||
auto ptr = (Vector4*)data.Get();
|
||||
for (int32 y = 0; y < textureData.Height; y++)
|
||||
for (int32 y = 0; y < texture->Height; y++)
|
||||
{
|
||||
for (int32 x = 0; x < textureData.Width; x++)
|
||||
for (int32 x = 0; x < texture->Width; x++)
|
||||
{
|
||||
Color color = SamplePoint(sampler, x, y, srcData->Data.Get(), srcData->RowPitch);
|
||||
if (sRGB)
|
||||
color = Color::SrgbToLinear(color);
|
||||
*(ptr + x + y * textureData.Width) = color.ToVector4();
|
||||
*(ptr + x + y * texture->Width) = color.ToVector4();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
data.Resize(sizeof(Color32) * comp * textureData.Width * textureData.Height);
|
||||
data.Resize(sizeof(Color32) * comp * texture->Width * texture->Height);
|
||||
|
||||
auto ptr = (Color32*)data.Get();
|
||||
for (int32 y = 0; y < textureData.Height; y++)
|
||||
for (int32 y = 0; y < texture->Height; y++)
|
||||
{
|
||||
for (int32 x = 0; x < textureData.Width; x++)
|
||||
for (int32 x = 0; x < texture->Width; x++)
|
||||
{
|
||||
Color color = SamplePoint(sampler, x, y, srcData->Data.Get(), srcData->RowPitch);
|
||||
if (sRGB)
|
||||
color = Color::SrgbToLinear(color);
|
||||
*(ptr + x + y * textureData.Width) = Color32(color);
|
||||
*(ptr + x + y * texture->Width) = Color32(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -116,21 +218,21 @@ bool TextureTool::ExportTextureStb(ImageType type, const StringView& path, const
|
||||
switch (type)
|
||||
{
|
||||
case ImageType::BMP:
|
||||
result = stbi_write_bmp_core(&s, textureData.Width, textureData.Height, comp, data.Get());
|
||||
result = stbi_write_bmp_core(&s, texture->Width, texture->Height, comp, data.Get());
|
||||
break;
|
||||
case ImageType::JPEG:
|
||||
result = stbi_write_jpg_core(&s, textureData.Width, textureData.Height, comp, data.Get(), 90);
|
||||
result = stbi_write_jpg_core(&s, texture->Width, texture->Height, comp, data.Get(), 90);
|
||||
break;
|
||||
case ImageType::TGA:
|
||||
result = stbi_write_tga_core(&s, textureData.Width, textureData.Height, comp, data.Get());
|
||||
result = stbi_write_tga_core(&s, texture->Width, texture->Height, comp, data.Get());
|
||||
break;
|
||||
case ImageType::HDR:
|
||||
result = stbi_write_hdr_core(&s, textureData.Width, textureData.Height, comp, (float*)data.Get());
|
||||
result = stbi_write_hdr_core(&s, texture->Width, texture->Height, comp, (float*)data.Get());
|
||||
break;
|
||||
case ImageType::PNG:
|
||||
{
|
||||
int32 ptrSize = 0;
|
||||
const auto ptr = stbi_write_png_to_mem(data.Get(), 0, textureData.Width, textureData.Height, comp, &ptrSize);
|
||||
const auto ptr = stbi_write_png_to_mem(data.Get(), 0, texture->Width, texture->Height, comp, &ptrSize);
|
||||
if (ptr)
|
||||
{
|
||||
file->WriteBytes(ptr, ptrSize);
|
||||
|
||||
14
Source/ThirdParty/detex/LICENSE
vendored
Normal file
14
Source/ThirdParty/detex/LICENSE
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
Copyright (c) 2015 Harm Hanemaaijer <fgenfb@yahoo.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
241
Source/ThirdParty/detex/decompress-bc.cpp
vendored
Normal file
241
Source/ThirdParty/detex/decompress-bc.cpp
vendored
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2015 Harm Hanemaaijer <fgenfb@yahoo.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "detex.h"
|
||||
|
||||
/* Decompress a 64-bit 4x4 pixel texture block compressed using the BC1 */
|
||||
/* format. */
|
||||
bool detexDecompressBlockBC1(const uint8_t * DETEX_RESTRICT bitstring, uint32_t mode_mask,
|
||||
uint32_t flags, uint8_t * DETEX_RESTRICT pixel_buffer) {
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || !defined(__BYTE_ORDER__)
|
||||
uint32_t colors = *(uint32_t *)&bitstring[0];
|
||||
#else
|
||||
uint32_t colors = ((uint32_t)bitstring[0] << 24) |
|
||||
((uint32_t)bitstring[1] << 16) |
|
||||
((uint32_t)bitstring[2] << 8) | bitstring[3];
|
||||
#endif
|
||||
// Decode the two 5-6-5 RGB colors.
|
||||
int color_r[4], color_g[4], color_b[4];
|
||||
color_b[0] = (colors & 0x0000001F) << 3;
|
||||
color_g[0] = (colors & 0x000007E0) >> (5 - 2);
|
||||
color_r[0] = (colors & 0x0000F800) >> (11 - 3);
|
||||
color_b[1] = (colors & 0x001F0000) >> (16 - 3);
|
||||
color_g[1] = (colors & 0x07E00000) >> (21 - 2);
|
||||
color_r[1] = (colors & 0xF8000000) >> (27 - 3);
|
||||
if ((colors & 0xFFFF) > ((colors & 0xFFFF0000) >> 16)) {
|
||||
color_r[2] = detexDivide0To767By3(2 * color_r[0] + color_r[1]);
|
||||
color_g[2] = detexDivide0To767By3(2 * color_g[0] + color_g[1]);
|
||||
color_b[2] = detexDivide0To767By3(2 * color_b[0] + color_b[1]);
|
||||
color_r[3] = detexDivide0To767By3(color_r[0] + 2 * color_r[1]);
|
||||
color_g[3] = detexDivide0To767By3(color_g[0] + 2 * color_g[1]);
|
||||
color_b[3] = detexDivide0To767By3(color_b[0] + 2 * color_b[1]);
|
||||
}
|
||||
else {
|
||||
color_r[2] = (color_r[0] + color_r[1]) / 2;
|
||||
color_g[2] = (color_g[0] + color_g[1]) / 2;
|
||||
color_b[2] = (color_b[0] + color_b[1]) / 2;
|
||||
color_r[3] = color_g[3] = color_b[3] = 0;
|
||||
}
|
||||
uint32_t pixels = *(uint32_t *)&bitstring[4];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int pixel = (pixels >> (i * 2)) & 0x3;
|
||||
*(uint32_t *)(pixel_buffer + i * 4) = detexPack32RGB8Alpha0xFF(
|
||||
color_r[pixel], color_g[pixel], color_b[pixel]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t detexGetModeBC1(const uint8_t *bitstring) {
|
||||
uint32_t colors = *(uint32_t *)bitstring;
|
||||
if ((colors & 0xFFFF) > ((colors & 0xFFFF0000) >> 16))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
void detexSetModeBC1(uint8_t *bitstring, uint32_t mode, uint32_t flags,
|
||||
uint32_t *colors) {
|
||||
uint32_t colorbits = *(uint32_t *)bitstring;
|
||||
uint32_t current_mode;
|
||||
if ((colorbits & 0xFFFF) > ((colorbits & 0xFFFF0000) >> 16))
|
||||
current_mode = 0;
|
||||
else
|
||||
current_mode = 1;
|
||||
if (current_mode != mode) {
|
||||
colorbits = ((colorbits & 0xFFFF) << 16) | (colorbits >> 16);
|
||||
*(uint32_t *)bitstring = colorbits;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decompress a 64-bit 4x4 pixel texture block compressed using the BC1A */
|
||||
/* format. */
|
||||
bool detexDecompressBlockBC1A(const uint8_t * DETEX_RESTRICT bitstring, uint32_t mode_mask,
|
||||
uint32_t flags, uint8_t * DETEX_RESTRICT pixel_buffer) {
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || !defined(__BYTE_ORDER__)
|
||||
uint32_t colors = *(uint32_t *)&bitstring[0];
|
||||
#else
|
||||
uint32_t colors = ((uint32_t)bitstring[0] << 24) |
|
||||
((uint32_t)bitstring[1] << 16) |
|
||||
((uint32_t)bitstring[2] << 8) | bitstring[3];
|
||||
#endif
|
||||
bool opaque = ((colors & 0xFFFF) > ((colors & 0xFFFF0000) >> 16));
|
||||
if (opaque && (flags & DETEX_DECOMPRESS_FLAG_NON_OPAQUE_ONLY))
|
||||
return false;
|
||||
if (!opaque && (flags & DETEX_DECOMPRESS_FLAG_OPAQUE_ONLY))
|
||||
return false;
|
||||
// Decode the two 5-6-5 RGB colors.
|
||||
int color_r[4], color_g[4], color_b[4], color_a[4];
|
||||
color_b[0] = (colors & 0x0000001F) << 3;
|
||||
color_g[0] = (colors & 0x000007E0) >> (5 - 2);
|
||||
color_r[0] = (colors & 0x0000F800) >> (11 - 3);
|
||||
color_b[1] = (colors & 0x001F0000) >> (16 - 3);
|
||||
color_g[1] = (colors & 0x07E00000) >> (21 - 2);
|
||||
color_r[1] = (colors & 0xF8000000) >> (27 - 3);
|
||||
color_a[0] = color_a[1] = color_a[2] = color_a[3] = 0xFF;
|
||||
if (opaque) {
|
||||
color_r[2] = detexDivide0To767By3(2 * color_r[0] + color_r[1]);
|
||||
color_g[2] = detexDivide0To767By3(2 * color_g[0] + color_g[1]);
|
||||
color_b[2] = detexDivide0To767By3(2 * color_b[0] + color_b[1]);
|
||||
color_r[3] = detexDivide0To767By3(color_r[0] + 2 * color_r[1]);
|
||||
color_g[3] = detexDivide0To767By3(color_g[0] + 2 * color_g[1]);
|
||||
color_b[3] = detexDivide0To767By3(color_b[0] + 2 * color_b[1]);
|
||||
}
|
||||
else {
|
||||
color_r[2] = (color_r[0] + color_r[1]) / 2;
|
||||
color_g[2] = (color_g[0] + color_g[1]) / 2;
|
||||
color_b[2] = (color_b[0] + color_b[1]) / 2;
|
||||
color_r[3] = color_g[3] = color_b[3] = color_a[3] = 0;
|
||||
}
|
||||
uint32_t pixels = *(uint32_t *)&bitstring[4];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int pixel = (pixels >> (i * 2)) & 0x3;
|
||||
*(uint32_t *)(pixel_buffer + i * 4) = detexPack32RGBA8(
|
||||
color_r[pixel], color_g[pixel], color_b[pixel],
|
||||
color_a[pixel]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Decompress a 64-bit 4x4 pixel texture block compressed using the BC2 */
|
||||
/* format. */
|
||||
bool detexDecompressBlockBC2(const uint8_t * DETEX_RESTRICT bitstring, uint32_t mode_mask,
|
||||
uint32_t flags, uint8_t * DETEX_RESTRICT pixel_buffer) {
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || !defined(__BYTE_ORDER__)
|
||||
uint32_t colors = *(uint32_t *)&bitstring[8];
|
||||
#else
|
||||
uint32_t colors = ((uint32_t)bitstring[8] << 24) |
|
||||
((uint32_t)bitstring[9] << 16) |
|
||||
((uint32_t)bitstring[10] << 8) | bitstring[11];
|
||||
#endif
|
||||
if ((colors & 0xFFFF) <= ((colors & 0xFFFF0000) >> 16) &&
|
||||
(flags & DETEX_DECOMPRESS_FLAG_ENCODE))
|
||||
// GeForce 6 and 7 series produce wrong result in this case.
|
||||
return false;
|
||||
int color_r[4], color_g[4], color_b[4];
|
||||
color_b[0] = (colors & 0x0000001F) << 3;
|
||||
color_g[0] = (colors & 0x000007E0) >> (5 - 2);
|
||||
color_r[0] = (colors & 0x0000F800) >> (11 - 3);
|
||||
color_b[1] = (colors & 0x001F0000) >> (16 - 3);
|
||||
color_g[1] = (colors & 0x07E00000) >> (21 - 2);
|
||||
color_r[1] = (colors & 0xF8000000) >> (27 - 3);
|
||||
color_r[2] = detexDivide0To767By3(2 * color_r[0] + color_r[1]);
|
||||
color_g[2] = detexDivide0To767By3(2 * color_g[0] + color_g[1]);
|
||||
color_b[2] = detexDivide0To767By3(2 * color_b[0] + color_b[1]);
|
||||
color_r[3] = detexDivide0To767By3(color_r[0] + 2 * color_r[1]);
|
||||
color_g[3] = detexDivide0To767By3(color_g[0] + 2 * color_g[1]);
|
||||
color_b[3] = detexDivide0To767By3(color_b[0] + 2 * color_b[1]);
|
||||
uint32_t pixels = *(uint32_t *)&bitstring[12];
|
||||
uint64_t alpha_pixels = *(uint64_t *)&bitstring[0];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int pixel = (pixels >> (i * 2)) & 0x3;
|
||||
int alpha = ((alpha_pixels >> (i * 4)) & 0xF) * 255 / 15;
|
||||
*(uint32_t *)(pixel_buffer + i * 4) = detexPack32RGBA8(
|
||||
color_r[pixel], color_g[pixel], color_b[pixel], alpha);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Decompress a 64-bit 4x4 pixel texture block compressed using the BC3 */
|
||||
/* format. */
|
||||
bool detexDecompressBlockBC3(const uint8_t * DETEX_RESTRICT bitstring, uint32_t mode_mask,
|
||||
uint32_t flags, uint8_t * DETEX_RESTRICT pixel_buffer) {
|
||||
int alpha0 = bitstring[0];
|
||||
int alpha1 = bitstring[1];
|
||||
if (alpha0 > alpha1 && (flags & DETEX_DECOMPRESS_FLAG_OPAQUE_ONLY))
|
||||
return false;
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || !defined(__BYTE_ORDER__)
|
||||
uint32_t colors = *(uint32_t *)&bitstring[8];
|
||||
#else
|
||||
uint32_t colors = ((uint32_t)bitstring[8] << 24) |
|
||||
((uint32_t)bitstring[9] << 16) |
|
||||
((uint32_t)bitstring[10] << 8) | bitstring[11];
|
||||
#endif
|
||||
if ((colors & 0xFFFF) <= ((colors & 0xFFFF0000) >> 16) &&
|
||||
(flags & DETEX_DECOMPRESS_FLAG_ENCODE))
|
||||
// GeForce 6 and 7 series produce wrong result in this case.
|
||||
return false;
|
||||
int color_r[4], color_g[4], color_b[4];
|
||||
// color_x[] has a value between 0 and 248 with the lower three bits zero.
|
||||
color_b[0] = (colors & 0x0000001F) << 3;
|
||||
color_g[0] = (colors & 0x000007E0) >> (5 - 2);
|
||||
color_r[0] = (colors & 0x0000F800) >> (11 - 3);
|
||||
color_b[1] = (colors & 0x001F0000) >> (16 - 3);
|
||||
color_g[1] = (colors & 0x07E00000) >> (21 - 2);
|
||||
color_r[1] = (colors & 0xF8000000) >> (27 - 3);
|
||||
color_r[2] = detexDivide0To767By3(2 * color_r[0] + color_r[1]);
|
||||
color_g[2] = detexDivide0To767By3(2 * color_g[0] + color_g[1]);
|
||||
color_b[2] = detexDivide0To767By3(2 * color_b[0] + color_b[1]);
|
||||
color_r[3] = detexDivide0To767By3(color_r[0] + 2 * color_r[1]);
|
||||
color_g[3] = detexDivide0To767By3(color_g[0] + 2 * color_g[1]);
|
||||
color_b[3] = detexDivide0To767By3(color_b[0] + 2 * color_b[1]);
|
||||
uint32_t pixels = *(uint32_t *)&bitstring[12];
|
||||
uint64_t alpha_bits = (uint32_t)bitstring[2] |
|
||||
((uint32_t)bitstring[3] << 8) |
|
||||
((uint64_t)*(uint32_t *)&bitstring[4] << 16);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
int pixel = (pixels >> (i * 2)) & 0x3;
|
||||
int code = (alpha_bits >> (i * 3)) & 0x7;
|
||||
int alpha;
|
||||
if (alpha0 > alpha1)
|
||||
switch (code) {
|
||||
case 0 : alpha = alpha0; break;
|
||||
case 1 : alpha = alpha1; break;
|
||||
case 2 : alpha = detexDivide0To1791By7(6 * alpha0 + 1 * alpha1); break;
|
||||
case 3 : alpha = detexDivide0To1791By7(5 * alpha0 + 2 * alpha1); break;
|
||||
case 4 : alpha = detexDivide0To1791By7(4 * alpha0 + 3 * alpha1); break;
|
||||
case 5 : alpha = detexDivide0To1791By7(3 * alpha0 + 4 * alpha1); break;
|
||||
case 6 : alpha = detexDivide0To1791By7(2 * alpha0 + 5 * alpha1); break;
|
||||
case 7 : alpha = detexDivide0To1791By7(1 * alpha0 + 6 * alpha1); break;
|
||||
}
|
||||
else
|
||||
switch (code) {
|
||||
case 0 : alpha = alpha0; break;
|
||||
case 1 : alpha = alpha1; break;
|
||||
case 2 : alpha = detexDivide0To1279By5(4 * alpha0 + 1 * alpha1); break;
|
||||
case 3 : alpha = detexDivide0To1279By5(3 * alpha0 + 2 * alpha1); break;
|
||||
case 4 : alpha = detexDivide0To1279By5(2 * alpha0 + 3 * alpha1); break;
|
||||
case 5 : alpha = detexDivide0To1279By5(1 * alpha0 + 4 * alpha1); break;
|
||||
case 6 : alpha = 0; break;
|
||||
case 7 : alpha = 0xFF; break;
|
||||
}
|
||||
*(uint32_t *)(pixel_buffer + i * 4) = detexPack32RGBA8(
|
||||
color_r[pixel], color_g[pixel], color_b[pixel], alpha);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
21
Source/ThirdParty/detex/detex.Build.cs
vendored
Normal file
21
Source/ThirdParty/detex/detex.Build.cs
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved.
|
||||
|
||||
using Flax.Build;
|
||||
|
||||
/// <summary>
|
||||
/// https://github.com/hglm/detex
|
||||
/// </summary>
|
||||
public class detex : ThirdPartyModule
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
|
||||
LicenseType = LicenseTypes.MIT;
|
||||
LicenseFilePath = "LICENSE";
|
||||
|
||||
// Merge third-party modules into engine binary
|
||||
BinaryModuleName = "FlaxEngine";
|
||||
}
|
||||
}
|
||||
1194
Source/ThirdParty/detex/detex.h
vendored
Normal file
1194
Source/ThirdParty/detex/detex.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
512
Source/ThirdParty/detex/division-tables.cpp
vendored
Normal file
512
Source/ThirdParty/detex/division-tables.cpp
vendored
Normal file
@@ -0,0 +1,512 @@
|
||||
/*
|
||||
|
||||
Copyright (c) 2015 Harm Hanemaaijer <fgenfb@yahoo.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
*/
|
||||
|
||||
#include "detex.h"
|
||||
|
||||
// Integer division using look-up tables, used by BC1/2/3 and RGTC (BC4/5)
|
||||
// decompression.
|
||||
|
||||
const uint8_t detex_division_by_3_table[768] = {
|
||||
0, 0, 0, 1, 1, 1, 2, 2,
|
||||
2, 3, 3, 3, 4, 4, 4, 5,
|
||||
5, 5, 6, 6, 6, 7, 7, 7,
|
||||
8, 8, 8, 9, 9, 9, 10, 10,
|
||||
10, 11, 11, 11, 12, 12, 12, 13,
|
||||
13, 13, 14, 14, 14, 15, 15, 15,
|
||||
16, 16, 16, 17, 17, 17, 18, 18,
|
||||
18, 19, 19, 19, 20, 20, 20, 21,
|
||||
21, 21, 22, 22, 22, 23, 23, 23,
|
||||
24, 24, 24, 25, 25, 25, 26, 26,
|
||||
26, 27, 27, 27, 28, 28, 28, 29,
|
||||
29, 29, 30, 30, 30, 31, 31, 31,
|
||||
32, 32, 32, 33, 33, 33, 34, 34,
|
||||
34, 35, 35, 35, 36, 36, 36, 37,
|
||||
37, 37, 38, 38, 38, 39, 39, 39,
|
||||
40, 40, 40, 41, 41, 41, 42, 42,
|
||||
42, 43, 43, 43, 44, 44, 44, 45,
|
||||
45, 45, 46, 46, 46, 47, 47, 47,
|
||||
48, 48, 48, 49, 49, 49, 50, 50,
|
||||
50, 51, 51, 51, 52, 52, 52, 53,
|
||||
53, 53, 54, 54, 54, 55, 55, 55,
|
||||
56, 56, 56, 57, 57, 57, 58, 58,
|
||||
58, 59, 59, 59, 60, 60, 60, 61,
|
||||
61, 61, 62, 62, 62, 63, 63, 63,
|
||||
64, 64, 64, 65, 65, 65, 66, 66,
|
||||
66, 67, 67, 67, 68, 68, 68, 69,
|
||||
69, 69, 70, 70, 70, 71, 71, 71,
|
||||
72, 72, 72, 73, 73, 73, 74, 74,
|
||||
74, 75, 75, 75, 76, 76, 76, 77,
|
||||
77, 77, 78, 78, 78, 79, 79, 79,
|
||||
80, 80, 80, 81, 81, 81, 82, 82,
|
||||
82, 83, 83, 83, 84, 84, 84, 85,
|
||||
85, 85, 86, 86, 86, 87, 87, 87,
|
||||
88, 88, 88, 89, 89, 89, 90, 90,
|
||||
90, 91, 91, 91, 92, 92, 92, 93,
|
||||
93, 93, 94, 94, 94, 95, 95, 95,
|
||||
96, 96, 96, 97, 97, 97, 98, 98,
|
||||
98, 99, 99, 99, 100, 100, 100, 101,
|
||||
101, 101, 102, 102, 102, 103, 103, 103,
|
||||
104, 104, 104, 105, 105, 105, 106, 106,
|
||||
106, 107, 107, 107, 108, 108, 108, 109,
|
||||
109, 109, 110, 110, 110, 111, 111, 111,
|
||||
112, 112, 112, 113, 113, 113, 114, 114,
|
||||
114, 115, 115, 115, 116, 116, 116, 117,
|
||||
117, 117, 118, 118, 118, 119, 119, 119,
|
||||
120, 120, 120, 121, 121, 121, 122, 122,
|
||||
122, 123, 123, 123, 124, 124, 124, 125,
|
||||
125, 125, 126, 126, 126, 127, 127, 127,
|
||||
128, 128, 128, 129, 129, 129, 130, 130,
|
||||
130, 131, 131, 131, 132, 132, 132, 133,
|
||||
133, 133, 134, 134, 134, 135, 135, 135,
|
||||
136, 136, 136, 137, 137, 137, 138, 138,
|
||||
138, 139, 139, 139, 140, 140, 140, 141,
|
||||
141, 141, 142, 142, 142, 143, 143, 143,
|
||||
144, 144, 144, 145, 145, 145, 146, 146,
|
||||
146, 147, 147, 147, 148, 148, 148, 149,
|
||||
149, 149, 150, 150, 150, 151, 151, 151,
|
||||
152, 152, 152, 153, 153, 153, 154, 154,
|
||||
154, 155, 155, 155, 156, 156, 156, 157,
|
||||
157, 157, 158, 158, 158, 159, 159, 159,
|
||||
160, 160, 160, 161, 161, 161, 162, 162,
|
||||
162, 163, 163, 163, 164, 164, 164, 165,
|
||||
165, 165, 166, 166, 166, 167, 167, 167,
|
||||
168, 168, 168, 169, 169, 169, 170, 170,
|
||||
170, 171, 171, 171, 172, 172, 172, 173,
|
||||
173, 173, 174, 174, 174, 175, 175, 175,
|
||||
176, 176, 176, 177, 177, 177, 178, 178,
|
||||
178, 179, 179, 179, 180, 180, 180, 181,
|
||||
181, 181, 182, 182, 182, 183, 183, 183,
|
||||
184, 184, 184, 185, 185, 185, 186, 186,
|
||||
186, 187, 187, 187, 188, 188, 188, 189,
|
||||
189, 189, 190, 190, 190, 191, 191, 191,
|
||||
192, 192, 192, 193, 193, 193, 194, 194,
|
||||
194, 195, 195, 195, 196, 196, 196, 197,
|
||||
197, 197, 198, 198, 198, 199, 199, 199,
|
||||
200, 200, 200, 201, 201, 201, 202, 202,
|
||||
202, 203, 203, 203, 204, 204, 204, 205,
|
||||
205, 205, 206, 206, 206, 207, 207, 207,
|
||||
208, 208, 208, 209, 209, 209, 210, 210,
|
||||
210, 211, 211, 211, 212, 212, 212, 213,
|
||||
213, 213, 214, 214, 214, 215, 215, 215,
|
||||
216, 216, 216, 217, 217, 217, 218, 218,
|
||||
218, 219, 219, 219, 220, 220, 220, 221,
|
||||
221, 221, 222, 222, 222, 223, 223, 223,
|
||||
224, 224, 224, 225, 225, 225, 226, 226,
|
||||
226, 227, 227, 227, 228, 228, 228, 229,
|
||||
229, 229, 230, 230, 230, 231, 231, 231,
|
||||
232, 232, 232, 233, 233, 233, 234, 234,
|
||||
234, 235, 235, 235, 236, 236, 236, 237,
|
||||
237, 237, 238, 238, 238, 239, 239, 239,
|
||||
240, 240, 240, 241, 241, 241, 242, 242,
|
||||
242, 243, 243, 243, 244, 244, 244, 245,
|
||||
245, 245, 246, 246, 246, 247, 247, 247,
|
||||
248, 248, 248, 249, 249, 249, 250, 250,
|
||||
250, 251, 251, 251, 252, 252, 252, 253,
|
||||
253, 253, 254, 254, 254, 255, 255, 255,
|
||||
};
|
||||
|
||||
const uint8_t detex_division_by_7_table[1792] = {
|
||||
0, 0, 0, 0, 0, 0, 0, 1,
|
||||
1, 1, 1, 1, 1, 1, 2, 2,
|
||||
2, 2, 2, 2, 2, 3, 3, 3,
|
||||
3, 3, 3, 3, 4, 4, 4, 4,
|
||||
4, 4, 4, 5, 5, 5, 5, 5,
|
||||
5, 5, 6, 6, 6, 6, 6, 6,
|
||||
6, 7, 7, 7, 7, 7, 7, 7,
|
||||
8, 8, 8, 8, 8, 8, 8, 9,
|
||||
9, 9, 9, 9, 9, 9, 10, 10,
|
||||
10, 10, 10, 10, 10, 11, 11, 11,
|
||||
11, 11, 11, 11, 12, 12, 12, 12,
|
||||
12, 12, 12, 13, 13, 13, 13, 13,
|
||||
13, 13, 14, 14, 14, 14, 14, 14,
|
||||
14, 15, 15, 15, 15, 15, 15, 15,
|
||||
16, 16, 16, 16, 16, 16, 16, 17,
|
||||
17, 17, 17, 17, 17, 17, 18, 18,
|
||||
18, 18, 18, 18, 18, 19, 19, 19,
|
||||
19, 19, 19, 19, 20, 20, 20, 20,
|
||||
20, 20, 20, 21, 21, 21, 21, 21,
|
||||
21, 21, 22, 22, 22, 22, 22, 22,
|
||||
22, 23, 23, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 24, 24, 25,
|
||||
25, 25, 25, 25, 25, 25, 26, 26,
|
||||
26, 26, 26, 26, 26, 27, 27, 27,
|
||||
27, 27, 27, 27, 28, 28, 28, 28,
|
||||
28, 28, 28, 29, 29, 29, 29, 29,
|
||||
29, 29, 30, 30, 30, 30, 30, 30,
|
||||
30, 31, 31, 31, 31, 31, 31, 31,
|
||||
32, 32, 32, 32, 32, 32, 32, 33,
|
||||
33, 33, 33, 33, 33, 33, 34, 34,
|
||||
34, 34, 34, 34, 34, 35, 35, 35,
|
||||
35, 35, 35, 35, 36, 36, 36, 36,
|
||||
36, 36, 36, 37, 37, 37, 37, 37,
|
||||
37, 37, 38, 38, 38, 38, 38, 38,
|
||||
38, 39, 39, 39, 39, 39, 39, 39,
|
||||
40, 40, 40, 40, 40, 40, 40, 41,
|
||||
41, 41, 41, 41, 41, 41, 42, 42,
|
||||
42, 42, 42, 42, 42, 43, 43, 43,
|
||||
43, 43, 43, 43, 44, 44, 44, 44,
|
||||
44, 44, 44, 45, 45, 45, 45, 45,
|
||||
45, 45, 46, 46, 46, 46, 46, 46,
|
||||
46, 47, 47, 47, 47, 47, 47, 47,
|
||||
48, 48, 48, 48, 48, 48, 48, 49,
|
||||
49, 49, 49, 49, 49, 49, 50, 50,
|
||||
50, 50, 50, 50, 50, 51, 51, 51,
|
||||
51, 51, 51, 51, 52, 52, 52, 52,
|
||||
52, 52, 52, 53, 53, 53, 53, 53,
|
||||
53, 53, 54, 54, 54, 54, 54, 54,
|
||||
54, 55, 55, 55, 55, 55, 55, 55,
|
||||
56, 56, 56, 56, 56, 56, 56, 57,
|
||||
57, 57, 57, 57, 57, 57, 58, 58,
|
||||
58, 58, 58, 58, 58, 59, 59, 59,
|
||||
59, 59, 59, 59, 60, 60, 60, 60,
|
||||
60, 60, 60, 61, 61, 61, 61, 61,
|
||||
61, 61, 62, 62, 62, 62, 62, 62,
|
||||
62, 63, 63, 63, 63, 63, 63, 63,
|
||||
64, 64, 64, 64, 64, 64, 64, 65,
|
||||
65, 65, 65, 65, 65, 65, 66, 66,
|
||||
66, 66, 66, 66, 66, 67, 67, 67,
|
||||
67, 67, 67, 67, 68, 68, 68, 68,
|
||||
68, 68, 68, 69, 69, 69, 69, 69,
|
||||
69, 69, 70, 70, 70, 70, 70, 70,
|
||||
70, 71, 71, 71, 71, 71, 71, 71,
|
||||
72, 72, 72, 72, 72, 72, 72, 73,
|
||||
73, 73, 73, 73, 73, 73, 74, 74,
|
||||
74, 74, 74, 74, 74, 75, 75, 75,
|
||||
75, 75, 75, 75, 76, 76, 76, 76,
|
||||
76, 76, 76, 77, 77, 77, 77, 77,
|
||||
77, 77, 78, 78, 78, 78, 78, 78,
|
||||
78, 79, 79, 79, 79, 79, 79, 79,
|
||||
80, 80, 80, 80, 80, 80, 80, 81,
|
||||
81, 81, 81, 81, 81, 81, 82, 82,
|
||||
82, 82, 82, 82, 82, 83, 83, 83,
|
||||
83, 83, 83, 83, 84, 84, 84, 84,
|
||||
84, 84, 84, 85, 85, 85, 85, 85,
|
||||
85, 85, 86, 86, 86, 86, 86, 86,
|
||||
86, 87, 87, 87, 87, 87, 87, 87,
|
||||
88, 88, 88, 88, 88, 88, 88, 89,
|
||||
89, 89, 89, 89, 89, 89, 90, 90,
|
||||
90, 90, 90, 90, 90, 91, 91, 91,
|
||||
91, 91, 91, 91, 92, 92, 92, 92,
|
||||
92, 92, 92, 93, 93, 93, 93, 93,
|
||||
93, 93, 94, 94, 94, 94, 94, 94,
|
||||
94, 95, 95, 95, 95, 95, 95, 95,
|
||||
96, 96, 96, 96, 96, 96, 96, 97,
|
||||
97, 97, 97, 97, 97, 97, 98, 98,
|
||||
98, 98, 98, 98, 98, 99, 99, 99,
|
||||
99, 99, 99, 99, 100, 100, 100, 100,
|
||||
100, 100, 100, 101, 101, 101, 101, 101,
|
||||
101, 101, 102, 102, 102, 102, 102, 102,
|
||||
102, 103, 103, 103, 103, 103, 103, 103,
|
||||
104, 104, 104, 104, 104, 104, 104, 105,
|
||||
105, 105, 105, 105, 105, 105, 106, 106,
|
||||
106, 106, 106, 106, 106, 107, 107, 107,
|
||||
107, 107, 107, 107, 108, 108, 108, 108,
|
||||
108, 108, 108, 109, 109, 109, 109, 109,
|
||||
109, 109, 110, 110, 110, 110, 110, 110,
|
||||
110, 111, 111, 111, 111, 111, 111, 111,
|
||||
112, 112, 112, 112, 112, 112, 112, 113,
|
||||
113, 113, 113, 113, 113, 113, 114, 114,
|
||||
114, 114, 114, 114, 114, 115, 115, 115,
|
||||
115, 115, 115, 115, 116, 116, 116, 116,
|
||||
116, 116, 116, 117, 117, 117, 117, 117,
|
||||
117, 117, 118, 118, 118, 118, 118, 118,
|
||||
118, 119, 119, 119, 119, 119, 119, 119,
|
||||
120, 120, 120, 120, 120, 120, 120, 121,
|
||||
121, 121, 121, 121, 121, 121, 122, 122,
|
||||
122, 122, 122, 122, 122, 123, 123, 123,
|
||||
123, 123, 123, 123, 124, 124, 124, 124,
|
||||
124, 124, 124, 125, 125, 125, 125, 125,
|
||||
125, 125, 126, 126, 126, 126, 126, 126,
|
||||
126, 127, 127, 127, 127, 127, 127, 127,
|
||||
128, 128, 128, 128, 128, 128, 128, 129,
|
||||
129, 129, 129, 129, 129, 129, 130, 130,
|
||||
130, 130, 130, 130, 130, 131, 131, 131,
|
||||
131, 131, 131, 131, 132, 132, 132, 132,
|
||||
132, 132, 132, 133, 133, 133, 133, 133,
|
||||
133, 133, 134, 134, 134, 134, 134, 134,
|
||||
134, 135, 135, 135, 135, 135, 135, 135,
|
||||
136, 136, 136, 136, 136, 136, 136, 137,
|
||||
137, 137, 137, 137, 137, 137, 138, 138,
|
||||
138, 138, 138, 138, 138, 139, 139, 139,
|
||||
139, 139, 139, 139, 140, 140, 140, 140,
|
||||
140, 140, 140, 141, 141, 141, 141, 141,
|
||||
141, 141, 142, 142, 142, 142, 142, 142,
|
||||
142, 143, 143, 143, 143, 143, 143, 143,
|
||||
144, 144, 144, 144, 144, 144, 144, 145,
|
||||
145, 145, 145, 145, 145, 145, 146, 146,
|
||||
146, 146, 146, 146, 146, 147, 147, 147,
|
||||
147, 147, 147, 147, 148, 148, 148, 148,
|
||||
148, 148, 148, 149, 149, 149, 149, 149,
|
||||
149, 149, 150, 150, 150, 150, 150, 150,
|
||||
150, 151, 151, 151, 151, 151, 151, 151,
|
||||
152, 152, 152, 152, 152, 152, 152, 153,
|
||||
153, 153, 153, 153, 153, 153, 154, 154,
|
||||
154, 154, 154, 154, 154, 155, 155, 155,
|
||||
155, 155, 155, 155, 156, 156, 156, 156,
|
||||
156, 156, 156, 157, 157, 157, 157, 157,
|
||||
157, 157, 158, 158, 158, 158, 158, 158,
|
||||
158, 159, 159, 159, 159, 159, 159, 159,
|
||||
160, 160, 160, 160, 160, 160, 160, 161,
|
||||
161, 161, 161, 161, 161, 161, 162, 162,
|
||||
162, 162, 162, 162, 162, 163, 163, 163,
|
||||
163, 163, 163, 163, 164, 164, 164, 164,
|
||||
164, 164, 164, 165, 165, 165, 165, 165,
|
||||
165, 165, 166, 166, 166, 166, 166, 166,
|
||||
166, 167, 167, 167, 167, 167, 167, 167,
|
||||
168, 168, 168, 168, 168, 168, 168, 169,
|
||||
169, 169, 169, 169, 169, 169, 170, 170,
|
||||
170, 170, 170, 170, 170, 171, 171, 171,
|
||||
171, 171, 171, 171, 172, 172, 172, 172,
|
||||
172, 172, 172, 173, 173, 173, 173, 173,
|
||||
173, 173, 174, 174, 174, 174, 174, 174,
|
||||
174, 175, 175, 175, 175, 175, 175, 175,
|
||||
176, 176, 176, 176, 176, 176, 176, 177,
|
||||
177, 177, 177, 177, 177, 177, 178, 178,
|
||||
178, 178, 178, 178, 178, 179, 179, 179,
|
||||
179, 179, 179, 179, 180, 180, 180, 180,
|
||||
180, 180, 180, 181, 181, 181, 181, 181,
|
||||
181, 181, 182, 182, 182, 182, 182, 182,
|
||||
182, 183, 183, 183, 183, 183, 183, 183,
|
||||
184, 184, 184, 184, 184, 184, 184, 185,
|
||||
185, 185, 185, 185, 185, 185, 186, 186,
|
||||
186, 186, 186, 186, 186, 187, 187, 187,
|
||||
187, 187, 187, 187, 188, 188, 188, 188,
|
||||
188, 188, 188, 189, 189, 189, 189, 189,
|
||||
189, 189, 190, 190, 190, 190, 190, 190,
|
||||
190, 191, 191, 191, 191, 191, 191, 191,
|
||||
192, 192, 192, 192, 192, 192, 192, 193,
|
||||
193, 193, 193, 193, 193, 193, 194, 194,
|
||||
194, 194, 194, 194, 194, 195, 195, 195,
|
||||
195, 195, 195, 195, 196, 196, 196, 196,
|
||||
196, 196, 196, 197, 197, 197, 197, 197,
|
||||
197, 197, 198, 198, 198, 198, 198, 198,
|
||||
198, 199, 199, 199, 199, 199, 199, 199,
|
||||
200, 200, 200, 200, 200, 200, 200, 201,
|
||||
201, 201, 201, 201, 201, 201, 202, 202,
|
||||
202, 202, 202, 202, 202, 203, 203, 203,
|
||||
203, 203, 203, 203, 204, 204, 204, 204,
|
||||
204, 204, 204, 205, 205, 205, 205, 205,
|
||||
205, 205, 206, 206, 206, 206, 206, 206,
|
||||
206, 207, 207, 207, 207, 207, 207, 207,
|
||||
208, 208, 208, 208, 208, 208, 208, 209,
|
||||
209, 209, 209, 209, 209, 209, 210, 210,
|
||||
210, 210, 210, 210, 210, 211, 211, 211,
|
||||
211, 211, 211, 211, 212, 212, 212, 212,
|
||||
212, 212, 212, 213, 213, 213, 213, 213,
|
||||
213, 213, 214, 214, 214, 214, 214, 214,
|
||||
214, 215, 215, 215, 215, 215, 215, 215,
|
||||
216, 216, 216, 216, 216, 216, 216, 217,
|
||||
217, 217, 217, 217, 217, 217, 218, 218,
|
||||
218, 218, 218, 218, 218, 219, 219, 219,
|
||||
219, 219, 219, 219, 220, 220, 220, 220,
|
||||
220, 220, 220, 221, 221, 221, 221, 221,
|
||||
221, 221, 222, 222, 222, 222, 222, 222,
|
||||
222, 223, 223, 223, 223, 223, 223, 223,
|
||||
224, 224, 224, 224, 224, 224, 224, 225,
|
||||
225, 225, 225, 225, 225, 225, 226, 226,
|
||||
226, 226, 226, 226, 226, 227, 227, 227,
|
||||
227, 227, 227, 227, 228, 228, 228, 228,
|
||||
228, 228, 228, 229, 229, 229, 229, 229,
|
||||
229, 229, 230, 230, 230, 230, 230, 230,
|
||||
230, 231, 231, 231, 231, 231, 231, 231,
|
||||
232, 232, 232, 232, 232, 232, 232, 233,
|
||||
233, 233, 233, 233, 233, 233, 234, 234,
|
||||
234, 234, 234, 234, 234, 235, 235, 235,
|
||||
235, 235, 235, 235, 236, 236, 236, 236,
|
||||
236, 236, 236, 237, 237, 237, 237, 237,
|
||||
237, 237, 238, 238, 238, 238, 238, 238,
|
||||
238, 239, 239, 239, 239, 239, 239, 239,
|
||||
240, 240, 240, 240, 240, 240, 240, 241,
|
||||
241, 241, 241, 241, 241, 241, 242, 242,
|
||||
242, 242, 242, 242, 242, 243, 243, 243,
|
||||
243, 243, 243, 243, 244, 244, 244, 244,
|
||||
244, 244, 244, 245, 245, 245, 245, 245,
|
||||
245, 245, 246, 246, 246, 246, 246, 246,
|
||||
246, 247, 247, 247, 247, 247, 247, 247,
|
||||
248, 248, 248, 248, 248, 248, 248, 249,
|
||||
249, 249, 249, 249, 249, 249, 250, 250,
|
||||
250, 250, 250, 250, 250, 251, 251, 251,
|
||||
251, 251, 251, 251, 252, 252, 252, 252,
|
||||
252, 252, 252, 253, 253, 253, 253, 253,
|
||||
253, 253, 254, 254, 254, 254, 254, 254,
|
||||
254, 255, 255, 255, 255, 255, 255, 255,
|
||||
};
|
||||
|
||||
const uint8_t detex_division_by_5_table[1280] = {
|
||||
0, 0, 0, 0, 0, 1, 1, 1,
|
||||
1, 1, 2, 2, 2, 2, 2, 3,
|
||||
3, 3, 3, 3, 4, 4, 4, 4,
|
||||
4, 5, 5, 5, 5, 5, 6, 6,
|
||||
6, 6, 6, 7, 7, 7, 7, 7,
|
||||
8, 8, 8, 8, 8, 9, 9, 9,
|
||||
9, 9, 10, 10, 10, 10, 10, 11,
|
||||
11, 11, 11, 11, 12, 12, 12, 12,
|
||||
12, 13, 13, 13, 13, 13, 14, 14,
|
||||
14, 14, 14, 15, 15, 15, 15, 15,
|
||||
16, 16, 16, 16, 16, 17, 17, 17,
|
||||
17, 17, 18, 18, 18, 18, 18, 19,
|
||||
19, 19, 19, 19, 20, 20, 20, 20,
|
||||
20, 21, 21, 21, 21, 21, 22, 22,
|
||||
22, 22, 22, 23, 23, 23, 23, 23,
|
||||
24, 24, 24, 24, 24, 25, 25, 25,
|
||||
25, 25, 26, 26, 26, 26, 26, 27,
|
||||
27, 27, 27, 27, 28, 28, 28, 28,
|
||||
28, 29, 29, 29, 29, 29, 30, 30,
|
||||
30, 30, 30, 31, 31, 31, 31, 31,
|
||||
32, 32, 32, 32, 32, 33, 33, 33,
|
||||
33, 33, 34, 34, 34, 34, 34, 35,
|
||||
35, 35, 35, 35, 36, 36, 36, 36,
|
||||
36, 37, 37, 37, 37, 37, 38, 38,
|
||||
38, 38, 38, 39, 39, 39, 39, 39,
|
||||
40, 40, 40, 40, 40, 41, 41, 41,
|
||||
41, 41, 42, 42, 42, 42, 42, 43,
|
||||
43, 43, 43, 43, 44, 44, 44, 44,
|
||||
44, 45, 45, 45, 45, 45, 46, 46,
|
||||
46, 46, 46, 47, 47, 47, 47, 47,
|
||||
48, 48, 48, 48, 48, 49, 49, 49,
|
||||
49, 49, 50, 50, 50, 50, 50, 51,
|
||||
51, 51, 51, 51, 52, 52, 52, 52,
|
||||
52, 53, 53, 53, 53, 53, 54, 54,
|
||||
54, 54, 54, 55, 55, 55, 55, 55,
|
||||
56, 56, 56, 56, 56, 57, 57, 57,
|
||||
57, 57, 58, 58, 58, 58, 58, 59,
|
||||
59, 59, 59, 59, 60, 60, 60, 60,
|
||||
60, 61, 61, 61, 61, 61, 62, 62,
|
||||
62, 62, 62, 63, 63, 63, 63, 63,
|
||||
64, 64, 64, 64, 64, 65, 65, 65,
|
||||
65, 65, 66, 66, 66, 66, 66, 67,
|
||||
67, 67, 67, 67, 68, 68, 68, 68,
|
||||
68, 69, 69, 69, 69, 69, 70, 70,
|
||||
70, 70, 70, 71, 71, 71, 71, 71,
|
||||
72, 72, 72, 72, 72, 73, 73, 73,
|
||||
73, 73, 74, 74, 74, 74, 74, 75,
|
||||
75, 75, 75, 75, 76, 76, 76, 76,
|
||||
76, 77, 77, 77, 77, 77, 78, 78,
|
||||
78, 78, 78, 79, 79, 79, 79, 79,
|
||||
80, 80, 80, 80, 80, 81, 81, 81,
|
||||
81, 81, 82, 82, 82, 82, 82, 83,
|
||||
83, 83, 83, 83, 84, 84, 84, 84,
|
||||
84, 85, 85, 85, 85, 85, 86, 86,
|
||||
86, 86, 86, 87, 87, 87, 87, 87,
|
||||
88, 88, 88, 88, 88, 89, 89, 89,
|
||||
89, 89, 90, 90, 90, 90, 90, 91,
|
||||
91, 91, 91, 91, 92, 92, 92, 92,
|
||||
92, 93, 93, 93, 93, 93, 94, 94,
|
||||
94, 94, 94, 95, 95, 95, 95, 95,
|
||||
96, 96, 96, 96, 96, 97, 97, 97,
|
||||
97, 97, 98, 98, 98, 98, 98, 99,
|
||||
99, 99, 99, 99, 100, 100, 100, 100,
|
||||
100, 101, 101, 101, 101, 101, 102, 102,
|
||||
102, 102, 102, 103, 103, 103, 103, 103,
|
||||
104, 104, 104, 104, 104, 105, 105, 105,
|
||||
105, 105, 106, 106, 106, 106, 106, 107,
|
||||
107, 107, 107, 107, 108, 108, 108, 108,
|
||||
108, 109, 109, 109, 109, 109, 110, 110,
|
||||
110, 110, 110, 111, 111, 111, 111, 111,
|
||||
112, 112, 112, 112, 112, 113, 113, 113,
|
||||
113, 113, 114, 114, 114, 114, 114, 115,
|
||||
115, 115, 115, 115, 116, 116, 116, 116,
|
||||
116, 117, 117, 117, 117, 117, 118, 118,
|
||||
118, 118, 118, 119, 119, 119, 119, 119,
|
||||
120, 120, 120, 120, 120, 121, 121, 121,
|
||||
121, 121, 122, 122, 122, 122, 122, 123,
|
||||
123, 123, 123, 123, 124, 124, 124, 124,
|
||||
124, 125, 125, 125, 125, 125, 126, 126,
|
||||
126, 126, 126, 127, 127, 127, 127, 127,
|
||||
128, 128, 128, 128, 128, 129, 129, 129,
|
||||
129, 129, 130, 130, 130, 130, 130, 131,
|
||||
131, 131, 131, 131, 132, 132, 132, 132,
|
||||
132, 133, 133, 133, 133, 133, 134, 134,
|
||||
134, 134, 134, 135, 135, 135, 135, 135,
|
||||
136, 136, 136, 136, 136, 137, 137, 137,
|
||||
137, 137, 138, 138, 138, 138, 138, 139,
|
||||
139, 139, 139, 139, 140, 140, 140, 140,
|
||||
140, 141, 141, 141, 141, 141, 142, 142,
|
||||
142, 142, 142, 143, 143, 143, 143, 143,
|
||||
144, 144, 144, 144, 144, 145, 145, 145,
|
||||
145, 145, 146, 146, 146, 146, 146, 147,
|
||||
147, 147, 147, 147, 148, 148, 148, 148,
|
||||
148, 149, 149, 149, 149, 149, 150, 150,
|
||||
150, 150, 150, 151, 151, 151, 151, 151,
|
||||
152, 152, 152, 152, 152, 153, 153, 153,
|
||||
153, 153, 154, 154, 154, 154, 154, 155,
|
||||
155, 155, 155, 155, 156, 156, 156, 156,
|
||||
156, 157, 157, 157, 157, 157, 158, 158,
|
||||
158, 158, 158, 159, 159, 159, 159, 159,
|
||||
160, 160, 160, 160, 160, 161, 161, 161,
|
||||
161, 161, 162, 162, 162, 162, 162, 163,
|
||||
163, 163, 163, 163, 164, 164, 164, 164,
|
||||
164, 165, 165, 165, 165, 165, 166, 166,
|
||||
166, 166, 166, 167, 167, 167, 167, 167,
|
||||
168, 168, 168, 168, 168, 169, 169, 169,
|
||||
169, 169, 170, 170, 170, 170, 170, 171,
|
||||
171, 171, 171, 171, 172, 172, 172, 172,
|
||||
172, 173, 173, 173, 173, 173, 174, 174,
|
||||
174, 174, 174, 175, 175, 175, 175, 175,
|
||||
176, 176, 176, 176, 176, 177, 177, 177,
|
||||
177, 177, 178, 178, 178, 178, 178, 179,
|
||||
179, 179, 179, 179, 180, 180, 180, 180,
|
||||
180, 181, 181, 181, 181, 181, 182, 182,
|
||||
182, 182, 182, 183, 183, 183, 183, 183,
|
||||
184, 184, 184, 184, 184, 185, 185, 185,
|
||||
185, 185, 186, 186, 186, 186, 186, 187,
|
||||
187, 187, 187, 187, 188, 188, 188, 188,
|
||||
188, 189, 189, 189, 189, 189, 190, 190,
|
||||
190, 190, 190, 191, 191, 191, 191, 191,
|
||||
192, 192, 192, 192, 192, 193, 193, 193,
|
||||
193, 193, 194, 194, 194, 194, 194, 195,
|
||||
195, 195, 195, 195, 196, 196, 196, 196,
|
||||
196, 197, 197, 197, 197, 197, 198, 198,
|
||||
198, 198, 198, 199, 199, 199, 199, 199,
|
||||
200, 200, 200, 200, 200, 201, 201, 201,
|
||||
201, 201, 202, 202, 202, 202, 202, 203,
|
||||
203, 203, 203, 203, 204, 204, 204, 204,
|
||||
204, 205, 205, 205, 205, 205, 206, 206,
|
||||
206, 206, 206, 207, 207, 207, 207, 207,
|
||||
208, 208, 208, 208, 208, 209, 209, 209,
|
||||
209, 209, 210, 210, 210, 210, 210, 211,
|
||||
211, 211, 211, 211, 212, 212, 212, 212,
|
||||
212, 213, 213, 213, 213, 213, 214, 214,
|
||||
214, 214, 214, 215, 215, 215, 215, 215,
|
||||
216, 216, 216, 216, 216, 217, 217, 217,
|
||||
217, 217, 218, 218, 218, 218, 218, 219,
|
||||
219, 219, 219, 219, 220, 220, 220, 220,
|
||||
220, 221, 221, 221, 221, 221, 222, 222,
|
||||
222, 222, 222, 223, 223, 223, 223, 223,
|
||||
224, 224, 224, 224, 224, 225, 225, 225,
|
||||
225, 225, 226, 226, 226, 226, 226, 227,
|
||||
227, 227, 227, 227, 228, 228, 228, 228,
|
||||
228, 229, 229, 229, 229, 229, 230, 230,
|
||||
230, 230, 230, 231, 231, 231, 231, 231,
|
||||
232, 232, 232, 232, 232, 233, 233, 233,
|
||||
233, 233, 234, 234, 234, 234, 234, 235,
|
||||
235, 235, 235, 235, 236, 236, 236, 236,
|
||||
236, 237, 237, 237, 237, 237, 238, 238,
|
||||
238, 238, 238, 239, 239, 239, 239, 239,
|
||||
240, 240, 240, 240, 240, 241, 241, 241,
|
||||
241, 241, 242, 242, 242, 242, 242, 243,
|
||||
243, 243, 243, 243, 244, 244, 244, 244,
|
||||
244, 245, 245, 245, 245, 245, 246, 246,
|
||||
246, 246, 246, 247, 247, 247, 247, 247,
|
||||
248, 248, 248, 248, 248, 249, 249, 249,
|
||||
249, 249, 250, 250, 250, 250, 250, 251,
|
||||
251, 251, 251, 251, 252, 252, 252, 252,
|
||||
252, 253, 253, 253, 253, 253, 254, 254,
|
||||
254, 254, 254, 255, 255, 255, 255, 255,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user