mirror of
https://github.com/holub/mame
synced 2025-04-21 07:52:35 +03:00
Update bimg to latest
This commit is contained in:
parent
a851430879
commit
702c9b45cc
3
3rdparty/bimg/.appveyor.yml
vendored
3
3rdparty/bimg/.appveyor.yml
vendored
@ -1,11 +1,12 @@
|
||||
shallow_clone: true
|
||||
|
||||
os:
|
||||
- Visual Studio 2017
|
||||
- Visual Studio 2019
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- TOOLSET: vs2017
|
||||
- TOOLSET: vs2019
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
|
2
3rdparty/bimg/.travis.yml
vendored
2
3rdparty/bimg/.travis.yml
vendored
@ -29,4 +29,4 @@ branches:
|
||||
notifications:
|
||||
email: false
|
||||
|
||||
osx_image: xcode9.3
|
||||
osx_image: xcode11
|
||||
|
1
3rdparty/bimg/3rdparty/astc/astc_lib.cpp
vendored
1
3rdparty/bimg/3rdparty/astc/astc_lib.cpp
vendored
@ -53,6 +53,7 @@ namespace
|
||||
{ 0, 1, 2, 3 }, // ASTC_RGBA
|
||||
{ 2, 1, 0, 3 }, // ASTC_BGRA
|
||||
{ 0, 0, 0, 1 }, // ASTC_ENC_NORMAL_RA
|
||||
{ 0, 0, 0, 1 }, // ASTC_ENC_NORMAL_RA_PCPT
|
||||
{ 0, 3, 6, 5 }, // ASTC_DEC_RA_NORMAL
|
||||
};
|
||||
|
||||
|
16
3rdparty/bimg/3rdparty/astc/mathlib.cpp
vendored
16
3rdparty/bimg/3rdparty/astc/mathlib.cpp
vendored
@ -1,4 +1,4 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/**
|
||||
* This confidential and proprietary software may be used only as
|
||||
* authorised by a licensing agreement from ARM Limited
|
||||
@ -10,8 +10,8 @@
|
||||
* by a licensing agreement from ARM Limited.
|
||||
*
|
||||
* @brief Library of math functions.
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
*/
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#define _USE_MATH_DEFINES // for M_PI on windows
|
||||
|
||||
@ -116,7 +116,7 @@ float4 fmin(float4 p, float4 q)
|
||||
return float4(fmin(p.x, q.x), fmin(p.y, q.y), fmin(p.z, q.z), fmin(p.w, q.w));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
float dot( float2 p, float2 q ) { return p.x*q.x + p.y*q.y; } float dot( float3 p, float3 q ) { return p.x*q.x + p.y*q.y + p.z*q.z; } float dot( float4 p, float4 q ) { return p.x*q.x + p.y*q.y +
|
||||
p.z*q.z + p.w*q.w; } */
|
||||
|
||||
@ -225,7 +225,7 @@ float4 normalize(float4 p)
|
||||
|
||||
*************************************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
struct mat2 { float2 v[2]; };
|
||||
struct mat3 { float3 v[3]; };
|
||||
struct mat4 { float4 v[4]; };
|
||||
@ -265,7 +265,7 @@ float determinant(mat4 p)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
characteristic polynomials for matrices. These polynomials are monic, meaning that the coefficient of the highest component is 1; this component is omitted. The first component is the constant
|
||||
part. */
|
||||
|
||||
@ -293,7 +293,7 @@ float4 characteristic_poly(mat4 p)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
Root finders for monic polynomials (highest coefficient is equal to 1)
|
||||
|
||||
Returns a vector with length equal to the number of roots that the polynomial has;
|
||||
@ -362,7 +362,7 @@ float3 solve_monic(float3 p)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
/*
|
||||
* This function is not overflow-safe. Use with care.
|
||||
*/
|
||||
float4 solve_monic(float4 p)
|
||||
|
28
3rdparty/bimg/3rdparty/astc/vectypes.h
vendored
28
3rdparty/bimg/3rdparty/astc/vectypes.h
vendored
@ -16,11 +16,11 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned short ushort;
|
||||
typedef unsigned long ulong;
|
||||
typedef unsigned char uchar;
|
||||
typedef signed char schar;
|
||||
typedef uint32_t uint;
|
||||
typedef uint16_t ushort;
|
||||
typedef uint64_t ulong;
|
||||
typedef uint8_t uchar;
|
||||
typedef int8_t schar;
|
||||
|
||||
template < typename vtype > class vtype2;
|
||||
|
||||
@ -9756,21 +9756,21 @@ typedef vtype4 < float >float4;
|
||||
typedef vtype2 < double >double2;
|
||||
typedef vtype3 < double >double3;
|
||||
typedef vtype4 < double >double4;
|
||||
typedef vtype2 < int >int2;
|
||||
typedef vtype3 < int >int3;
|
||||
typedef vtype4 < int >int4;
|
||||
typedef vtype2 < int32_t >int2;
|
||||
typedef vtype3 < int32_t >int3;
|
||||
typedef vtype4 < int32_t >int4;
|
||||
typedef vtype2 < uint > uint2;
|
||||
typedef vtype3 < uint > uint3;
|
||||
typedef vtype4 < uint > uint4;
|
||||
typedef vtype2 < short >short2;
|
||||
typedef vtype3 < short >short3;
|
||||
typedef vtype4 < short >short4;
|
||||
typedef vtype2 < int16_t >short2;
|
||||
typedef vtype3 < int16_t >short3;
|
||||
typedef vtype4 < int16_t >short4;
|
||||
typedef vtype2 < ushort > ushort2;
|
||||
typedef vtype3 < ushort > ushort3;
|
||||
typedef vtype4 < ushort > ushort4;
|
||||
typedef vtype2 < long >long2;
|
||||
typedef vtype3 < long >long3;
|
||||
typedef vtype4 < long >long4;
|
||||
typedef vtype2 < int64_t >long2;
|
||||
typedef vtype3 < int64_t >long3;
|
||||
typedef vtype4 < int64_t >long4;
|
||||
typedef vtype2 < ulong > ulong2;
|
||||
typedef vtype3 < ulong > ulong3;
|
||||
typedef vtype4 < ulong > ulong4;
|
||||
|
21
3rdparty/bimg/3rdparty/lodepng/LICENSE
vendored
Normal file
21
3rdparty/bimg/3rdparty/lodepng/LICENSE
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
Copyright (c) 2005-2018 Lode Vandevenne
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
10
3rdparty/bimg/3rdparty/lodepng/README.md
vendored
10
3rdparty/bimg/3rdparty/lodepng/README.md
vendored
@ -1,10 +0,0 @@
|
||||
LodePNG
|
||||
-------
|
||||
|
||||
PNG encoder and decoder in C and C++.
|
||||
|
||||
Home page: http://lodev.org/lodepng/
|
||||
|
||||
Only two files are needed to allow your program to read and write PNG files: lodepng.cpp and lodepng.h.
|
||||
|
||||
The other files in the project are just examples, unit tests, etc...
|
5528
3rdparty/bimg/3rdparty/lodepng/lodepng.cpp
vendored
5528
3rdparty/bimg/3rdparty/lodepng/lodepng.cpp
vendored
File diff suppressed because it is too large
Load Diff
464
3rdparty/bimg/3rdparty/lodepng/lodepng.h
vendored
464
3rdparty/bimg/3rdparty/lodepng/lodepng.h
vendored
@ -1,7 +1,7 @@
|
||||
/*
|
||||
LodePNG version 20160501
|
||||
LodePNG version 20200306
|
||||
|
||||
Copyright (c) 2005-2016 Lode Vandevenne
|
||||
Copyright (c) 2005-2020 Lode Vandevenne
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
@ -44,36 +44,44 @@ the custom_zlib field of the compress and decompress settings*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ZLIB
|
||||
#define LODEPNG_COMPILE_ZLIB
|
||||
#endif
|
||||
|
||||
/*png encoder and png decoder*/
|
||||
#ifndef LODEPNG_NO_COMPILE_PNG
|
||||
#define LODEPNG_COMPILE_PNG
|
||||
#endif
|
||||
|
||||
/*deflate&zlib decoder and png decoder*/
|
||||
#ifndef LODEPNG_NO_COMPILE_DECODER
|
||||
#define LODEPNG_COMPILE_DECODER
|
||||
#endif
|
||||
|
||||
/*deflate&zlib encoder and png encoder*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ENCODER
|
||||
#define LODEPNG_COMPILE_ENCODER
|
||||
#endif
|
||||
|
||||
/*the optional built in harddisk file loading and saving functions*/
|
||||
#ifndef LODEPNG_NO_COMPILE_DISK
|
||||
#define LODEPNG_COMPILE_DISK
|
||||
#endif
|
||||
|
||||
/*support for chunks other than IHDR, IDAT, PLTE, tRNS, IEND: ancillary and unknown chunks*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
|
||||
#define LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
#endif
|
||||
|
||||
/*ability to convert error numerical codes to English text string*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ERROR_TEXT
|
||||
#define LODEPNG_COMPILE_ERROR_TEXT
|
||||
#endif
|
||||
|
||||
/*Compile the default allocators (C's free, malloc and realloc). If you disable this,
|
||||
you can define the functions lodepng_free, lodepng_malloc and lodepng_realloc in your
|
||||
source files with custom allocators.*/
|
||||
#ifndef LODEPNG_NO_COMPILE_ALLOCATORS
|
||||
#define LODEPNG_COMPILE_ALLOCATORS
|
||||
#endif
|
||||
|
||||
/*compile the C++ version (you can disable the C++ wrapper here even when compiling for C++)*/
|
||||
#ifdef __cplusplus
|
||||
#ifndef LODEPNG_NO_COMPILE_CPP
|
||||
@ -87,14 +95,19 @@ source files with custom allocators.*/
|
||||
#endif /*LODEPNG_COMPILE_CPP*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
/*The PNG color types (also used for raw).*/
|
||||
typedef enum LodePNGColorType
|
||||
{
|
||||
LCT_GREY = 0, /*greyscale: 1,2,4,8,16 bit*/
|
||||
/*The PNG color types (also used for raw image).*/
|
||||
typedef enum LodePNGColorType {
|
||||
LCT_GREY = 0, /*grayscale: 1,2,4,8,16 bit*/
|
||||
LCT_RGB = 2, /*RGB: 8,16 bit*/
|
||||
LCT_PALETTE = 3, /*palette: 1,2,4,8 bit*/
|
||||
LCT_GREY_ALPHA = 4, /*greyscale with alpha: 8,16 bit*/
|
||||
LCT_RGBA = 6 /*RGB with alpha: 8,16 bit*/
|
||||
LCT_GREY_ALPHA = 4, /*grayscale with alpha: 8,16 bit*/
|
||||
LCT_RGBA = 6, /*RGB with alpha: 8,16 bit*/
|
||||
/*LCT_MAX_OCTET_VALUE lets the compiler allow this enum to represent any invalid
|
||||
byte value from 0 to 255 that could be present in an invalid PNG file header. Do
|
||||
not use, compare with or set the name LCT_MAX_OCTET_VALUE, instead either use
|
||||
the valid color type names above, or numeric values like 1 or 7 when checking for
|
||||
particular disallowed color type byte values, or cast to integer to print it.*/
|
||||
LCT_MAX_OCTET_VALUE = 255
|
||||
} LodePNGColorType;
|
||||
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
@ -196,8 +209,7 @@ unsigned lodepng_encode24_file(const char* filename,
|
||||
|
||||
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
namespace lodepng
|
||||
{
|
||||
namespace lodepng {
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
/*Same as lodepng_decode_memory, but decodes to an std::vector. The colortype
|
||||
is the format to output the pixels to. Default is RGBA 8-bit per channel.*/
|
||||
@ -253,17 +265,17 @@ const char* lodepng_error_text(unsigned code);
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
/*Settings for zlib decompression*/
|
||||
typedef struct LodePNGDecompressSettings LodePNGDecompressSettings;
|
||||
struct LodePNGDecompressSettings
|
||||
{
|
||||
struct LodePNGDecompressSettings {
|
||||
/* Check LodePNGDecoderSettings for more ignorable errors such as ignore_crc */
|
||||
unsigned ignore_adler32; /*if 1, continue and don't give an error message if the Adler32 checksum is corrupted*/
|
||||
unsigned ignore_nlen; /*ignore complement of len checksum in uncompressed blocks*/
|
||||
|
||||
/*use custom zlib decoder instead of built in one (default: null)*/
|
||||
unsigned (*custom_zlib)(unsigned char**, size_t*,
|
||||
const unsigned char*, size_t,
|
||||
const LodePNGDecompressSettings*);
|
||||
/*use custom deflate decoder instead of built in one (default: null)
|
||||
if custom_zlib is used, custom_deflate is ignored since only the built in
|
||||
zlib function will call custom_deflate*/
|
||||
if custom_zlib is not null, custom_inflate is ignored (the zlib format uses deflate)*/
|
||||
unsigned (*custom_inflate)(unsigned char**, size_t*,
|
||||
const unsigned char*, size_t,
|
||||
const LodePNGDecompressSettings*);
|
||||
@ -281,13 +293,12 @@ Settings for zlib compression. Tweaking these settings tweaks the balance
|
||||
between speed and compression ratio.
|
||||
*/
|
||||
typedef struct LodePNGCompressSettings LodePNGCompressSettings;
|
||||
struct LodePNGCompressSettings /*deflate = compress*/
|
||||
{
|
||||
struct LodePNGCompressSettings /*deflate = compress*/ {
|
||||
/*LZ77 related settings*/
|
||||
unsigned btype; /*the block type for LZ (0, 1, 2 or 3, see zlib standard). Should be 2 for proper compression.*/
|
||||
unsigned use_lz77; /*whether or not to use LZ77. Should be 1 for proper compression.*/
|
||||
unsigned windowsize; /*must be a power of two <= 32768. higher compresses more but is slower. Default value: 2048.*/
|
||||
unsigned minmatch; /*mininum lz77 length. 3 is normally best, 6 can be better for some PNGs. Default: 0*/
|
||||
unsigned minmatch; /*minimum lz77 length. 3 is normally best, 6 can be better for some PNGs. Default: 0*/
|
||||
unsigned nicematch; /*stop searching if >= this length found. Set to 258 for best compression. Default: 128*/
|
||||
unsigned lazymatching; /*use lazy matching: better compression but a bit slower. Default: true*/
|
||||
|
||||
@ -315,8 +326,7 @@ Color mode of an image. Contains all information required to decode the pixel
|
||||
bits to RGBA colors. This information is the same as used in the PNG file
|
||||
format, and is used both for PNG and raw image data in LodePNG.
|
||||
*/
|
||||
typedef struct LodePNGColorMode
|
||||
{
|
||||
typedef struct LodePNGColorMode {
|
||||
/*header (IHDR)*/
|
||||
LodePNGColorType colortype; /*color type, see PNG standard or documentation further in this header file*/
|
||||
unsigned bitdepth; /*bits per sample, see PNG standard or documentation further in this header file*/
|
||||
@ -325,23 +335,25 @@ typedef struct LodePNGColorMode
|
||||
palette (PLTE and tRNS)
|
||||
|
||||
Dynamically allocated with the colors of the palette, including alpha.
|
||||
When encoding a PNG, to store your colors in the palette of the LodePNGColorMode, first use
|
||||
lodepng_palette_clear, then for each color use lodepng_palette_add.
|
||||
If you encode an image without alpha with palette, don't forget to put value 255 in each A byte of the palette.
|
||||
This field may not be allocated directly, use lodepng_color_mode_init first,
|
||||
then lodepng_palette_add per color to correctly initialize it (to ensure size
|
||||
of exactly 1024 bytes).
|
||||
|
||||
The alpha channels must be set as well, set them to 255 for opaque images.
|
||||
|
||||
When decoding, by default you can ignore this palette, since LodePNG already
|
||||
fills the palette colors in the pixels of the raw RGBA output.
|
||||
|
||||
The palette is only supported for color type 3.
|
||||
*/
|
||||
unsigned char* palette; /*palette in RGBARGBA... order. When allocated, must be either 0, or have size 1024*/
|
||||
size_t palettesize; /*palette size in number of colors (amount of bytes is 4 * palettesize)*/
|
||||
unsigned char* palette; /*palette in RGBARGBA... order. Must be either 0, or when allocated must have 1024 bytes*/
|
||||
size_t palettesize; /*palette size in number of colors (amount of used bytes is 4 * palettesize)*/
|
||||
|
||||
/*
|
||||
transparent color key (tRNS)
|
||||
|
||||
This color uses the same bit depth as the bitdepth value in this struct, which can be 1-bit to 16-bit.
|
||||
For greyscale PNGs, r, g and b will all 3 be set to the same.
|
||||
For grayscale PNGs, r, g and b will all 3 be set to the same.
|
||||
|
||||
When decoding, by default you can ignore this information, since LodePNG sets
|
||||
pixels with this key to transparent already in the raw RGBA output.
|
||||
@ -349,7 +361,7 @@ typedef struct LodePNGColorMode
|
||||
The color key is only supported for color types 0 and 2.
|
||||
*/
|
||||
unsigned key_defined; /*is a transparent color key given? 0 = false, 1 = true*/
|
||||
unsigned key_r; /*red/greyscale component of color key*/
|
||||
unsigned key_r; /*red/grayscale component of color key*/
|
||||
unsigned key_g; /*green component of color key*/
|
||||
unsigned key_b; /*blue component of color key*/
|
||||
} LodePNGColorMode;
|
||||
@ -359,6 +371,8 @@ void lodepng_color_mode_init(LodePNGColorMode* info);
|
||||
void lodepng_color_mode_cleanup(LodePNGColorMode* info);
|
||||
/*return value is error code (0 means no error)*/
|
||||
unsigned lodepng_color_mode_copy(LodePNGColorMode* dest, const LodePNGColorMode* source);
|
||||
/* Makes a temporary LodePNGColorMode that does not need cleanup (no palette) */
|
||||
LodePNGColorMode lodepng_color_mode_make(LodePNGColorType colortype, unsigned bitdepth);
|
||||
|
||||
void lodepng_palette_clear(LodePNGColorMode* info);
|
||||
/*add 1 color to the palette*/
|
||||
@ -370,7 +384,7 @@ unsigned lodepng_get_bpp(const LodePNGColorMode* info);
|
||||
/*get the amount of color channels used, based on colortype in the struct.
|
||||
If a palette is used, it counts as 1 channel.*/
|
||||
unsigned lodepng_get_channels(const LodePNGColorMode* info);
|
||||
/*is it a greyscale type? (only colortype 0 or 4)*/
|
||||
/*is it a grayscale type? (only colortype 0 or 4)*/
|
||||
unsigned lodepng_is_greyscale_type(const LodePNGColorMode* info);
|
||||
/*has it got an alpha channel? (only colortype 2 or 6)*/
|
||||
unsigned lodepng_is_alpha_type(const LodePNGColorMode* info);
|
||||
@ -392,8 +406,7 @@ size_t lodepng_get_raw_size(unsigned w, unsigned h, const LodePNGColorMode* colo
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
/*The information of a Time chunk in PNG.*/
|
||||
typedef struct LodePNGTime
|
||||
{
|
||||
typedef struct LodePNGTime {
|
||||
unsigned year; /*2 bytes used (0-65535)*/
|
||||
unsigned month; /*1-12*/
|
||||
unsigned day; /*1-31*/
|
||||
@ -404,28 +417,39 @@ typedef struct LodePNGTime
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
|
||||
/*Information about the PNG image, except pixels, width and height.*/
|
||||
typedef struct LodePNGInfo
|
||||
{
|
||||
typedef struct LodePNGInfo {
|
||||
/*header (IHDR), palette (PLTE) and transparency (tRNS) chunks*/
|
||||
unsigned compression_method;/*compression method of the original file. Always 0.*/
|
||||
unsigned filter_method; /*filter method of the original file*/
|
||||
unsigned interlace_method; /*interlace method of the original file*/
|
||||
unsigned interlace_method; /*interlace method of the original file: 0=none, 1=Adam7*/
|
||||
LodePNGColorMode color; /*color type and bits, palette and transparency of the PNG file*/
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
/*
|
||||
suggested background color chunk (bKGD)
|
||||
This color uses the same color mode as the PNG (except alpha channel), which can be 1-bit to 16-bit.
|
||||
Suggested background color chunk (bKGD)
|
||||
|
||||
For greyscale PNGs, r, g and b will all 3 be set to the same. When encoding
|
||||
the encoder writes the red one. For palette PNGs: When decoding, the RGB value
|
||||
will be stored, not a palette index. But when encoding, specify the index of
|
||||
the palette in background_r, the other two are then ignored.
|
||||
This uses the same color mode and bit depth as the PNG (except no alpha channel),
|
||||
with values truncated to the bit depth in the unsigned integer.
|
||||
|
||||
The decoder does not use this background color to edit the color of pixels.
|
||||
For grayscale and palette PNGs, the value is stored in background_r. The values
|
||||
in background_g and background_b are then unused.
|
||||
|
||||
So when decoding, you may get these in a different color mode than the one you requested
|
||||
for the raw pixels.
|
||||
|
||||
When encoding with auto_convert, you must use the color model defined in info_png.color for
|
||||
these values. The encoder normally ignores info_png.color when auto_convert is on, but will
|
||||
use it to interpret these values (and convert copies of them to its chosen color model).
|
||||
|
||||
When encoding, avoid setting this to an expensive color, such as a non-gray value
|
||||
when the image is gray, or the compression will be worse since it will be forced to
|
||||
write the PNG with a more expensive color mode (when auto_convert is on).
|
||||
|
||||
The decoder does not use this background color to edit the color of pixels. This is a
|
||||
completely optional metadata feature.
|
||||
*/
|
||||
unsigned background_defined; /*is a suggested background color given?*/
|
||||
unsigned background_r; /*red component of suggested background color*/
|
||||
unsigned background_r; /*red/gray/palette component of suggested background color*/
|
||||
unsigned background_g; /*green component of suggested background color*/
|
||||
unsigned background_b; /*blue component of suggested background color*/
|
||||
|
||||
@ -436,6 +460,10 @@ typedef struct LodePNGInfo
|
||||
text_strings, while text_keys are keywords that give a short description what
|
||||
the actual text represents, e.g. Title, Author, Description, or anything else.
|
||||
|
||||
All the string fields below including keys, names and language tags are null terminated.
|
||||
The PNG specification uses null characters for the keys, names and tags, and forbids null
|
||||
characters to appear in the main text which is why we can use null termination everywhere here.
|
||||
|
||||
A keyword is minimum 1 character and maximum 79 characters long. It's
|
||||
discouraged to use a single line length longer than 79 characters for texts.
|
||||
|
||||
@ -468,11 +496,86 @@ typedef struct LodePNGInfo
|
||||
unsigned phys_unit; /*may be 0 (unknown unit) or 1 (metre)*/
|
||||
|
||||
/*
|
||||
unknown chunks
|
||||
There are 3 buffers, one for each position in the PNG where unknown chunks can appear
|
||||
each buffer contains all unknown chunks for that position consecutively
|
||||
The 3 buffers are the unknown chunks between certain critical chunks:
|
||||
0: IHDR-PLTE, 1: PLTE-IDAT, 2: IDAT-IEND
|
||||
Color profile related chunks: gAMA, cHRM, sRGB, iCPP
|
||||
|
||||
LodePNG does not apply any color conversions on pixels in the encoder or decoder and does not interpret these color
|
||||
profile values. It merely passes on the information. If you wish to use color profiles and convert colors, please
|
||||
use these values with a color management library.
|
||||
|
||||
See the PNG, ICC and sRGB specifications for more information about the meaning of these values.
|
||||
*/
|
||||
|
||||
/* gAMA chunk: optional, overridden by sRGB or iCCP if those are present. */
|
||||
unsigned gama_defined; /* Whether a gAMA chunk is present (0 = not present, 1 = present). */
|
||||
unsigned gama_gamma; /* Gamma exponent times 100000 */
|
||||
|
||||
/* cHRM chunk: optional, overridden by sRGB or iCCP if those are present. */
|
||||
unsigned chrm_defined; /* Whether a cHRM chunk is present (0 = not present, 1 = present). */
|
||||
unsigned chrm_white_x; /* White Point x times 100000 */
|
||||
unsigned chrm_white_y; /* White Point y times 100000 */
|
||||
unsigned chrm_red_x; /* Red x times 100000 */
|
||||
unsigned chrm_red_y; /* Red y times 100000 */
|
||||
unsigned chrm_green_x; /* Green x times 100000 */
|
||||
unsigned chrm_green_y; /* Green y times 100000 */
|
||||
unsigned chrm_blue_x; /* Blue x times 100000 */
|
||||
unsigned chrm_blue_y; /* Blue y times 100000 */
|
||||
|
||||
/*
|
||||
sRGB chunk: optional. May not appear at the same time as iCCP.
|
||||
If gAMA is also present gAMA must contain value 45455.
|
||||
If cHRM is also present cHRM must contain respectively 31270,32900,64000,33000,30000,60000,15000,6000.
|
||||
*/
|
||||
unsigned srgb_defined; /* Whether an sRGB chunk is present (0 = not present, 1 = present). */
|
||||
unsigned srgb_intent; /* Rendering intent: 0=perceptual, 1=rel. colorimetric, 2=saturation, 3=abs. colorimetric */
|
||||
|
||||
/*
|
||||
iCCP chunk: optional. May not appear at the same time as sRGB.
|
||||
|
||||
LodePNG does not parse or use the ICC profile (except its color space header field for an edge case), a
|
||||
separate library to handle the ICC data (not included in LodePNG) format is needed to use it for color
|
||||
management and conversions.
|
||||
|
||||
For encoding, if iCCP is present, gAMA and cHRM are recommended to be added as well with values that match the ICC
|
||||
profile as closely as possible, if you wish to do this you should provide the correct values for gAMA and cHRM and
|
||||
enable their '_defined' flags since LodePNG will not automatically compute them from the ICC profile.
|
||||
|
||||
For encoding, the ICC profile is required by the PNG specification to be an "RGB" profile for non-gray
|
||||
PNG color types and a "GRAY" profile for gray PNG color types. If you disable auto_convert, you must ensure
|
||||
the ICC profile type matches your requested color type, else the encoder gives an error. If auto_convert is
|
||||
enabled (the default), and the ICC profile is not a good match for the pixel data, this will result in an encoder
|
||||
error if the pixel data has non-gray pixels for a GRAY profile, or a silent less-optimal compression of the pixel
|
||||
data if the pixels could be encoded as grayscale but the ICC profile is RGB.
|
||||
|
||||
To avoid this do not set an ICC profile in the image unless there is a good reason for it, and when doing so
|
||||
make sure you compute it carefully to avoid the above problems.
|
||||
*/
|
||||
unsigned iccp_defined; /* Whether an iCCP chunk is present (0 = not present, 1 = present). */
|
||||
char* iccp_name; /* Null terminated string with profile name, 1-79 bytes */
|
||||
/*
|
||||
The ICC profile in iccp_profile_size bytes.
|
||||
Don't allocate this buffer yourself. Use the init/cleanup functions
|
||||
correctly and use lodepng_set_icc and lodepng_clear_icc.
|
||||
*/
|
||||
unsigned char* iccp_profile;
|
||||
unsigned iccp_profile_size; /* The size of iccp_profile in bytes */
|
||||
|
||||
/* End of color profile related chunks */
|
||||
|
||||
|
||||
/*
|
||||
unknown chunks: chunks not known by LodePNG, passed on byte for byte.
|
||||
|
||||
There are 3 buffers, one for each position in the PNG where unknown chunks can appear.
|
||||
Each buffer contains all unknown chunks for that position consecutively.
|
||||
The 3 positions are:
|
||||
0: between IHDR and PLTE, 1: between PLTE and IDAT, 2: between IDAT and IEND.
|
||||
|
||||
For encoding, do not store critical chunks or known chunks that are enabled with a "_defined" flag
|
||||
above in here, since the encoder will blindly follow this and could then encode an invalid PNG file
|
||||
(such as one with two IHDR chunks or the disallowed combination of sRGB with iCCP). But do use
|
||||
this if you wish to store an ancillary chunk that is not supported by LodePNG (such as sPLT or hIST),
|
||||
or any non-standard PNG chunk.
|
||||
|
||||
Do not allocate or traverse this data yourself. Use the chunk traversing functions declared
|
||||
later, such as lodepng_chunk_next and lodepng_chunk_append, to read/write this struct.
|
||||
*/
|
||||
@ -488,12 +591,16 @@ void lodepng_info_cleanup(LodePNGInfo* info);
|
||||
unsigned lodepng_info_copy(LodePNGInfo* dest, const LodePNGInfo* source);
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ANCILLARY_CHUNKS
|
||||
void lodepng_clear_text(LodePNGInfo* info); /*use this to clear the texts again after you filled them in*/
|
||||
unsigned lodepng_add_text(LodePNGInfo* info, const char* key, const char* str); /*push back both texts at once*/
|
||||
void lodepng_clear_text(LodePNGInfo* info); /*use this to clear the texts again after you filled them in*/
|
||||
|
||||
void lodepng_clear_itext(LodePNGInfo* info); /*use this to clear the itexts again after you filled them in*/
|
||||
unsigned lodepng_add_itext(LodePNGInfo* info, const char* key, const char* langtag,
|
||||
const char* transkey, const char* str); /*push back the 4 texts of 1 chunk at once*/
|
||||
void lodepng_clear_itext(LodePNGInfo* info); /*use this to clear the itexts again after you filled them in*/
|
||||
|
||||
/*replaces if exists*/
|
||||
unsigned lodepng_set_icc(LodePNGInfo* info, const char* name, const unsigned char* profile, unsigned profile_size);
|
||||
void lodepng_clear_icc(LodePNGInfo* info); /*use this to clear the texts again after you filled them in*/
|
||||
#endif /*LODEPNG_COMPILE_ANCILLARY_CHUNKS*/
|
||||
|
||||
/*
|
||||
@ -516,11 +623,17 @@ unsigned lodepng_convert(unsigned char* out, const unsigned char* in,
|
||||
Settings for the decoder. This contains settings for the PNG and the Zlib
|
||||
decoder, but not the Info settings from the Info structs.
|
||||
*/
|
||||
typedef struct LodePNGDecoderSettings
|
||||
{
|
||||
typedef struct LodePNGDecoderSettings {
|
||||
LodePNGDecompressSettings zlibsettings; /*in here is the setting to ignore Adler32 checksums*/
|
||||
|
||||
/* Check LodePNGDecompressSettings for more ignorable errors such as ignore_adler32 */
|
||||
unsigned ignore_crc; /*ignore CRC checksums*/
|
||||
unsigned ignore_critical; /*ignore unknown critical chunks*/
|
||||
unsigned ignore_end; /*ignore issues at end of file if possible (missing IEND chunk, too large chunk, ...)*/
|
||||
/* TODO: make a system involving warnings with levels and a strict mode instead. Other potentially recoverable
|
||||
errors: srgb rendering intent value, size of content of ancillary chunks, more than 79 characters for some
|
||||
strings, placement/combination rules for ancillary chunks, crc of unknown chunks, allowed characters
|
||||
in string keys, etc... */
|
||||
|
||||
unsigned color_convert; /*whether to convert the PNG to the color type you want. Default: yes*/
|
||||
|
||||
@ -536,10 +649,14 @@ void lodepng_decoder_settings_init(LodePNGDecoderSettings* settings);
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
/*automatically use color type with less bits per pixel if losslessly possible. Default: AUTO*/
|
||||
typedef enum LodePNGFilterStrategy
|
||||
{
|
||||
typedef enum LodePNGFilterStrategy {
|
||||
/*every filter at zero*/
|
||||
LFS_ZERO,
|
||||
LFS_ZERO = 0,
|
||||
/*every filter at 1, 2, 3 or 4 (paeth), unlike LFS_ZERO not a good choice, but for testing*/
|
||||
LFS_ONE = 1,
|
||||
LFS_TWO = 2,
|
||||
LFS_THREE = 3,
|
||||
LFS_FOUR = 4,
|
||||
/*Use filter that gives minimum sum, as described in the official PNG filter heuristic.*/
|
||||
LFS_MINSUM,
|
||||
/*Use the filter type that gives smallest Shannon entropy for this scanline. Depending
|
||||
@ -554,36 +671,36 @@ typedef enum LodePNGFilterStrategy
|
||||
LFS_PREDEFINED
|
||||
} LodePNGFilterStrategy;
|
||||
|
||||
/*Gives characteristics about the colors of the image, which helps decide which color model to use for encoding.
|
||||
/*Gives characteristics about the integer RGBA colors of the image (count, alpha channel usage, bit depth, ...),
|
||||
which helps decide which color model to use for encoding.
|
||||
Used internally by default if "auto_convert" is enabled. Public because it's useful for custom algorithms.*/
|
||||
typedef struct LodePNGColorProfile
|
||||
{
|
||||
unsigned colored; /*not greyscale*/
|
||||
unsigned key; /*if true, image is not opaque. Only if true and alpha is false, color key is possible.*/
|
||||
unsigned short key_r; /*these values are always in 16-bit bitdepth in the profile*/
|
||||
typedef struct LodePNGColorStats {
|
||||
unsigned colored; /*not grayscale*/
|
||||
unsigned key; /*image is not opaque and color key is possible instead of full alpha*/
|
||||
unsigned short key_r; /*key values, always as 16-bit, in 8-bit case the byte is duplicated, e.g. 65535 means 255*/
|
||||
unsigned short key_g;
|
||||
unsigned short key_b;
|
||||
unsigned alpha; /*alpha channel or alpha palette required*/
|
||||
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16.*/
|
||||
unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order*/
|
||||
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for greyscale only. 16 if 16-bit per channel required.*/
|
||||
} LodePNGColorProfile;
|
||||
unsigned alpha; /*image is not opaque and alpha channel or alpha palette required*/
|
||||
unsigned numcolors; /*amount of colors, up to 257. Not valid if bits == 16 or allow_palette is disabled.*/
|
||||
unsigned char palette[1024]; /*Remembers up to the first 256 RGBA colors, in no particular order, only valid when numcolors is valid*/
|
||||
unsigned bits; /*bits per channel (not for palette). 1,2 or 4 for grayscale only. 16 if 16-bit per channel required.*/
|
||||
size_t numpixels;
|
||||
|
||||
void lodepng_color_profile_init(LodePNGColorProfile* profile);
|
||||
/*user settings for computing/using the stats*/
|
||||
unsigned allow_palette; /*default 1. if 0, disallow choosing palette colortype in auto_choose_color, and don't count numcolors*/
|
||||
unsigned allow_greyscale; /*default 1. if 0, choose RGB or RGBA even if the image only has gray colors*/
|
||||
} LodePNGColorStats;
|
||||
|
||||
/*Get a LodePNGColorProfile of the image.*/
|
||||
unsigned lodepng_get_color_profile(LodePNGColorProfile* profile,
|
||||
const unsigned char* image, unsigned w, unsigned h,
|
||||
const LodePNGColorMode* mode_in);
|
||||
/*The function LodePNG uses internally to decide the PNG color with auto_convert.
|
||||
Chooses an optimal color model, e.g. grey if only grey pixels, palette if < 256 colors, ...*/
|
||||
unsigned lodepng_auto_choose_color(LodePNGColorMode* mode_out,
|
||||
const unsigned char* image, unsigned w, unsigned h,
|
||||
const LodePNGColorMode* mode_in);
|
||||
void lodepng_color_stats_init(LodePNGColorStats* stats);
|
||||
|
||||
/*Get a LodePNGColorStats of the image. The stats must already have been inited.
|
||||
Returns error code (e.g. alloc fail) or 0 if ok.*/
|
||||
unsigned lodepng_compute_color_stats(LodePNGColorStats* stats,
|
||||
const unsigned char* image, unsigned w, unsigned h,
|
||||
const LodePNGColorMode* mode_in);
|
||||
|
||||
/*Settings for the encoder.*/
|
||||
typedef struct LodePNGEncoderSettings
|
||||
{
|
||||
typedef struct LodePNGEncoderSettings {
|
||||
LodePNGCompressSettings zlibsettings; /*settings for the zlib encoder, such as window size, ...*/
|
||||
|
||||
unsigned auto_convert; /*automatically choose output PNG color type. Default: true*/
|
||||
@ -619,8 +736,7 @@ void lodepng_encoder_settings_init(LodePNGEncoderSettings* settings);
|
||||
|
||||
#if defined(LODEPNG_COMPILE_DECODER) || defined(LODEPNG_COMPILE_ENCODER)
|
||||
/*The settings, state and information for extended encoding and decoding.*/
|
||||
typedef struct LodePNGState
|
||||
{
|
||||
typedef struct LodePNGState {
|
||||
#ifdef LODEPNG_COMPILE_DECODER
|
||||
LodePNGDecoderSettings decoder; /*the decoding settings*/
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
@ -630,10 +746,6 @@ typedef struct LodePNGState
|
||||
LodePNGColorMode info_raw; /*specifies the format in which you would like to get the raw pixel buffer*/
|
||||
LodePNGInfo info_png; /*info of the PNG image obtained after decoding*/
|
||||
unsigned error;
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
/* For the lodepng::State subclass. */
|
||||
virtual ~LodePNGState(){}
|
||||
#endif
|
||||
} LodePNGState;
|
||||
|
||||
/*init, cleanup and copy functions to use with this struct*/
|
||||
@ -653,7 +765,7 @@ unsigned lodepng_decode(unsigned char** out, unsigned* w, unsigned* h,
|
||||
|
||||
/*
|
||||
Read the PNG header, but not the actual data. This returns only the information
|
||||
that is in the header chunk of the PNG, such as width, height and color type. The
|
||||
that is in the IHDR chunk of the PNG, such as width, height and color type. The
|
||||
information is placed in the info_png field of the LodePNGState.
|
||||
*/
|
||||
unsigned lodepng_inspect(unsigned* w, unsigned* h,
|
||||
@ -661,6 +773,20 @@ unsigned lodepng_inspect(unsigned* w, unsigned* h,
|
||||
const unsigned char* in, size_t insize);
|
||||
#endif /*LODEPNG_COMPILE_DECODER*/
|
||||
|
||||
/*
|
||||
Reads one metadata chunk (other than IHDR) of the PNG file and outputs what it
|
||||
read in the state. Returns error code on failure.
|
||||
Use lodepng_inspect first with a new state, then e.g. lodepng_chunk_find_const
|
||||
to find the desired chunk type, and if non null use lodepng_inspect_chunk (with
|
||||
chunk_pointer - start_of_file as pos).
|
||||
Supports most metadata chunks from the PNG standard (gAMA, bKGD, tEXt, ...).
|
||||
Ignores unsupported, unknown, non-metadata or IHDR chunks (without error).
|
||||
Requirements: &in[pos] must point to start of a chunk, must use regular
|
||||
lodepng_inspect first since format of most other chunks depends on IHDR, and if
|
||||
there is a PLTE chunk, that one must be inspected before tRNS or bKGD.
|
||||
*/
|
||||
unsigned lodepng_inspect_chunk(LodePNGState* state, size_t pos,
|
||||
const unsigned char* in, size_t insize);
|
||||
|
||||
#ifdef LODEPNG_COMPILE_ENCODER
|
||||
/*This function allocates the out buffer with standard malloc and stores the size in *outsize.*/
|
||||
@ -674,11 +800,23 @@ The lodepng_chunk functions are normally not needed, except to traverse the
|
||||
unknown chunks stored in the LodePNGInfo struct, or add new ones to it.
|
||||
It also allows traversing the chunks of an encoded PNG file yourself.
|
||||
|
||||
PNG standard chunk naming conventions:
|
||||
First byte: uppercase = critical, lowercase = ancillary
|
||||
Second byte: uppercase = public, lowercase = private
|
||||
Third byte: must be uppercase
|
||||
Fourth byte: uppercase = unsafe to copy, lowercase = safe to copy
|
||||
The chunk pointer always points to the beginning of the chunk itself, that is
|
||||
the first byte of the 4 length bytes.
|
||||
|
||||
In the PNG file format, chunks have the following format:
|
||||
-4 bytes length: length of the data of the chunk in bytes (chunk itself is 12 bytes longer)
|
||||
-4 bytes chunk type (ASCII a-z,A-Z only, see below)
|
||||
-length bytes of data (may be 0 bytes if length was 0)
|
||||
-4 bytes of CRC, computed on chunk name + data
|
||||
|
||||
The first chunk starts at the 8th byte of the PNG file, the entire rest of the file
|
||||
exists out of concatenated chunks with the above format.
|
||||
|
||||
PNG standard chunk ASCII naming conventions:
|
||||
-First byte: uppercase = critical, lowercase = ancillary
|
||||
-Second byte: uppercase = public, lowercase = private
|
||||
-Third byte: must be uppercase
|
||||
-Fourth byte: uppercase = unsafe to copy, lowercase = safe to copy
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -713,24 +851,38 @@ unsigned lodepng_chunk_check_crc(const unsigned char* chunk);
|
||||
/*generates the correct CRC from the data and puts it in the last 4 bytes of the chunk*/
|
||||
void lodepng_chunk_generate_crc(unsigned char* chunk);
|
||||
|
||||
/*iterate to next chunks. don't use on IEND chunk, as there is no next chunk then*/
|
||||
unsigned char* lodepng_chunk_next(unsigned char* chunk);
|
||||
const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk);
|
||||
/*
|
||||
Iterate to next chunks, allows iterating through all chunks of the PNG file.
|
||||
Input must be at the beginning of a chunk (result of a previous lodepng_chunk_next call,
|
||||
or the 8th byte of a PNG file which always has the first chunk), or alternatively may
|
||||
point to the first byte of the PNG file (which is not a chunk but the magic header, the
|
||||
function will then skip over it and return the first real chunk).
|
||||
Will output pointer to the start of the next chunk, or at or beyond end of the file if there
|
||||
is no more chunk after this or possibly if the chunk is corrupt.
|
||||
Start this process at the 8th byte of the PNG file.
|
||||
In a non-corrupt PNG file, the last chunk should have name "IEND".
|
||||
*/
|
||||
unsigned char* lodepng_chunk_next(unsigned char* chunk, unsigned char* end);
|
||||
const unsigned char* lodepng_chunk_next_const(const unsigned char* chunk, const unsigned char* end);
|
||||
|
||||
/*Finds the first chunk with the given type in the range [chunk, end), or returns NULL if not found.*/
|
||||
unsigned char* lodepng_chunk_find(unsigned char* chunk, unsigned char* end, const char type[5]);
|
||||
const unsigned char* lodepng_chunk_find_const(const unsigned char* chunk, const unsigned char* end, const char type[5]);
|
||||
|
||||
/*
|
||||
Appends chunk to the data in out. The given chunk should already have its chunk header.
|
||||
The out variable and outlength are updated to reflect the new reallocated buffer.
|
||||
The out variable and outsize are updated to reflect the new reallocated buffer.
|
||||
Returns error code (0 if it went ok)
|
||||
*/
|
||||
unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk);
|
||||
unsigned lodepng_chunk_append(unsigned char** out, size_t* outsize, const unsigned char* chunk);
|
||||
|
||||
/*
|
||||
Appends new chunk to out. The chunk to append is given by giving its length, type
|
||||
and data separately. The type is a 4-letter string.
|
||||
The out variable and outlength are updated to reflect the new reallocated buffer.
|
||||
The out variable and outsize are updated to reflect the new reallocated buffer.
|
||||
Returne error code (0 if it went ok)
|
||||
*/
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outsize, unsigned length,
|
||||
const char* type, const unsigned char* data);
|
||||
|
||||
|
||||
@ -814,15 +966,13 @@ unsigned lodepng_save_file(const unsigned char* buffer, size_t buffersize, const
|
||||
|
||||
#ifdef LODEPNG_COMPILE_CPP
|
||||
/* The LodePNG C++ wrapper uses std::vectors instead of manually allocated memory buffers. */
|
||||
namespace lodepng
|
||||
{
|
||||
namespace lodepng {
|
||||
#ifdef LODEPNG_COMPILE_PNG
|
||||
class State : public LodePNGState
|
||||
{
|
||||
class State : public LodePNGState {
|
||||
public:
|
||||
State();
|
||||
State(const State& other);
|
||||
virtual ~State();
|
||||
~State();
|
||||
State& operator=(const State& other);
|
||||
};
|
||||
|
||||
@ -890,15 +1040,21 @@ TODO:
|
||||
[.] test if there are no memory leaks or security exploits - done a lot but needs to be checked often
|
||||
[.] check compatibility with various compilers - done but needs to be redone for every newer version
|
||||
[X] converting color to 16-bit per channel types
|
||||
[ ] read all public PNG chunk types (but never let the color profile and gamma ones touch RGB values)
|
||||
[X] support color profile chunk types (but never let them touch RGB values by default)
|
||||
[ ] support all public PNG chunk types (almost done except sBIT, sPLT and hIST)
|
||||
[ ] make sure encoder generates no chunks with size > (2^31)-1
|
||||
[ ] partial decoding (stream processing)
|
||||
[X] let the "isFullyOpaque" function check color keys and transparent palettes too
|
||||
[X] better name for the variables "codes", "codesD", "codelengthcodes", "clcl" and "lldl"
|
||||
[ ] don't stop decoding on errors like 69, 57, 58 (make warnings)
|
||||
[ ] allow treating some errors like warnings, when image is recoverable (e.g. 69, 57, 58)
|
||||
[ ] make warnings like: oob palette, checksum fail, data after iend, wrong/unknown crit chunk, no null terminator in text, ...
|
||||
[ ] error messages with line numbers (and version)
|
||||
[ ] errors in state instead of as return code?
|
||||
[ ] new errors/warnings like suspiciously big decompressed ztxt or iccp chunk
|
||||
[ ] let the C++ wrapper catch exceptions coming from the standard library and return LodePNG error codes
|
||||
[ ] allow user to provide custom color conversion functions, e.g. for premultiplied alpha, padding bits or not, ...
|
||||
[ ] allow user to give data (void*) to custom allocator
|
||||
[X] provide alternatives for C library functions not present on some platforms (memcpy, ...)
|
||||
*/
|
||||
|
||||
#endif /*LODEPNG_H inclusion guard*/
|
||||
@ -993,8 +1149,10 @@ The following features are supported by the decoder:
|
||||
*) zlib decompression (inflate)
|
||||
*) zlib compression (deflate)
|
||||
*) CRC32 and ADLER32 checksums
|
||||
*) colorimetric color profile conversions: currently experimentally available in lodepng_util.cpp only,
|
||||
plus alternatively ability to pass on chroma/gamma/ICC profile information to other color management system.
|
||||
*) handling of unknown chunks, allowing making a PNG editor that stores custom and unknown chunks.
|
||||
*) the following chunks are supported (generated/interpreted) by both encoder and decoder:
|
||||
*) the following chunks are supported by both encoder and decoder:
|
||||
IHDR: header information
|
||||
PLTE: color palette
|
||||
IDAT: pixel data
|
||||
@ -1006,6 +1164,10 @@ The following features are supported by the decoder:
|
||||
bKGD: suggested background color
|
||||
pHYs: physical dimensions
|
||||
tIME: modification time
|
||||
cHRM: RGB chromaticities
|
||||
gAMA: RGB gamma correction
|
||||
iCCP: ICC color profile
|
||||
sRGB: rendering intent
|
||||
|
||||
1.2. features not supported
|
||||
---------------------------
|
||||
@ -1014,10 +1176,10 @@ The following features are _not_ supported:
|
||||
|
||||
*) some features needed to make a conformant PNG-Editor might be still missing.
|
||||
*) partial loading/stream processing. All data must be available and is processed in one call.
|
||||
*) The following public chunks are not supported but treated as unknown chunks by LodePNG
|
||||
cHRM, gAMA, iCCP, sRGB, sBIT, hIST, sPLT
|
||||
Some of these are not supported on purpose: LodePNG wants to provide the RGB values
|
||||
stored in the pixels, not values modified by system dependent gamma or color models.
|
||||
*) The following public chunks are not (yet) supported but treated as unknown chunks by LodePNG:
|
||||
sBIT
|
||||
hIST
|
||||
sPLT
|
||||
|
||||
|
||||
2. C and C++ version
|
||||
@ -1091,7 +1253,7 @@ LodePNGColorMode info_raw
|
||||
When decoding, here you can specify which color type you want
|
||||
the resulting raw image to be. If this is different from the colortype of the
|
||||
PNG, then the decoder will automatically convert the result. This conversion
|
||||
always works, except if you want it to convert a color PNG to greyscale or to
|
||||
always works, except if you want it to convert a color PNG to grayscale or to
|
||||
a palette with missing colors.
|
||||
|
||||
By default, 32-bit color is used for the result.
|
||||
@ -1187,7 +1349,7 @@ can encode the colors of all pixels without information loss.
|
||||
An important thing to note about LodePNG, is that the color type of the PNG, and
|
||||
the color type of the raw image, are completely independent. By default, when
|
||||
you decode a PNG, you get the result as a raw image in the color type you want,
|
||||
no matter whether the PNG was encoded with a palette, greyscale or RGBA color.
|
||||
no matter whether the PNG was encoded with a palette, grayscale or RGBA color.
|
||||
And if you encode an image, by default LodePNG will automatically choose the PNG
|
||||
color type that gives good compression based on the values of colors and amount
|
||||
of colors in the image. It can be configured to let you control it instead as
|
||||
@ -1195,10 +1357,10 @@ well, though.
|
||||
|
||||
To be able to do this, LodePNG does conversions from one color mode to another.
|
||||
It can convert from almost any color type to any other color type, except the
|
||||
following conversions: RGB to greyscale is not supported, and converting to a
|
||||
following conversions: RGB to grayscale is not supported, and converting to a
|
||||
palette when the palette doesn't have a required color is not supported. This is
|
||||
not supported on purpose: this is information loss which requires a color
|
||||
reduction algorithm that is beyong the scope of a PNG encoder (yes, RGB to grey
|
||||
reduction algorithm that is beyond the scope of a PNG encoder (yes, RGB to gray
|
||||
is easy, but there are multiple ways if you want to give some channels more
|
||||
weight).
|
||||
|
||||
@ -1219,10 +1381,10 @@ decoding to have another color type, a conversion is done by LodePNG.
|
||||
|
||||
The PNG specification gives the following color types:
|
||||
|
||||
0: greyscale, bit depths 1, 2, 4, 8, 16
|
||||
0: grayscale, bit depths 1, 2, 4, 8, 16
|
||||
2: RGB, bit depths 8 and 16
|
||||
3: palette, bit depths 1, 2, 4 and 8
|
||||
4: greyscale with alpha, bit depths 8 and 16
|
||||
4: grayscale with alpha, bit depths 8 and 16
|
||||
6: RGBA, bit depths 8 and 16
|
||||
|
||||
Bit depth is the amount of bits per pixel per color channel. So the total amount
|
||||
@ -1271,15 +1433,22 @@ To avoid some confusion:
|
||||
the raw image correctly before encoding.
|
||||
-both encoder and decoder use the same color converter.
|
||||
|
||||
The function lodepng_convert does the color conversion. It is available in the
|
||||
interface but normally isn't needed since the encoder and decoder already call
|
||||
it.
|
||||
|
||||
Non supported color conversions:
|
||||
-color to greyscale: no error is thrown, but the result will look ugly because
|
||||
only the red channel is taken
|
||||
-anything to palette when that palette does not have that color in it: in this
|
||||
case an error is thrown
|
||||
-color to grayscale when non-gray pixels are present: no error is thrown, but
|
||||
the result will look ugly because only the red channel is taken (it assumes all
|
||||
three channels are the same in this case so ignores green and blue). The reason
|
||||
no error is given is to allow converting from three-channel grayscale images to
|
||||
one-channel even if there are numerical imprecisions.
|
||||
-anything to palette when the palette does not have an exact match for a from-color
|
||||
in it: in this case an error is thrown
|
||||
|
||||
Supported color conversions:
|
||||
-anything to 8-bit RGB, 8-bit RGBA, 16-bit RGB, 16-bit RGBA
|
||||
-any grey or grey+alpha, to grey or grey+alpha
|
||||
-any gray or gray+alpha, to gray or gray+alpha
|
||||
-anything to a palette, as long as the palette has the requested colors in it
|
||||
-removing alpha channel
|
||||
-higher to smaller bitdepth, and vice versa
|
||||
@ -1292,10 +1461,6 @@ false.
|
||||
as the PNG has, by setting the color_convert setting to false. Settings in
|
||||
info_raw are then ignored.
|
||||
|
||||
The function lodepng_convert does the color conversion. It is available in the
|
||||
interface but normally isn't needed since the encoder and decoder already call
|
||||
it.
|
||||
|
||||
6.3. padding bits
|
||||
-----------------
|
||||
|
||||
@ -1304,7 +1469,7 @@ have a bit amount that isn't a multiple of 8, then padding bits are used so that
|
||||
scanline starts at a fresh byte. But that is NOT true for the LodePNG raw input and output.
|
||||
The raw input image you give to the encoder, and the raw output image you get from the decoder
|
||||
will NOT have these padding bits, e.g. in the case of a 1-bit image with a width
|
||||
of 7 pixels, the first pixel of the second scanline will the the 8th bit of the first byte,
|
||||
of 7 pixels, the first pixel of the second scanline will the 8th bit of the first byte,
|
||||
not the first bit of a new byte.
|
||||
|
||||
6.4. A note about 16-bits per channel and endianness
|
||||
@ -1405,12 +1570,12 @@ Iterate to the next chunk. This works if you have a buffer with consecutive chun
|
||||
functions do no boundary checking of the allocated data whatsoever, so make sure there is enough
|
||||
data available in the buffer to be able to go to the next chunk.
|
||||
|
||||
unsigned lodepng_chunk_append(unsigned char** out, size_t* outlength, const unsigned char* chunk):
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outlength, unsigned length,
|
||||
unsigned lodepng_chunk_append(unsigned char** out, size_t* outsize, const unsigned char* chunk):
|
||||
unsigned lodepng_chunk_create(unsigned char** out, size_t* outsize, unsigned length,
|
||||
const char* type, const unsigned char* data):
|
||||
|
||||
These functions are used to create new chunks that are appended to the data in *out that has
|
||||
length *outlength. The append function appends an existing chunk to the new data. The create
|
||||
length *outsize. The append function appends an existing chunk to the new data. The create
|
||||
function creates a new chunk with the given parameters and appends it. Type is the 4-letter
|
||||
name of the chunk.
|
||||
|
||||
@ -1421,7 +1586,7 @@ The LodePNGInfo struct contains fields with the unknown chunk in it. It has 3
|
||||
buffers (each with size) to contain 3 types of unknown chunks:
|
||||
the ones that come before the PLTE chunk, the ones that come between the PLTE
|
||||
and the IDAT chunks, and the ones that come after the IDAT chunks.
|
||||
It's necessary to make the distionction between these 3 cases because the PNG
|
||||
It's necessary to make the distinction between these 3 cases because the PNG
|
||||
standard forces to keep the ordering of unknown chunks compared to the critical
|
||||
chunks, but does not force any other ordering rules.
|
||||
|
||||
@ -1504,7 +1669,7 @@ C and C++.
|
||||
*) Other Compilers
|
||||
|
||||
If you encounter problems on any compilers, feel free to let me know and I may
|
||||
try to fix it if the compiler is modern and standards complient.
|
||||
try to fix it if the compiler is modern and standards compliant.
|
||||
|
||||
|
||||
10. examples
|
||||
@ -1519,8 +1684,7 @@ examples can be found on the LodePNG website.
|
||||
#include "lodepng.h"
|
||||
#include <iostream>
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
const char* filename = argc > 1 ? argv[1] : "test.png";
|
||||
|
||||
//load and decode
|
||||
@ -1539,8 +1703,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "lodepng.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int main(int argc, char *argv[]) {
|
||||
unsigned error;
|
||||
unsigned char* image;
|
||||
size_t width, height;
|
||||
@ -1566,6 +1729,8 @@ For decoding:
|
||||
state.decoder.zlibsettings.ignore_adler32: ignore ADLER32 checksums
|
||||
state.decoder.zlibsettings.custom_...: use custom inflate function
|
||||
state.decoder.ignore_crc: ignore CRC checksums
|
||||
state.decoder.ignore_critical: ignore unknown critical chunks
|
||||
state.decoder.ignore_end: ignore missing IEND chunk. May fail if this corruption causes other errors
|
||||
state.decoder.color_convert: convert internal PNG color to chosen one
|
||||
state.decoder.read_text_chunks: whether to read in text metadata chunks
|
||||
state.decoder.remember_unknown_chunks: whether to read in unknown chunks
|
||||
@ -1607,12 +1772,33 @@ yyyymmdd.
|
||||
Some changes aren't backwards compatible. Those are indicated with a (!)
|
||||
symbol.
|
||||
|
||||
Not all changes are listed here, the commit history in github lists more:
|
||||
https://github.com/lvandeve/lodepng
|
||||
|
||||
*) 06 mar 2020: simplified some of the dynamic memory allocations.
|
||||
*) 12 jan 2020: (!) added 'end' argument to lodepng_chunk_next to allow correct
|
||||
overflow checks.
|
||||
*) 14 aug 2019: around 25% faster decoding thanks to huffman lookup tables.
|
||||
*) 15 jun 2019: (!) auto_choose_color API changed (for bugfix: don't use palette
|
||||
if gray ICC profile) and non-ICC LodePNGColorProfile renamed to
|
||||
LodePNGColorStats.
|
||||
*) 30 dec 2018: code style changes only: removed newlines before opening braces.
|
||||
*) 10 sep 2018: added way to inspect metadata chunks without full decoding.
|
||||
*) 19 aug 2018: (!) fixed color mode bKGD is encoded with and made it use
|
||||
palette index in case of palette.
|
||||
*) 10 aug 2018: (!) added support for gAMA, cHRM, sRGB and iCCP chunks. This
|
||||
change is backwards compatible unless you relied on unknown_chunks for those.
|
||||
*) 11 jun 2018: less restrictive check for pixel size integer overflow
|
||||
*) 14 jan 2018: allow optionally ignoring a few more recoverable errors
|
||||
*) 17 sep 2017: fix memory leak for some encoder input error cases
|
||||
*) 27 nov 2016: grey+alpha auto color model detection bugfix
|
||||
*) 18 apr 2016: Changed qsort to custom stable sort (for platforms w/o qsort).
|
||||
*) 09 apr 2016: Fixed colorkey usage detection, and better file loading (within
|
||||
the limits of pure C90).
|
||||
*) 08 dec 2015: Made load_file function return error if file can't be opened.
|
||||
*) 24 okt 2015: Bugfix with decoding to palette output.
|
||||
*) 18 apr 2015: Boundary PM instead of just package-merge for faster encoding.
|
||||
*) 24 aug 2014: Moved to github
|
||||
*) 23 aug 2014: Reduced needless memory usage of decoder.
|
||||
*) 28 jun 2014: Removed fix_png setting, always support palette OOB for
|
||||
simplicity. Made ColorProfile public.
|
||||
@ -1620,25 +1806,25 @@ symbol.
|
||||
*) 22 dec 2013: Power of two windowsize required for optimization.
|
||||
*) 15 apr 2013: Fixed bug with LAC_ALPHA and color key.
|
||||
*) 25 mar 2013: Added an optional feature to ignore some PNG errors (fix_png).
|
||||
*) 11 mar 2013 (!): Bugfix with custom free. Changed from "my" to "lodepng_"
|
||||
*) 11 mar 2013: (!) Bugfix with custom free. Changed from "my" to "lodepng_"
|
||||
prefix for the custom allocators and made it possible with a new #define to
|
||||
use custom ones in your project without needing to change lodepng's code.
|
||||
*) 28 jan 2013: Bugfix with color key.
|
||||
*) 27 okt 2012: Tweaks in text chunk keyword length error handling.
|
||||
*) 8 okt 2012 (!): Added new filter strategy (entropy) and new auto color mode.
|
||||
*) 8 okt 2012: (!) Added new filter strategy (entropy) and new auto color mode.
|
||||
(no palette). Better deflate tree encoding. New compression tweak settings.
|
||||
Faster color conversions while decoding. Some internal cleanups.
|
||||
*) 23 sep 2012: Reduced warnings in Visual Studio a little bit.
|
||||
*) 1 sep 2012 (!): Removed #define's for giving custom (de)compression functions
|
||||
*) 1 sep 2012: (!) Removed #define's for giving custom (de)compression functions
|
||||
and made it work with function pointers instead.
|
||||
*) 23 jun 2012: Added more filter strategies. Made it easier to use custom alloc
|
||||
and free functions and toggle #defines from compiler flags. Small fixes.
|
||||
*) 6 may 2012 (!): Made plugging in custom zlib/deflate functions more flexible.
|
||||
*) 22 apr 2012 (!): Made interface more consistent, renaming a lot. Removed
|
||||
*) 6 may 2012: (!) Made plugging in custom zlib/deflate functions more flexible.
|
||||
*) 22 apr 2012: (!) Made interface more consistent, renaming a lot. Removed
|
||||
redundant C++ codec classes. Reduced amount of structs. Everything changed,
|
||||
but it is cleaner now imho and functionality remains the same. Also fixed
|
||||
several bugs and shrunk the implementation code. Made new samples.
|
||||
*) 6 nov 2011 (!): By default, the encoder now automatically chooses the best
|
||||
*) 6 nov 2011: (!) By default, the encoder now automatically chooses the best
|
||||
PNG color model and bit depth, based on the amount and type of colors of the
|
||||
raw image. For this, autoLeaveOutAlphaChannel replaced by auto_choose_color.
|
||||
*) 9 okt 2011: simpler hash chain implementation for the encoder.
|
||||
@ -1647,7 +1833,7 @@ symbol.
|
||||
A bug with the PNG filtertype heuristic was fixed, so that it chooses much
|
||||
better ones (it's quite significant). A setting to do an experimental, slow,
|
||||
brute force search for PNG filter types is added.
|
||||
*) 17 aug 2011 (!): changed some C zlib related function names.
|
||||
*) 17 aug 2011: (!) changed some C zlib related function names.
|
||||
*) 16 aug 2011: made the code less wide (max 120 characters per line).
|
||||
*) 17 apr 2011: code cleanup. Bugfixes. Convert low to 16-bit per sample colors.
|
||||
*) 21 feb 2011: fixed compiling for C90. Fixed compiling with sections disabled.
|
||||
@ -1755,5 +1941,5 @@ Domain: gmail dot com.
|
||||
Account: lode dot vandevenne.
|
||||
|
||||
|
||||
Copyright (c) 2005-2016 Lode Vandevenne
|
||||
Copyright (c) 2005-2020 Lode Vandevenne
|
||||
*/
|
||||
|
4
3rdparty/bimg/3rdparty/nvtt/nvcore/nvcore.h
vendored
4
3rdparty/bimg/3rdparty/nvtt/nvcore/nvcore.h
vendored
@ -1,4 +1,4 @@
|
||||
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
|
||||
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
|
||||
|
||||
#ifndef NV_CORE_H
|
||||
#define NV_CORE_H
|
||||
@ -357,7 +357,7 @@ NV_COMPILER_CHECK(sizeof(uint32) == 4);
|
||||
# include "defsgnuclinux.h"
|
||||
# elif NV_OS_DARWIN || NV_OS_FREEBSD || NV_OS_OPENBSD
|
||||
# include "defsgnucdarwin.h"
|
||||
# elif NV_OS_MINGW
|
||||
# elif NV_OS_MINGW || (NV_CC_CLANG && NV_OS_WIN32)
|
||||
# include "defsgnucwin32.h"
|
||||
# elif NV_OS_CYGWIN
|
||||
# error "GCC: Cygwin not supported"
|
||||
|
2
3rdparty/bimg/3rdparty/nvtt/nvcore/posh.h
vendored
2
3rdparty/bimg/3rdparty/nvtt/nvcore/posh.h
vendored
@ -258,9 +258,11 @@ LLVM:
|
||||
#endif
|
||||
|
||||
#if defined _MSC_VER
|
||||
#if !defined __clang__
|
||||
# define POSH_COMPILER_STRING "Microsoft Visual C++"
|
||||
# define POSH_COMPILER_MSVC 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined __SUNPRO_C
|
||||
# define POSH_COMPILER_STRING "Sun Pro"
|
||||
|
2
3rdparty/bimg/3rdparty/nvtt/nvtt.cpp
vendored
2
3rdparty/bimg/3rdparty/nvtt/nvtt.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
|
1233
3rdparty/bimg/3rdparty/stb/stb_image.h
vendored
1233
3rdparty/bimg/3rdparty/stb/stb_image.h
vendored
File diff suppressed because it is too large
Load Diff
100
3rdparty/bimg/3rdparty/stb/stb_image_resize.h
vendored
100
3rdparty/bimg/3rdparty/stb/stb_image_resize.h
vendored
@ -1,4 +1,4 @@
|
||||
/* stb_image_resize - v0.95 - public domain image resizing
|
||||
/* stb_image_resize - v0.96 - public domain image resizing
|
||||
by Jorge L Rodriguez (@VinoBS) - 2014
|
||||
http://github.com/nothings/stb
|
||||
|
||||
@ -20,8 +20,8 @@
|
||||
output_pixels, out_w, out_h, 0,
|
||||
num_channels , alpha_chan , 0)
|
||||
stbir_resize_uint8_srgb_edgemode(
|
||||
input_pixels , in_w , in_h , 0,
|
||||
output_pixels, out_w, out_h, 0,
|
||||
input_pixels , in_w , in_h , 0,
|
||||
output_pixels, out_w, out_h, 0,
|
||||
num_channels , alpha_chan , 0, STBIR_EDGE_CLAMP)
|
||||
// WRAP/REFLECT/ZERO
|
||||
|
||||
@ -159,6 +159,8 @@
|
||||
Nathan Reed: warning fixes
|
||||
|
||||
REVISIONS
|
||||
0.97 (2020-02-02) fixed warning
|
||||
0.96 (2019-03-04) fixed warnings
|
||||
0.95 (2017-07-23) fixed warnings
|
||||
0.94 (2017-03-18) fixed warnings
|
||||
0.93 (2017-03-03) fixed bug with certain combinations of heights
|
||||
@ -193,6 +195,7 @@ typedef uint16_t stbir_uint16;
|
||||
typedef uint32_t stbir_uint32;
|
||||
#endif
|
||||
|
||||
#ifndef STBIRDEF
|
||||
#ifdef STB_IMAGE_RESIZE_STATIC
|
||||
#define STBIRDEF static
|
||||
#else
|
||||
@ -202,7 +205,7 @@ typedef uint32_t stbir_uint32;
|
||||
#define STBIRDEF extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@ -231,7 +234,7 @@ STBIRDEF int stbir_resize_float( const float *input_pixels , int input_w , i
|
||||
int num_channels);
|
||||
|
||||
|
||||
// The following functions interpret image data as gamma-corrected sRGB.
|
||||
// The following functions interpret image data as gamma-corrected sRGB.
|
||||
// Specify STBIR_ALPHA_CHANNEL_NONE if you have no alpha channel,
|
||||
// or otherwise provide the index of the alpha channel. Flags value
|
||||
// of 0 will probably do the right thing if you're not sure what
|
||||
@ -304,19 +307,19 @@ typedef enum
|
||||
STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
|
||||
unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
void *alloc_context);
|
||||
|
||||
STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
|
||||
stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
void *alloc_context);
|
||||
|
||||
STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
|
||||
float *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
void *alloc_context);
|
||||
|
||||
|
||||
@ -348,7 +351,7 @@ STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int
|
||||
void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
stbir_datatype datatype,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_filter filter_horizontal, stbir_filter filter_vertical,
|
||||
stbir_colorspace space, void *alloc_context);
|
||||
|
||||
@ -356,7 +359,7 @@ STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int
|
||||
void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
stbir_datatype datatype,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_filter filter_horizontal, stbir_filter filter_vertical,
|
||||
stbir_colorspace space, void *alloc_context,
|
||||
float x_scale, float y_scale,
|
||||
@ -366,7 +369,7 @@ STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int
|
||||
void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
stbir_datatype datatype,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_filter filter_horizontal, stbir_filter filter_vertical,
|
||||
stbir_colorspace space, void *alloc_context,
|
||||
float s0, float t0, float s1, float t1);
|
||||
@ -668,14 +671,14 @@ static const stbir_uint32 fp32_to_srgb8_tab4[104] = {
|
||||
0x44c20798, 0x488e071e, 0x4c1c06b6, 0x4f76065d, 0x52a50610, 0x55ac05cc, 0x5892058f, 0x5b590559,
|
||||
0x5e0c0a23, 0x631c0980, 0x67db08f6, 0x6c55087f, 0x70940818, 0x74a007bd, 0x787d076c, 0x7c330723,
|
||||
};
|
||||
|
||||
|
||||
static stbir_uint8 stbir__linear_to_srgb_uchar(float in)
|
||||
{
|
||||
static const stbir__FP32 almostone = { 0x3f7fffff }; // 1-eps
|
||||
static const stbir__FP32 minval = { (127-13) << 23 };
|
||||
stbir_uint32 tab,bias,scale,t;
|
||||
stbir__FP32 f;
|
||||
|
||||
|
||||
// Clamp to [2^(-13), 1-eps]; these two values map to 0 and 1, respectively.
|
||||
// The tests are carefully written so that NaNs map to 0, same as in the reference
|
||||
// implementation.
|
||||
@ -683,13 +686,13 @@ static stbir_uint8 stbir__linear_to_srgb_uchar(float in)
|
||||
in = minval.f;
|
||||
if (in > almostone.f)
|
||||
in = almostone.f;
|
||||
|
||||
|
||||
// Do the table lookup and unpack bias, scale
|
||||
f.f = in;
|
||||
tab = fp32_to_srgb8_tab4[(f.u - minval.u) >> 20];
|
||||
bias = (tab >> 16) << 9;
|
||||
scale = tab & 0xffff;
|
||||
|
||||
|
||||
// Grab next-highest mantissa bits and perform linear interpolation
|
||||
t = (f.u >> 12) & 0xff;
|
||||
return (unsigned char) ((bias + scale*t) >> 16);
|
||||
@ -1236,7 +1239,7 @@ static float* stbir__get_decode_buffer(stbir__info* stbir_info)
|
||||
return &stbir_info->decode_buffer[stbir_info->horizontal_filter_pixel_margin * stbir_info->channels];
|
||||
}
|
||||
|
||||
#define STBIR__DECODE(type, colorspace) ((type) * (STBIR_MAX_COLORSPACES) + (colorspace))
|
||||
#define STBIR__DECODE(type, colorspace) ((int)(type) * (STBIR_MAX_COLORSPACES) + (int)(colorspace))
|
||||
|
||||
static void stbir__decode_scanline(stbir__info* stbir_info, int n)
|
||||
{
|
||||
@ -2324,8 +2327,9 @@ static int stbir__resize_allocated(stbir__info *info,
|
||||
if (alpha_channel < 0)
|
||||
flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED;
|
||||
|
||||
if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED))
|
||||
if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED)) {
|
||||
STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels);
|
||||
}
|
||||
|
||||
if (alpha_channel >= info->channels)
|
||||
return 0;
|
||||
@ -2442,7 +2446,7 @@ static int stbir__resize_arbitrary(
|
||||
return 0;
|
||||
|
||||
result = stbir__resize_allocated(&info, input_data, input_stride_in_bytes,
|
||||
output_data, output_stride_in_bytes,
|
||||
output_data, output_stride_in_bytes,
|
||||
alpha_channel, flags, type,
|
||||
edge_horizontal, edge_vertical,
|
||||
colorspace, extra_memory, memory_required);
|
||||
@ -2496,7 +2500,7 @@ STBIRDEF int stbir_resize_uint8_srgb_edgemode(const unsigned char *input_pixels
|
||||
STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
|
||||
unsigned char *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
void *alloc_context)
|
||||
{
|
||||
return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
|
||||
@ -2508,7 +2512,7 @@ STBIRDEF int stbir_resize_uint8_generic( const unsigned char *input_pixels , int
|
||||
STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
|
||||
stbir_uint16 *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
void *alloc_context)
|
||||
{
|
||||
return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
|
||||
@ -2521,7 +2525,7 @@ STBIRDEF int stbir_resize_uint16_generic(const stbir_uint16 *input_pixels , int
|
||||
STBIRDEF int stbir_resize_float_generic( const float *input_pixels , int input_w , int input_h , int input_stride_in_bytes,
|
||||
float *output_pixels , int output_w, int output_h, int output_stride_in_bytes,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
stbir_edge edge_wrap_mode, stbir_filter filter, stbir_colorspace space,
|
||||
void *alloc_context)
|
||||
{
|
||||
return stbir__resize_arbitrary(alloc_context, input_pixels, input_w, input_h, input_stride_in_bytes,
|
||||
@ -2535,7 +2539,7 @@ STBIRDEF int stbir_resize( const void *input_pixels , int input_w , int
|
||||
void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
stbir_datatype datatype,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_filter filter_horizontal, stbir_filter filter_vertical,
|
||||
stbir_colorspace space, void *alloc_context)
|
||||
{
|
||||
@ -2550,7 +2554,7 @@ STBIRDEF int stbir_resize_subpixel(const void *input_pixels , int input_w , int
|
||||
void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
stbir_datatype datatype,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_filter filter_horizontal, stbir_filter filter_vertical,
|
||||
stbir_colorspace space, void *alloc_context,
|
||||
float x_scale, float y_scale,
|
||||
@ -2571,7 +2575,7 @@ STBIRDEF int stbir_resize_region( const void *input_pixels , int input_w , int
|
||||
void *output_pixels, int output_w, int output_h, int output_stride_in_bytes,
|
||||
stbir_datatype datatype,
|
||||
int num_channels, int alpha_channel, int flags,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_edge edge_mode_horizontal, stbir_edge edge_mode_vertical,
|
||||
stbir_filter filter_horizontal, stbir_filter filter_vertical,
|
||||
stbir_colorspace space, void *alloc_context,
|
||||
float s0, float t0, float s1, float t1)
|
||||
@ -2590,38 +2594,38 @@ This software is available under 2 licenses -- choose whichever you prefer.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE A - MIT License
|
||||
Copyright (c) 2017 Sean Barrett
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
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 OR COPYRIGHT HOLDERS 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
|
||||
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 OR COPYRIGHT HOLDERS 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.
|
||||
------------------------------------------------------------------------------
|
||||
ALTERNATIVE B - Public Domain (www.unlicense.org)
|
||||
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,
|
||||
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
|
||||
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
|
||||
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.
|
||||
------------------------------------------------------------------------------
|
||||
*/
|
||||
|
872
3rdparty/bimg/3rdparty/stb/stb_image_write.h
vendored
872
3rdparty/bimg/3rdparty/stb/stb_image_write.h
vendored
File diff suppressed because it is too large
Load Diff
492
3rdparty/bimg/3rdparty/tinyexr/README.md
vendored
492
3rdparty/bimg/3rdparty/tinyexr/README.md
vendored
@ -1,5 +1,7 @@
|
||||
# Tiny OpenEXR image library.
|
||||
|
||||
[](https://lgtm.com/projects/g/syoyo/tinyexr/alerts/)
|
||||
|
||||

|
||||
|
||||
[](https://ci.appveyor.com/project/syoyo/tinyexr/branch/master)
|
||||
@ -8,38 +10,106 @@
|
||||
|
||||
[](https://scan.coverity.com/projects/5827)
|
||||
|
||||
`tinyexr` is a small, single header-only library to load and save OpenEXR(.exr) images.
|
||||
`tinyexr` is written in portable C++(no library dependency except for STL), thus `tinyexr` is good to embed into your application.
|
||||
`tinyexr` is a small, single header-only library to load and save OpenEXR (.exr) images.
|
||||
`tinyexr` is written in portable C++ (no library dependency except for STL), thus `tinyexr` is good to embed into your application.
|
||||
To use `tinyexr`, simply copy `tinyexr.h` into your project.
|
||||
|
||||
`tinyexr` currently supports:
|
||||
# Features
|
||||
|
||||
* OpenEXR version 1.x.
|
||||
* Normal image
|
||||
* Scanline format.
|
||||
* Uncompress("compress" = 0), ZIPS("compress" = 2), ZIP compression("compress" = 3) and PIZ compression("compress" = 4).
|
||||
* Half/Uint/Float pixel type.
|
||||
* Custom attributes(up to 128)
|
||||
* Deep image
|
||||
* Scanline format.
|
||||
* ZIPS compression("compress" = 2).
|
||||
* Half, float pixel type.
|
||||
* Litte endian machine.
|
||||
* Limited support for big endian machine.
|
||||
* read/write normal image.
|
||||
Current status of `tinyexr` is:
|
||||
|
||||
- OpenEXR v1 image
|
||||
- [x] Scanline format
|
||||
- [x] Tiled format
|
||||
- [x] Tile format with no LoD (load).
|
||||
- [x] Tile format with LoD (load).
|
||||
- [x] Tile format with no LoD (save).
|
||||
- [x] Tile format with LoD (save).
|
||||
- [x] Custom attributes
|
||||
- OpenEXR v2 image
|
||||
- [ ] Multipart format
|
||||
- [x] Load multi-part image
|
||||
- [x] Save multi-part image
|
||||
- [ ] Load multi-part deep image
|
||||
- [ ] Save multi-part deep image
|
||||
- OpenEXR v2 deep image
|
||||
- [x] Loading scanline + ZIPS + HALF or FLOAT pixel type.
|
||||
- Compression
|
||||
- [x] NONE
|
||||
- [x] RLE
|
||||
- [x] ZIP
|
||||
- [x] ZIPS
|
||||
- [x] PIZ
|
||||
- [x] ZFP (tinyexr extension)
|
||||
- [ ] B44?
|
||||
- [ ] B44A?
|
||||
- [ ] PIX24?
|
||||
- Line order.
|
||||
- [x] Increasing, decreasing (load)
|
||||
- [ ] Random?
|
||||
- [x] Increasing (save)
|
||||
- [ ] decreasing (save)
|
||||
- Pixel format (UINT, FLOAT).
|
||||
- [x] UINT, FLOAT (load)
|
||||
- [x] UINT, FLOAT (deep load)
|
||||
- [x] UINT, FLOAT (save)
|
||||
- [ ] UINT, FLOAT (deep save)
|
||||
- Support for big endian machine.
|
||||
- [x] Loading scanline image
|
||||
- [x] Saving scanline image
|
||||
- [x] Loading multi-part channel EXR (not tested)
|
||||
- [x] Saving multi-part channel EXR (not tested)
|
||||
- [ ] Loading deep image
|
||||
- [ ] Saving deep image
|
||||
- Optimization
|
||||
- [x] C++11 thread loading
|
||||
- [ ] C++11 thread saving
|
||||
- [ ] ISPC?
|
||||
- [x] OpenMP multi-threading in EXR loading.
|
||||
- [x] OpenMP multi-threading in EXR saving.
|
||||
- [ ] OpenMP multi-threading in deep image loading.
|
||||
- [ ] OpenMP multi-threading in deep image saving.
|
||||
* C interface.
|
||||
* You can easily write language bindings(e.g. golang)
|
||||
* EXR saving
|
||||
* with ZIP compression.
|
||||
* JavaScript library
|
||||
* Through emscripten.
|
||||
* You can easily write language bindings (e.g. golang)
|
||||
|
||||
# Use case
|
||||
# Supported platform
|
||||
|
||||
* [x] x86-64
|
||||
* [x] Windows 7 or later
|
||||
* [x] Linux(posix) system
|
||||
* [x] macOS
|
||||
* [x] AARCH64
|
||||
* [x] aarch64 linux(e.g. Raspberry Pi)
|
||||
* [x] Android
|
||||
* [x] iOS
|
||||
* [ ] macOS(Should work)
|
||||
* [ ] RISC-V(Should work)
|
||||
* [x] Big endian machine(not maintained, but should work)
|
||||
* SPARC, PowerPC, ...
|
||||
* [x] WebAssembly(JavaScript)
|
||||
* Loader only(See )
|
||||
* [x] Python binding
|
||||
* Loader only https://pypi.org/project/pytinyexr/
|
||||
|
||||
# Requirements
|
||||
|
||||
* C++ compiler(C++11 recommended. C++03 may work)
|
||||
|
||||
# Use case
|
||||
|
||||
## New TinyEXR (v0.9.5+)
|
||||
|
||||
* Godot. Multi-platform 2D and 3D game engine https://godotengine.org/
|
||||
* Filament. PBR engine(used in a converter tool). https://github.com/google/filament
|
||||
* PyEXR. Loading OpenEXR (.exr) images using Python. https://github.com/ialhashim/PyEXR
|
||||
* The-Forge. The Forge Cross-Platform Rendering Framework PC, Linux, Ray Tracing, macOS / iOS, Android, XBOX, PS4 https://github.com/ConfettiFX/The-Forge
|
||||
* Your project here!
|
||||
|
||||
## Older TinyEXR (v0.9.0)
|
||||
|
||||
* mallie https://github.com/lighttransport/mallie
|
||||
* PBRT v3 https://github.com/mmp/pbrt-v3
|
||||
* Cinder 0.9.0 https://libcinder.org/notes/v0.9.0
|
||||
* Piccante(develop branch) http://piccantelib.net/
|
||||
* Piccante (develop branch) http://piccantelib.net/
|
||||
* Your project here!
|
||||
|
||||
## Examples
|
||||
@ -47,79 +117,240 @@ To use `tinyexr`, simply copy `tinyexr.h` into your project.
|
||||
* [examples/deepview/](examples/deepview) Deep image view
|
||||
* [examples/rgbe2exr/](examples/rgbe2exr) .hdr to EXR converter
|
||||
* [examples/exr2rgbe/](examples/exr2rgbe) EXR to .hdr converter
|
||||
* [examples/ldr2exr/](examples/exr2rgbe) LDR to EXR converter
|
||||
* [examples/exr2ldr/](examples/exr2ldr) EXR to LDR converter
|
||||
* [examples/exr2fptiff/](examples/exr2fptiff) EXR to 32bit floating point TIFF converter
|
||||
* for 32bit floating point TIFF to EXR convert, see https://github.com/syoyo/tinydngloader/tree/master/examples/fptiff2exr
|
||||
* [examples/cube2longlat/](examples/cube2longlat) Cubemap to longlat (equirectangler) converter
|
||||
|
||||
## Experimental
|
||||
|
||||
* [experimental/js/](experimental/js) JavaScript port using Emscripten
|
||||
|
||||
## Usage
|
||||
|
||||
NOTE: **API is still subject to change**. See the source code for details.
|
||||
|
||||
Include `tinyexr.h` with `TINYEXR_IMPLEMENTATION` flag(do this only for **one** .cc file).
|
||||
Include `tinyexr.h` with `TINYEXR_IMPLEMENTATION` flag (do this only for **one** .cc file).
|
||||
|
||||
```
|
||||
```cpp
|
||||
//Please include your own zlib-compatible API header before
|
||||
//including `tinyexr.h` when you disable `TINYEXR_USE_MINIZ`
|
||||
//#define TINYEXR_USE_MINIZ 0
|
||||
//#include "zlib.h"
|
||||
#define TINYEXR_IMPLEMENTATION
|
||||
#include "tinyexr.h"
|
||||
```
|
||||
|
||||
Quickly reading RGB(A) EXR file.
|
||||
### Compile flags
|
||||
|
||||
```
|
||||
* `TINYEXR_USE_MINIZ` Use embedded miniz (default = 1). Please include `zlib.h` header (before `tinyexr.h`) if you disable miniz support.
|
||||
* `TINYEXR_USE_PIZ` Enable PIZ compression support (default = 1)
|
||||
* `TINYEXR_USE_ZFP` Enable ZFP compression supoort (TinyEXR extension, default = 0)
|
||||
* `TINYEXR_USE_THREAD` Enable threaded loading using C++11 thread (Requires C++11 compiler, default = 0)
|
||||
* `TINYEXR_USE_OPENMP` Enable OpenMP threading support (default = 1 if `_OPENMP` is defined)
|
||||
* Use `TINYEXR_USE_OPENMP=0` to force disable OpenMP code path even if OpenMP is available/enabled in the compiler.
|
||||
|
||||
### Quickly reading RGB(A) EXR file.
|
||||
|
||||
```cpp
|
||||
const char* input = "asakusa.exr";
|
||||
float* out; // width * height * RGBA
|
||||
int width;
|
||||
int height;
|
||||
const char* err;
|
||||
const char* err = NULL; // or nullptr in C++11
|
||||
|
||||
int ret = LoadEXR(&out, &width, &height, input, &err);
|
||||
```
|
||||
|
||||
Loading EXR from a file.
|
||||
if (ret != TINYEXR_SUCCESS) {
|
||||
if (err) {
|
||||
fprintf(stderr, "ERR : %s\n", err);
|
||||
FreeEXRErrorMessage(err); // release memory of error message.
|
||||
}
|
||||
} else {
|
||||
...
|
||||
free(out); // release memory of image data
|
||||
}
|
||||
|
||||
```
|
||||
const char* input = "asakusa.exr";
|
||||
const char* err;
|
||||
|
||||
EXRImage exrImage;
|
||||
InitEXRImage(&exrImage);
|
||||
### Reading layered RGB(A) EXR file.
|
||||
|
||||
int ret = ParseMultiChannelEXRHeaderFromFile(&exrImage, input, &err);
|
||||
If you want to read EXR image with layer info (channel has a name with delimiter `.`), please use `LoadEXRWithLayer` API.
|
||||
|
||||
You need to know layer name in advance (e.g. through `EXRLayers` API).
|
||||
|
||||
```cpp
|
||||
const char* input = ...;
|
||||
const char* layer_name = "diffuse"; // or use EXRLayers to get list of layer names in .exr
|
||||
float* out; // width * height * RGBA
|
||||
int width;
|
||||
int height;
|
||||
const char* err = NULL; // or nullptr in C++11
|
||||
|
||||
// will read `diffuse.R`, `diffuse.G`, `diffuse.B`, (`diffuse.A`) channels
|
||||
int ret = LoadEXRWithLayer(&out, &width, &height, input, layer_name, &err);
|
||||
|
||||
if (ret != TINYEXR_SUCCESS) {
|
||||
if (err) {
|
||||
fprintf(stderr, "ERR : %s\n", err);
|
||||
FreeEXRErrorMessage(err); // release memory of error message.
|
||||
}
|
||||
} else {
|
||||
...
|
||||
free(out); // release memory of image data
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### Loading Singlepart EXR from a file.
|
||||
|
||||
Scanline and tiled format are supported.
|
||||
|
||||
```cpp
|
||||
// 1. Read EXR version.
|
||||
EXRVersion exr_version;
|
||||
|
||||
int ret = ParseEXRVersionFromFile(&exr_version, argv[1]);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Invalid EXR file: %s\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (exr_version.multipart) {
|
||||
// must be multipart flag is false.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 2. Read EXR header
|
||||
EXRHeader exr_header;
|
||||
InitEXRHeader(&exr_header);
|
||||
|
||||
const char* err = NULL; // or `nullptr` in C++11 or later.
|
||||
ret = ParseEXRHeaderFromFile(&exr_header, &exr_version, argv[1], &err);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Parse EXR err: %s\n", err);
|
||||
return;
|
||||
FreeEXRErrorMessage(err); // free's buffer for an error message
|
||||
return ret;
|
||||
}
|
||||
|
||||
//// Uncomment if you want reading HALF image as FLOAT.
|
||||
//for (int i = 0; i < exrImage.num_channels; i++) {
|
||||
// if (exrImage.pixel_types[i] = TINYEXR_PIXELTYPE_HALF) {
|
||||
// exrImage.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;
|
||||
// }
|
||||
//}
|
||||
// // Read HALF channel as FLOAT.
|
||||
// for (int i = 0; i < exr_header.num_channels; i++) {
|
||||
// if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) {
|
||||
// exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT;
|
||||
// }
|
||||
// }
|
||||
|
||||
ret = LoadMultiChannelEXRFromFile(&exrImage, input, &err);
|
||||
EXRImage exr_image;
|
||||
InitEXRImage(&exr_image);
|
||||
|
||||
ret = LoadEXRImageFromFile(&exr_image, &exr_header, argv[1], &err);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Load EXR err: %s\n", err);
|
||||
return;
|
||||
FreeEXRHeader(&exr_header);
|
||||
FreeEXRErrorMessage(err); // free's buffer for an error message
|
||||
return ret;
|
||||
}
|
||||
|
||||
// 3. Access image data
|
||||
// `exr_image.images` will be filled when EXR is scanline format.
|
||||
// `exr_image.tiled` will be filled when EXR is tiled format.
|
||||
|
||||
// 4. Free image data
|
||||
FreeEXRImage(&exr_image);
|
||||
FreeEXRHeader(&exr_header);
|
||||
```
|
||||
|
||||
Saving EXR file.
|
||||
### Loading Multipart EXR from a file.
|
||||
|
||||
Scanline and tiled format are supported.
|
||||
|
||||
```cpp
|
||||
// 1. Read EXR version.
|
||||
EXRVersion exr_version;
|
||||
|
||||
int ret = ParseEXRVersionFromFile(&exr_version, argv[1]);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Invalid EXR file: %s\n", argv[1]);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!exr_version.multipart) {
|
||||
// must be multipart flag is true.
|
||||
return -1;
|
||||
}
|
||||
|
||||
// 2. Read EXR headers in the EXR.
|
||||
EXRHeader **exr_headers; // list of EXRHeader pointers.
|
||||
int num_exr_headers;
|
||||
const char *err = NULL; // or nullptr in C++11 or later
|
||||
|
||||
// Memory for EXRHeader is allocated inside of ParseEXRMultipartHeaderFromFile,
|
||||
ret = ParseEXRMultipartHeaderFromFile(&exr_headers, &num_exr_headers, &exr_version, argv[1], &err);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Parse EXR err: %s\n", err);
|
||||
FreeEXRErrorMessage(err); // free's buffer for an error message
|
||||
return ret;
|
||||
}
|
||||
|
||||
printf("num parts = %d\n", num_exr_headers);
|
||||
|
||||
|
||||
// 3. Load images.
|
||||
|
||||
// Prepare array of EXRImage.
|
||||
std::vector<EXRImage> images(num_exr_headers);
|
||||
for (int i =0; i < num_exr_headers; i++) {
|
||||
InitEXRImage(&images[i]);
|
||||
}
|
||||
|
||||
ret = LoadEXRMultipartImageFromFile(&images.at(0), const_cast<const EXRHeader**>(exr_headers), num_exr_headers, argv[1], &err);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Parse EXR err: %s\n", err);
|
||||
FreeEXRErrorMessage(err); // free's buffer for an error message
|
||||
return ret;
|
||||
}
|
||||
|
||||
printf("Loaded %d part images\n", num_exr_headers);
|
||||
|
||||
// 4. Access image data
|
||||
// `exr_image.images` will be filled when EXR is scanline format.
|
||||
// `exr_image.tiled` will be filled when EXR is tiled format.
|
||||
|
||||
// 5. Free images
|
||||
for (int i =0; i < num_exr_headers; i++) {
|
||||
FreeEXRImage(&images.at(i));
|
||||
}
|
||||
|
||||
// 6. Free headers.
|
||||
for (int i =0; i < num_exr_headers; i++) {
|
||||
FreeEXRHeader(exr_headers[i]);
|
||||
free(exr_headers[i]);
|
||||
}
|
||||
free(exr_headers);
|
||||
```
|
||||
|
||||
|
||||
Saving Scanline EXR file.
|
||||
|
||||
```cpp
|
||||
// See `examples/rgbe2exr/` for more details.
|
||||
bool SaveEXR(const float* rgb, int width, int height, const char* outfilename) {
|
||||
|
||||
float* channels[3];
|
||||
EXRHeader header;
|
||||
InitEXRHeader(&header);
|
||||
|
||||
EXRImage image;
|
||||
InitEXRImage(&image);
|
||||
|
||||
image.num_channels = 3;
|
||||
|
||||
// Must be BGR(A) order, since most of EXR viewers expect this channel order.
|
||||
const char* channel_names[] = {"B", "G", "R"}; // "B", "G", "R", "A" for RGBA image
|
||||
|
||||
std::vector<float> images[3];
|
||||
images[0].resize(width * height);
|
||||
images[1].resize(width * height);
|
||||
images[2].resize(width * height);
|
||||
|
||||
// Split RGBRGBRGB... into R, G and B layer
|
||||
for (int i = 0; i < width * height; i++) {
|
||||
images[0][i] = rgb[3*i+0];
|
||||
images[1][i] = rgb[3*i+1];
|
||||
@ -131,31 +362,38 @@ Saving EXR file.
|
||||
image_ptr[1] = &(images[1].at(0)); // G
|
||||
image_ptr[2] = &(images[0].at(0)); // R
|
||||
|
||||
image.channel_names = channel_names;
|
||||
image.images = (unsigned char**)image_ptr;
|
||||
image.width = width;
|
||||
image.height = height;
|
||||
image.compression = TINYEXR_COMPRESSIONTYPE_ZIP;
|
||||
|
||||
image.pixel_types = (int *)malloc(sizeof(int) * image.num_channels);
|
||||
image.requested_pixel_types = (int *)malloc(sizeof(int) * image.num_channels);
|
||||
for (int i = 0; i < image.num_channels; i++) {
|
||||
image.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image
|
||||
image.requested_pixel_types[i] = TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in .EXR
|
||||
header.num_channels = 3;
|
||||
header.channels = (EXRChannelInfo *)malloc(sizeof(EXRChannelInfo) * header.num_channels);
|
||||
// Must be (A)BGR order, since most of EXR viewers expect this channel order.
|
||||
strncpy(header.channels[0].name, "B", 255); header.channels[0].name[strlen("B")] = '\0';
|
||||
strncpy(header.channels[1].name, "G", 255); header.channels[1].name[strlen("G")] = '\0';
|
||||
strncpy(header.channels[2].name, "R", 255); header.channels[2].name[strlen("R")] = '\0';
|
||||
|
||||
header.pixel_types = (int *)malloc(sizeof(int) * header.num_channels);
|
||||
header.requested_pixel_types = (int *)malloc(sizeof(int) * header.num_channels);
|
||||
for (int i = 0; i < header.num_channels; i++) {
|
||||
header.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image
|
||||
header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in .EXR
|
||||
}
|
||||
|
||||
const char* err;
|
||||
int ret = SaveMultiChannelEXRToFile(&image, outfilename, &err);
|
||||
if (ret != 0) {
|
||||
const char* err = NULL; // or nullptr in C++11 or later.
|
||||
int ret = SaveEXRImageToFile(&image, &header, outfilename, &err);
|
||||
if (ret != TINYEXR_SUCCESS) {
|
||||
fprintf(stderr, "Save EXR err: %s\n", err);
|
||||
FreeEXRErrorMessage(err); // free's buffer for an error message
|
||||
return ret;
|
||||
}
|
||||
printf("Saved exr file. [ %s ] \n", outfilename);
|
||||
|
||||
free(image.pixel_types);
|
||||
free(image.requested_pixel_types);
|
||||
free(rgb);
|
||||
|
||||
return ret;
|
||||
free(header.channels);
|
||||
free(header.pixel_types);
|
||||
free(header.requested_pixel_types);
|
||||
|
||||
}
|
||||
```
|
||||
@ -164,14 +402,14 @@ Saving EXR file.
|
||||
Reading deep image EXR file.
|
||||
See `example/deepview` for actual usage.
|
||||
|
||||
```
|
||||
```cpp
|
||||
const char* input = "deepimage.exr";
|
||||
const char* err;
|
||||
const char* err = NULL; // or nullptr
|
||||
DeepImage deepImage;
|
||||
|
||||
int ret = LoadDeepEXR(&deepImage, input, &err);
|
||||
|
||||
// acccess to each sample in the deep pixel.
|
||||
// access to each sample in the deep pixel.
|
||||
for (int y = 0; y < deepImage.height; y++) {
|
||||
int sampleNum = deepImage.offset_table[y][deepImage.width-1];
|
||||
for (int x = 0; x < deepImage.width-1; x++) {
|
||||
@ -196,49 +434,101 @@ See `example/deepview` for actual usage.
|
||||
|
||||

|
||||
|
||||
## TinyEXR extension
|
||||
|
||||
### ZFP
|
||||
|
||||
#### NOTE
|
||||
|
||||
TinyEXR adds ZFP compression as an experimemtal support (Linux and MacOSX only).
|
||||
|
||||
ZFP only supports FLOAT format pixel, and its image width and height must be the multiple of 4, since ZFP compresses pixels with 4x4 pixel block.
|
||||
|
||||
#### Setup
|
||||
|
||||
Checkout zfp repo as an submodule.
|
||||
|
||||
$ git submodule update --init
|
||||
|
||||
#### Build
|
||||
|
||||
Then build ZFP
|
||||
|
||||
$ cd deps/ZFP
|
||||
$ mkdir -p lib # Create `lib` directory if not exist
|
||||
$ make
|
||||
|
||||
Set `1` to `TINYEXT_USE_ZFP` define in `tinyexr.h`
|
||||
|
||||
Build your app with linking `deps/ZFP/lib/libzfp.a`
|
||||
|
||||
#### ZFP attribute
|
||||
|
||||
For ZFP EXR image, the following attribute must exist in its EXR image.
|
||||
|
||||
* `zfpCompressionType` (uchar).
|
||||
* 0 = fixed rate compression
|
||||
* 1 = precision based variable rate compression
|
||||
* 2 = accuracy based variable rate compression
|
||||
|
||||
And the one of following attributes must exist in EXR, depending on the `zfpCompressionType` value.
|
||||
|
||||
* `zfpCompressionRate` (double)
|
||||
* Specifies compression rate for fixed rate compression.
|
||||
* `zfpCompressionPrecision` (int32)
|
||||
* Specifies the number of bits for precision based variable rate compression.
|
||||
* `zfpCompressionTolerance` (double)
|
||||
* Specifies the tolerance value for accuracy based variable rate compression.
|
||||
|
||||
#### Note on ZFP compression.
|
||||
|
||||
At least ZFP code itself works well on big endian machine.
|
||||
|
||||
## Unit tests
|
||||
|
||||
See `test/unit` directory.
|
||||
|
||||
## TODO
|
||||
|
||||
Contribution is welcome!
|
||||
|
||||
- [ ] Compression
|
||||
- [ ] NONE("compress" = 0, load)
|
||||
- [ ] RLE("compress" = 1, load)
|
||||
- [x] ZIPS("compress" = 2, load)
|
||||
- [x] ZIP("compress" = 3, load)
|
||||
- [x] PIZ("compress" = 4, load)
|
||||
- [x] NONE("compress" = 0, save)
|
||||
- [ ] RLE("compress" = 1, save)
|
||||
- [x] ZIPS("compress" = 2, save)
|
||||
- [x] ZIP("compress" = 3, save)
|
||||
- [ ] PIZ("compress" = 4, save)
|
||||
- [ ] B44?
|
||||
- [ ] B44A?
|
||||
- [ ] PIX24?
|
||||
- [ ] Custom attributes
|
||||
- [x] Normal image(EXR 1.x)
|
||||
- [ ] Deep image(EXR 2.x)
|
||||
- [ ] JavaScript library
|
||||
- [x] Normal image (EXR 1.x)
|
||||
- [ ] Deep image (EXR 2.x)
|
||||
- [ ] JavaScript library (experimental, using Emscripten)
|
||||
- [x] LoadEXRFromMemory
|
||||
- [ ] SaveMultiChannelEXR
|
||||
- [ ] Deep image save/load
|
||||
- [ ] Write from/to memory buffer.
|
||||
- [x] SaveMultiChannelEXR
|
||||
- [x] LoadMultiChannelEXR
|
||||
- [ ] Deep image save/load
|
||||
- [ ] Tile format.
|
||||
- [ ] Support for various compression type.
|
||||
- [x] zstd compression(Not in OpenEXR spec, though)
|
||||
- [x] Tile format with no LoD (load).
|
||||
- [ ] Tile format with LoD (load).
|
||||
- [ ] Tile format with no LoD (save).
|
||||
- [ ] Tile format with LoD (save).
|
||||
- [ ] Support for custom compression type.
|
||||
- [x] zfp compression (Not in OpenEXR spec, though)
|
||||
- [ ] zstd?
|
||||
- [x] Multi-channel.
|
||||
- [ ] Multi-part(EXR2.0)
|
||||
- [ ] Multi-part (EXR2.0)
|
||||
- [x] Load multi-part image
|
||||
- [ ] Load multi-part deep image
|
||||
- [ ] Line order.
|
||||
- [x] Increasing, decreasing(load)
|
||||
- [x] Increasing, decreasing (load)
|
||||
- [ ] Random?
|
||||
- [ ] Increasing, decreasing(save)
|
||||
- [ ] Pixel format(UINT, FLOAT).
|
||||
- [x] UINT, FLOAT(load)
|
||||
- [x] UINT, FLOAT(deep load)
|
||||
- [x] UINT, FLOAT(save)
|
||||
- [ ] UINT, FLOAT(deep save)
|
||||
- [ ] Full support for big endian machine.
|
||||
- [x] Loading multi channel EXR
|
||||
- [x] Saving multi channel EXR
|
||||
- [ ] Increasing, decreasing (save)
|
||||
- [ ] Pixel format (UINT, FLOAT).
|
||||
- [x] UINT, FLOAT (load)
|
||||
- [x] UINT, FLOAT (deep load)
|
||||
- [x] UINT, FLOAT (save)
|
||||
- [ ] UINT, FLOAT (deep save)
|
||||
- [ ] Support for big endian machine.
|
||||
- [ ] Loading multi-part channel EXR
|
||||
- [ ] Saving multi-part channel EXR
|
||||
- [ ] Loading deep image
|
||||
- [ ] Saving deep image
|
||||
- [ ] Optimization
|
||||
@ -248,6 +538,10 @@ Contribution is welcome!
|
||||
- [ ] OpenMP multi-threading in deep image loading.
|
||||
- [ ] OpenMP multi-threading in deep image saving.
|
||||
|
||||
## Python bindings
|
||||
|
||||
`pytinyexr` is available: https://pypi.org/project/pytinyexr/ (loading only as of 0.9.1)
|
||||
|
||||
## Similar or related projects
|
||||
|
||||
* miniexr: https://github.com/aras-p/miniexr (Write OpenEXR)
|
||||
@ -264,11 +558,11 @@ Contribution is welcome!
|
||||
|
||||
## Author(s)
|
||||
|
||||
Syoyo Fujita(syoyo@lighttransport.com)
|
||||
Syoyo Fujita (syoyo@lighttransport.com)
|
||||
|
||||
## Contributor(s)
|
||||
|
||||
* Matt Ebb (http://mattebb.com) : deep image example. Thanks!
|
||||
* Matt Pharr (http://pharr.org/matt/) : Testing tinyexr with OpenEXR(IlmImf). Thanks!
|
||||
* Andrew Bell (https://github.com/andrewfb) & Richard Eakin (https://github.com/richardeakin) : Improving TinyEXR API. Thanks!
|
||||
* Mike Wong (https://github.com/mwkm) : ZIPS compression support in loading. Thanks!
|
||||
* Matt Ebb (http://mattebb.com): deep image example. Thanks!
|
||||
* Matt Pharr (http://pharr.org/matt/): Testing tinyexr with OpenEXR(IlmImf). Thanks!
|
||||
* Andrew Bell (https://github.com/andrewfb) & Richard Eakin (https://github.com/richardeakin): Improving TinyEXR API. Thanks!
|
||||
* Mike Wong (https://github.com/mwkm): ZIPS compression support in loading. Thanks!
|
||||
|
196
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/ChangeLog.md
vendored
Normal file
196
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/ChangeLog.md
vendored
Normal file
@ -0,0 +1,196 @@
|
||||
## Changelog
|
||||
|
||||
### 2.2.0
|
||||
|
||||
- Fix examples with amalgamation
|
||||
- Modified cmake script to support shared library mode and find_package
|
||||
- Fix for misleading doc comment on `mz_zip_reader_init_cfile` function
|
||||
- Add include location tolerance and stop forcing `_GNU_SOURCE`
|
||||
- Fix: mz_zip_reader_locate_file_v2 returns an mz_bool
|
||||
- Fix large file system checks
|
||||
- Add #elif to enable an external mz_crc32() to be linked in
|
||||
- Write with dynamic size (size of file/data to be added not known before adding)
|
||||
- Added uncompress2 for zlib compatibility
|
||||
- Add support for building as a Meson subproject
|
||||
- Added OSSFuzz support; Integrate with CIFuzz
|
||||
- Add pkg-config file
|
||||
- Fixed use-of-uninitialized value msan error when copying dist bytes with no output bytes written.
|
||||
- mz_zip_validate_file(): fix memory leak on errors
|
||||
- Fixed MSAN use-of-uninitialized in tinfl_decompress when invalid dist is decoded. In this instance dist was 31 which s_dist_base translates as 0
|
||||
- Add flag to set (compressed) size in local file header
|
||||
- avoid use of uninitialized value in tdefl_record_literal
|
||||
|
||||
### 2.1.0
|
||||
|
||||
- More instances of memcpy instead of cast and use memcpy per default
|
||||
- Remove inline for c90 support
|
||||
- New function to read files via callback functions when adding them
|
||||
- Fix out of bounds read while reading Zip64 extended information
|
||||
- guard memcpy when n == 0 because buffer may be NULL
|
||||
- Implement inflateReset() function
|
||||
- Move comp/decomp alloc/free prototypes under guarding #ifndef MZ_NO_MALLOC
|
||||
- Fix large file support under Windows
|
||||
- Don't warn if _LARGEFILE64_SOURCE is not defined to 1
|
||||
- Fixes for MSVC warnings
|
||||
- Remove check that path of file added to archive contains ':' or '\'
|
||||
- Add !defined check on MINIZ_USE_ALIGNED_LOADS_AND_STORES
|
||||
|
||||
### 2.0.8
|
||||
|
||||
- Remove unimplemented functions (mz_zip_locate_file and mz_zip_locate_file_v2)
|
||||
- Add license, changelog, readme and example files to release zip
|
||||
- Fix heap overflow to user buffer in tinfl_status tinfl_decompress
|
||||
- Fix corrupt archive if uncompressed file smaller than 4 byte and the file is added by mz_zip_writer_add_mem*
|
||||
|
||||
### 2.0.7
|
||||
|
||||
- Removed need in C++ compiler in cmake build
|
||||
- Fixed a lot of uninitialized value errors found with Valgrind by memsetting m_dict to 0 in tdefl_init
|
||||
- Fix resource leak in mz_zip_reader_init_file_v2
|
||||
- Fix assert with mz_zip_writer_add_mem* w/MZ_DEFAULT_COMPRESSION
|
||||
- cmake build: install library and headers
|
||||
- Remove _LARGEFILE64_SOURCE requirement from apple defines for large files
|
||||
|
||||
### 2.0.6
|
||||
|
||||
- Improve MZ_ZIP_FLAG_WRITE_ZIP64 documentation
|
||||
- Remove check for cur_archive_file_ofs > UINT_MAX because cur_archive_file_ofs is not used after this point
|
||||
- Add cmake debug configuration
|
||||
- Fix PNG height when creating png files
|
||||
- Add "iterative" file extraction method based on mz_zip_reader_extract_to_callback.
|
||||
- Option to use memcpy for unaligned data access
|
||||
- Define processor/arch macros as zero if not set to one
|
||||
|
||||
### 2.0.4/2.0.5
|
||||
|
||||
- Fix compilation with the various omission compile definitions
|
||||
|
||||
### 2.0.3
|
||||
|
||||
- Fix GCC/clang compile warnings
|
||||
- Added callback for periodic flushes (for ZIP file streaming)
|
||||
- Use UTF-8 for file names in ZIP files per default
|
||||
|
||||
### 2.0.2
|
||||
|
||||
- Fix source backwards compatibility with 1.x
|
||||
- Fix a ZIP bit not being set correctly
|
||||
|
||||
### 2.0.1
|
||||
|
||||
- Added some tests
|
||||
- Added CI
|
||||
- Make source code ANSI C compatible
|
||||
|
||||
### 2.0.0 beta
|
||||
|
||||
- Matthew Sitton merged miniz 1.x to Rich Geldreich's vogl ZIP64 changes. Miniz is now licensed as MIT since the vogl code base is MIT licensed
|
||||
- Miniz is now split into several files
|
||||
- Miniz does now not seek backwards when creating ZIP files. That is the ZIP files can be streamed
|
||||
- Miniz automatically switches to the ZIP64 format when the created ZIP files goes over ZIP file limits
|
||||
- Similar to [SQLite](https://www.sqlite.org/amalgamation.html) the Miniz source code is amalgamated into one miniz.c/miniz.h pair in a build step (amalgamate.sh). Please use miniz.c/miniz.h in your projects
|
||||
- Miniz 2 is only source back-compatible with miniz 1.x. It breaks binary compatibility because structures changed
|
||||
|
||||
### v1.16 BETA Oct 19, 2013
|
||||
|
||||
Still testing, this release is downloadable from [here](http://www.tenacioussoftware.com/miniz_v116_beta_r1.7z). Two key inflator-only robustness and streaming related changes. Also merged in tdefl_compressor_alloc(), tdefl_compressor_free() helpers to make script bindings easier for rustyzip. I would greatly appreciate any help with testing or any feedback.
|
||||
|
||||
The inflator in raw (non-zlib) mode is now usable on gzip or similar streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520). This version should never read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer.
|
||||
|
||||
The inflator now has a new failure status TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on. This is scary behavior if the caller didn't know when to stop accepting output (because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum). v1.16 will instead return TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft" failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios.
|
||||
|
||||
- The inflator coroutine func. is subtle and complex so I'm being cautious about this release. I would greatly appreciate any help with testing or any feedback.
|
||||
I feel good about these changes, and they've been through several hours of automated testing, but they will probably not fix anything for the majority of prev. users so I'm
|
||||
going to mark this release as beta for a few weeks and continue testing it at work/home on various things.
|
||||
- The inflator in raw (non-zlib) mode is now usable on gzip or similar data streams that have a bunch of bytes following the raw deflate data (problem discovered by rustyzip author williamw520).
|
||||
This version should *never* read beyond the last byte of the raw deflate data independent of how many bytes you pass into the input buffer. This issue was caused by the various Huffman bitbuffer lookahead optimizations, and
|
||||
would not be an issue if the caller knew and enforced the precise size of the raw compressed data *or* if the compressed data was in zlib format (i.e. always followed by the byte aligned zlib adler32).
|
||||
So in other words, you can now call the inflator on deflate streams that are followed by arbitrary amounts of data and it's guaranteed that decompression will stop exactly on the last byte.
|
||||
- The inflator now has a new failure status: TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS (-4). Previously, if the inflator was starved of bytes and could not make progress (because the input buffer was empty and the
|
||||
caller did not set the TINFL_FLAG_HAS_MORE_INPUT flag - say on truncated or corrupted compressed data stream) it would append all 0's to the input and try to soldier on.
|
||||
This is scary, because in the worst case, I believe it was possible for the prev. inflator to start outputting large amounts of literal data. If the caller didn't know when to stop accepting output
|
||||
(because it didn't know how much uncompressed data was expected, or didn't enforce a sane maximum) it could continue forever. v1.16 cannot fall into this failure mode, instead it'll return
|
||||
TINFL_STATUS_FAILED_CANNOT_MAKE_PROGRESS immediately if it needs 1 or more bytes to make progress, the input buf is empty, and the caller has indicated that no more input is available. This is a "soft"
|
||||
failure, so you can call the inflator again with more input and it will try to continue, or you can give up and fail. This could be very useful in network streaming scenarios.
|
||||
- Added documentation to all the tinfl return status codes, fixed miniz_tester so it accepts double minus params for Linux, tweaked example1.c, added a simple "follower bytes" test to miniz_tester.cpp.
|
||||
### v1.15 r4 STABLE - Oct 13, 2013
|
||||
|
||||
Merged over a few very minor bug fixes that I fixed in the zip64 branch. This is downloadable from [here](http://code.google.com/p/miniz/downloads/list) and also in SVN head (as of 10/19/13).
|
||||
|
||||
|
||||
### v1.15 - Oct. 13, 2013
|
||||
|
||||
Interim bugfix release while I work on the next major release with zip64 and streaming compression/decompression support. Fixed the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com), which could cause the locate files func to not find files when this flag was specified. Also fixed a bug in mz_zip_reader_extract_to_mem_no_alloc() with user provided read buffers (thanks kymoon). I also merged lots of compiler fixes from various github repo branches and Google Code issue reports. I finally added cmake support (only tested under for Linux so far), compiled and tested with clang v3.3 and gcc 4.6 (under Linux), added defl_write_image_to_png_file_in_memory_ex() (supports Y flipping for OpenGL use, real-time compression), added a new PNG example (example6.c - Mandelbrot), and I added 64-bit file I/O support (stat64(), etc.) for glibc.
|
||||
|
||||
- Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug
|
||||
would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place()
|
||||
(which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag).
|
||||
- Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size
|
||||
- Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries.
|
||||
Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice).
|
||||
- Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes
|
||||
- mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed
|
||||
- Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6.
|
||||
- Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti
|
||||
- Merged MZ_FORCEINLINE fix from hdeanclark
|
||||
- Fix <time.h> include before config #ifdef, thanks emil.brink
|
||||
- Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can
|
||||
set it to 1 for real-time compression).
|
||||
- Merged in some compiler fixes from paulharris's github repro.
|
||||
- Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3.
|
||||
- Added example6.c, which dumps an image of the mandelbrot set to a PNG file.
|
||||
- Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more.
|
||||
- In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled
|
||||
- In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch
|
||||
|
||||
### v1.14 - May 20, 2012
|
||||
|
||||
(SVN Only) Minor tweaks to get miniz.c compiling with the Tiny C Compiler, added #ifndef MINIZ_NO_TIME guards around utime.h includes. Adding mz_free() function, so the caller can free heap blocks returned by miniz using whatever heap functions it has been configured to use, MSVC specific fixes to use "safe" variants of several functions (localtime_s, fopen_s, freopen_s).
|
||||
|
||||
MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include <time.h> (thanks fermtect).
|
||||
|
||||
Compiler specific fixes, some from fermtect. I upgraded to TDM GCC 4.6.1 and now static __forceinline is giving it fits, so I'm changing all usage of __forceinline to MZ_FORCEINLINE and forcing gcc to use __attribute__((__always_inline__)) (and MSVC to use __forceinline). Also various fixes from fermtect for MinGW32: added #include , 64-bit ftell/fseek fixes.
|
||||
|
||||
### v1.13 - May 19, 2012
|
||||
|
||||
From jason@cornsyrup.org and kelwert@mtu.edu - Most importantly, fixed mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bits. Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files. Other stuff:
|
||||
|
||||
Eliminated a bunch of warnings when compiling with GCC 32-bit/64. Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly "Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning).
|
||||
|
||||
Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64. Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test. Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives. Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.)
|
||||
|
||||
Fix ftell() usage in a few of the examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself). Fix fail logic handling in mz_zip_add_mem_to_archive_file_in_place() so it always calls mz_zip_writer_finalize_archive() and mz_zip_writer_end(), even if the file add fails.
|
||||
|
||||
- From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit.
|
||||
- Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files.
|
||||
- Eliminated a bunch of warnings when compiling with GCC 32-bit/64.
|
||||
- Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly
|
||||
"Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning).
|
||||
- Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64.
|
||||
- Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test.
|
||||
- Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives.
|
||||
- Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.)
|
||||
- Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself).
|
||||
|
||||
### v1.12 - 4/12/12
|
||||
|
||||
More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's.
|
||||
level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson <bruced@valvesoftware.com> for the feedback/bug report.
|
||||
|
||||
### v1.11 - 5/28/11
|
||||
|
||||
Added statement from unlicense.org
|
||||
|
||||
### v1.10 - 5/27/11
|
||||
|
||||
- Substantial compressor optimizations:
|
||||
- Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86).
|
||||
- Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types.
|
||||
- Refactored the compression code for better readability and maintainability.
|
||||
- Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large drop in throughput on some files).
|
||||
|
||||
### v1.09 - 5/15/11
|
||||
|
||||
Initial stable release.
|
||||
|
||||
|
22
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/LICENSE
vendored
Normal file
22
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/LICENSE
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
Copyright 2013-2014 RAD Game Tools and Valve Software
|
||||
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC
|
||||
|
||||
All Rights Reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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 OR COPYRIGHT HOLDERS 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.
|
7733
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/miniz.c
vendored
Normal file
7733
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/miniz.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1350
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/miniz.h
vendored
Normal file
1350
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/miniz.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
34
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/readme.md
vendored
Normal file
34
3rdparty/bimg/3rdparty/tinyexr/deps/miniz/readme.md
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
## Miniz
|
||||
|
||||
Miniz is a lossless, high performance data compression library in a single source file that implements the zlib (RFC 1950) and Deflate (RFC 1951) compressed data format specification standards. It supports the most commonly used functions exported by the zlib library, but is a completely independent implementation so zlib's licensing requirements do not apply. Miniz also contains simple to use functions for writing .PNG format image files and reading/writing/appending .ZIP format archives. Miniz's compression speed has been tuned to be comparable to zlib's, and it also has a specialized real-time compressor function designed to compare well against fastlz/minilzo.
|
||||
|
||||
## Usage
|
||||
|
||||
Please use the files from the [releases page](https://github.com/richgel999/miniz/releases) in your projects. Do not use the git checkout directly! The different source and header files are [amalgamated](https://www.sqlite.org/amalgamation.html) into one `miniz.c`/`miniz.h` pair in a build step (`amalgamate.sh`). Include `miniz.c` and `miniz.h` in your project to use Miniz.
|
||||
|
||||
## Features
|
||||
|
||||
* MIT licensed
|
||||
* A portable, single source and header file library written in plain C. Tested with GCC, clang and Visual Studio.
|
||||
* Easily tuned and trimmed down by defines
|
||||
* A drop-in replacement for zlib's most used API's (tested in several open source projects that use zlib, such as libpng and libzip).
|
||||
* Fills a single threaded performance vs. compression ratio gap between several popular real-time compressors and zlib. For example, at level 1, miniz.c compresses around 5-9% better than minilzo, but is approx. 35% slower. At levels 2-9, miniz.c is designed to compare favorably against zlib's ratio and speed. See the miniz performance comparison page for example timings.
|
||||
* Not a block based compressor: miniz.c fully supports stream based processing using a coroutine-style implementation. The zlib-style API functions can be called a single byte at a time if that's all you've got.
|
||||
* Easy to use. The low-level compressor (tdefl) and decompressor (tinfl) have simple state structs which can be saved/restored as needed with simple memcpy's. The low-level codec API's don't use the heap in any way.
|
||||
* Entire inflater (including optional zlib header parsing and Adler-32 checking) is implemented in a single function as a coroutine, which is separately available in a small (~550 line) source file: miniz_tinfl.c
|
||||
* A fairly complete (but totally optional) set of .ZIP archive manipulation and extraction API's. The archive functionality is intended to solve common problems encountered in embedded, mobile, or game development situations. (The archive API's are purposely just powerful enough to write an entire archiver given a bit of additional higher-level logic.)
|
||||
|
||||
## Known Problems
|
||||
|
||||
* No support for encrypted archives. Not sure how useful this stuff is in practice.
|
||||
* Minimal documentation. The assumption is that the user is already familiar with the basic zlib API. I need to write an API wiki - for now I've tried to place key comments before each enum/API, and I've included 6 examples that demonstrate how to use the module's major features.
|
||||
|
||||
## Special Thanks
|
||||
|
||||
Thanks to Alex Evans for the PNG writer function. Also, thanks to Paul Holden and Thorsten Scheuermann for feedback and testing, Matt Pritchard for all his encouragement, and Sean Barrett's various public domain libraries for inspiration (and encouraging me to write miniz.c in C, which was much more enjoyable and less painful than I thought it would be considering I've been programming in C++ for so long).
|
||||
|
||||
Thanks to Bruce Dawson for reporting a problem with the level_and_flags archive API parameter (which is fixed in v1.12) and general feedback, and Janez Zemva for indirectly encouraging me into writing more examples.
|
||||
|
||||
## Patents
|
||||
|
||||
I was recently asked if miniz avoids patent issues. miniz purposely uses the same core algorithms as the ones used by zlib. The compressor uses vanilla hash chaining as described [here](https://datatracker.ietf.org/doc/html/rfc1951#section-4). Also see the [gzip FAQ](https://web.archive.org/web/20160308045258/http://www.gzip.org/#faq11). In my opinion, if miniz falls prey to a patent attack then zlib/gzip are likely to be at serious risk too.
|
9989
3rdparty/bimg/3rdparty/tinyexr/tinyexr.h
vendored
9989
3rdparty/bimg/3rdparty/tinyexr/tinyexr.h
vendored
File diff suppressed because it is too large
Load Diff
2
3rdparty/bimg/LICENSE
vendored
2
3rdparty/bimg/LICENSE
vendored
@ -1,4 +1,4 @@
|
||||
Copyright 2010-2019 Branimir Karadzic
|
||||
Copyright 2010-2021 Branimir Karadzic
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
6
3rdparty/bimg/README.md
vendored
6
3rdparty/bimg/README.md
vendored
@ -3,10 +3,10 @@ bimg
|
||||
|
||||
Image library.
|
||||
|
||||
[](https://travis-ci.org/bkaradzic/bimg)
|
||||
[](https://travis-ci.com/bkaradzic/bimg)
|
||||
[](https://ci.appveyor.com/project/bkaradzic/bimg)
|
||||
[](https://bkaradzic.github.io/bgfx/license.html)
|
||||
[](https://gitter.im/bkaradzic/bgfx)
|
||||
[](https://discord.gg/9eMbv7J)
|
||||
|
||||
Contact
|
||||
-------
|
||||
@ -23,7 +23,7 @@ https://github.com/bkaradzic/bimg
|
||||
<img align="right" src="http://opensource.org/trademarks/opensource/OSI-Approved-License-100x137.png">
|
||||
</a>
|
||||
|
||||
Copyright 2010-2019 Branimir Karadzic
|
||||
Copyright 2010-2021 Branimir Karadzic
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
4
3rdparty/bimg/include/bimg/bimg.h
vendored
4
3rdparty/bimg/include/bimg/bimg.h
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
@ -195,6 +195,7 @@ namespace bimg
|
||||
bool m_cubeMap;
|
||||
bool m_ktx;
|
||||
bool m_ktxLE;
|
||||
bool m_pvr3;
|
||||
bool m_srgb;
|
||||
};
|
||||
|
||||
@ -541,6 +542,7 @@ namespace bimg
|
||||
, uint32_t _depth
|
||||
, uint8_t _numMips
|
||||
, uint32_t _numLayers
|
||||
, bool _srgb
|
||||
, const void* _src
|
||||
, bx::Error* _err = NULL
|
||||
);
|
||||
|
2
3rdparty/bimg/include/bimg/decode.h
vendored
2
3rdparty/bimg/include/bimg/decode.h
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
|
2
3rdparty/bimg/include/bimg/encode.h
vendored
2
3rdparty/bimg/include/bimg/encode.h
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
|
92
3rdparty/bimg/makefile
vendored
92
3rdparty/bimg/makefile
vendored
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
# Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
# License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
#
|
||||
|
||||
@ -42,15 +42,15 @@ projgen: ## Generate project files for all configurations.
|
||||
$(GENIE) --with-tools vs2017
|
||||
$(GENIE) --with-tools --gcc=mingw-gcc gmake
|
||||
$(GENIE) --with-tools --gcc=linux-gcc gmake
|
||||
$(GENIE) --with-tools --gcc=osx gmake
|
||||
$(GENIE) --with-tools --gcc=osx-x64 gmake
|
||||
$(GENIE) --with-tools --xcode=osx xcode8
|
||||
$(GENIE) --with-tools --xcode=ios xcode8
|
||||
$(GENIE) --gcc=freebsd gmake
|
||||
$(GENIE) --gcc=android-arm gmake
|
||||
$(GENIE) --gcc=android-arm64 gmake
|
||||
$(GENIE) --gcc=android-mips gmake
|
||||
$(GENIE) --gcc=android-x86 gmake
|
||||
$(GENIE) --gcc=asmjs gmake
|
||||
$(GENIE) --gcc=wasm2js gmake
|
||||
$(GENIE) --gcc=wasm gmake
|
||||
$(GENIE) --gcc=ios-arm gmake
|
||||
$(GENIE) --gcc=ios-arm64 gmake
|
||||
$(GENIE) --gcc=ios-simulator gmake
|
||||
@ -73,14 +73,6 @@ android-arm64-release: .build/projects/gmake-android-arm64 ## Build - Android AR
|
||||
$(MAKE) -R -C .build/projects/gmake-android-arm64 config=release
|
||||
android-arm64: android-arm64-debug android-arm64-release ## Build - Android ARM64 Debug and Release
|
||||
|
||||
.build/projects/gmake-android-mips:
|
||||
$(GENIE) --gcc=android-mips gmake
|
||||
android-mips-debug: .build/projects/gmake-android-mips ## Build - Android MIPS Debug
|
||||
$(MAKE) -R -C .build/projects/gmake-android-mips config=debug
|
||||
android-mips-release: .build/projects/gmake-android-mips ## Build - Android MIPS Release
|
||||
$(MAKE) -R -C .build/projects/gmake-android-mips config=release
|
||||
android-mips: android-mips-debug android-mips-release ## Build - Android MIPS Debug and Release
|
||||
|
||||
.build/projects/gmake-android-x86:
|
||||
$(GENIE) --gcc=android-x86 gmake
|
||||
android-x86-debug: .build/projects/gmake-android-x86 ## Build - Android x86 Debug and Release
|
||||
@ -89,13 +81,21 @@ android-x86-release: .build/projects/gmake-android-x86 ## Build - Android x86 De
|
||||
$(MAKE) -R -C .build/projects/gmake-android-x86 config=release
|
||||
android-x86: android-x86-debug android-x86-release ## Build - Android x86 Debug and Release
|
||||
|
||||
.build/projects/gmake-asmjs:
|
||||
$(GENIE) --gcc=asmjs gmake
|
||||
asmjs-debug: .build/projects/gmake-asmjs ## Build - Emscripten Debug
|
||||
$(MAKE) -R -C .build/projects/gmake-asmjs config=debug
|
||||
asmjs-release: .build/projects/gmake-asmjs ## Build - Emscripten Release
|
||||
$(MAKE) -R -C .build/projects/gmake-asmjs config=release
|
||||
asmjs: asmjs-debug asmjs-release ## Build - Emscripten Debug and Release
|
||||
.build/projects/gmake-wasm2js:
|
||||
$(GENIE) --gcc=wasm2js gmake
|
||||
wasm2js-debug: .build/projects/gmake-wasm2js ## Build - Emscripten Debug
|
||||
$(MAKE) -R -C .build/projects/gmake-wasm2js config=debug
|
||||
wasm2js-release: .build/projects/gmake-wasm2js ## Build - Emscripten Release
|
||||
$(MAKE) -R -C .build/projects/gmake-wasm2js config=release
|
||||
wasm2js: wasm2js-debug wasm2js-release ## Build - Emscripten Debug and Release
|
||||
|
||||
.build/projects/gmake-wasm:
|
||||
$(GENIE) --gcc=wasm gmake
|
||||
wasm-debug: .build/projects/gmake-wasm ## Build - Emscripten Debug
|
||||
$(MAKE) -R -C .build/projects/gmake-wasm config=debug
|
||||
wasm-release: .build/projects/gmake-wasm ## Build - Emscripten Release
|
||||
$(MAKE) -R -C .build/projects/gmake-wasm config=release
|
||||
wasm: wasm-debug wasm-release ## Build - Emscripten Debug and Release
|
||||
|
||||
.build/projects/gmake-linux:
|
||||
$(GENIE) --with-tools --gcc=linux-gcc gmake
|
||||
@ -153,13 +153,13 @@ vs2017-release64: .build/projects/vs2017 ## Build - vs2017 x64 Release
|
||||
devenv .build/projects/vs2017/bimg.sln /Build "Release|x64"
|
||||
vs2017: vs2017-debug32 vs2017-release32 vs2017-debug64 vs2017-release64 ## Build - vs2017 x86/x64 Debug and Release
|
||||
|
||||
.build/projects/gmake-osx:
|
||||
$(GENIE) --with-tools --gcc=osx gmake
|
||||
osx-debug64: .build/projects/gmake-osx ## Build - OSX x64 Debug
|
||||
$(MAKE) -C .build/projects/gmake-osx config=debug64
|
||||
osx-release64: .build/projects/gmake-osx ## Build - OSX x64 Release
|
||||
$(MAKE) -C .build/projects/gmake-osx config=release64
|
||||
osx: osx-debug64 osx-release64 ## Build - OSX x64 Debug and Release
|
||||
.build/projects/gmake-osx-x64:
|
||||
$(GENIE) --gcc=osx-x64 gmake
|
||||
osx-x64-debug: .build/projects/gmake-osx-x64
|
||||
make -C .build/projects/gmake-osx config=debug
|
||||
osx-x64-release: .build/projects/gmake-osx-x64
|
||||
make -C .build/projects/gmake-osx config=release
|
||||
osx-x64: osx-x64-debug osx-x64-release
|
||||
|
||||
.build/projects/gmake-ios-arm:
|
||||
$(GENIE) --gcc=ios-arm gmake
|
||||
@ -201,7 +201,7 @@ rpi-release: .build/projects/gmake-rpi ## Build - RasberryPi Release
|
||||
$(MAKE) -R -C .build/projects/gmake-rpi config=release
|
||||
rpi: rpi-debug rpi-release ## Build - RasberryPi Debug and Release
|
||||
|
||||
build-darwin: osx
|
||||
build-darwin: osx-x64
|
||||
|
||||
build-linux: linux-debug64 linux-release64
|
||||
|
||||
@ -231,9 +231,9 @@ UNAME := $(shell uname)
|
||||
ifeq ($(UNAME),$(filter $(UNAME),Linux Darwin FreeBSD GNU/kFreeBSD))
|
||||
ifeq ($(UNAME),$(filter $(UNAME),Darwin))
|
||||
OS=darwin
|
||||
BUILD_PROJECT_DIR=gmake-osx
|
||||
BUILD_OUTPUT_DIR=osx64_clang
|
||||
BUILD_TOOLS_CONFIG=release64
|
||||
BUILD_PROJECT_DIR=gmake-osx-x64
|
||||
BUILD_OUTPUT_DIR=osx-x64
|
||||
BUILD_TOOLS_CONFIG=release
|
||||
BUILD_TOOLS_SUFFIX=Release
|
||||
EXE=
|
||||
else
|
||||
@ -284,33 +284,15 @@ clean-tools: ## Clean tools projects.
|
||||
-$(SILENT) rm -r .build/projects/$(BUILD_PROJECT_DIR)
|
||||
|
||||
dist-windows: .build/projects/gmake-mingw-gcc
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 geometryc
|
||||
$(SILENT) cp .build/win64_mingw-gcc/bin/geometrycRelease.exe tools/bin/windows/geometryc.exe
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 shaderc
|
||||
$(SILENT) cp .build/win64_mingw-gcc/bin/shadercRelease.exe tools/bin/windows/shaderc.exe
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturec
|
||||
$(SILENT) cp .build/win64_mingw-gcc/bin/texturecRelease.exe tools/bin/windows/texturec.exe
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturev
|
||||
$(SILENT) cp .build/win64_mingw-gcc/bin/texturevRelease.exe tools/bin/windows/texturev.exe
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 texturec
|
||||
$(SILENT) cp .build/win64_mingw-gcc/bin/texturecRelease.exe tools/bin/windows/texturec.exe
|
||||
|
||||
dist-linux: .build/projects/gmake-linux
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 geometryc
|
||||
$(SILENT) cp .build/linux64_gcc/bin/geometrycRelease tools/bin/linux/geometryc
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 shaderc
|
||||
$(SILENT) cp .build/linux64_gcc/bin/shadercRelease tools/bin/linux/shaderc
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturec
|
||||
$(SILENT) cp .build/linux64_gcc/bin/texturecRelease tools/bin/linux/texturec
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturev
|
||||
$(SILENT) cp .build/linux64_gcc/bin/texturevRelease tools/bin/linux/texturev
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-linux config=release64 -j 6 texturec
|
||||
$(SILENT) cp .build/linux64_gcc/bin/texturecRelease tools/bin/linux/texturec
|
||||
|
||||
dist-darwin: .build/projects/gmake-osx
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 geometryc
|
||||
$(SILENT) cp .build/osx64_clang/bin/geometrycRelease tools/bin/darwin/geometryc
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 shaderc
|
||||
$(SILENT) cp .build/osx64_clang/bin/shadercRelease tools/bin/darwin/shaderc
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 texturec
|
||||
$(SILENT) cp .build/osx64_clang/bin/texturecRelease tools/bin/darwin/texturec
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-osx config=release64 -j 6 texturev
|
||||
$(SILENT) cp .build/osx64_clang/bin/texturevRelease tools/bin/darwin/texturev
|
||||
dist-darwin: .build/projects/gmake-osx-x64
|
||||
$(SILENT) $(MAKE) -C .build/projects/gmake-osx-x64 config=release -j 6 texturec
|
||||
$(SILENT) cp .build/osx-x64/bin/texturecRelease tools/bin/darwin/texturec
|
||||
|
||||
dist: clean dist-windows dist-linux dist-darwin
|
||||
|
5
3rdparty/bimg/scripts/bimg.lua
vendored
5
3rdparty/bimg/scripts/bimg.lua
vendored
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
||||
-- Copyright 2010-2021 Branimir Karadzic. All rights reserved.
|
||||
-- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
|
||||
--
|
||||
|
||||
@ -11,6 +11,7 @@ project "bimg"
|
||||
path.join(BIMG_DIR, "include"),
|
||||
path.join(BIMG_DIR, "3rdparty/astc-codec"),
|
||||
path.join(BIMG_DIR, "3rdparty/astc-codec/include"),
|
||||
path.join(BIMG_DIR, "3rdparty/tinyexr/deps/miniz"),
|
||||
}
|
||||
|
||||
local ASTC_CODEC_DIR = path.join(BIMG_DIR, "3rdparty/astc-codec")
|
||||
@ -31,6 +32,8 @@ project "bimg"
|
||||
path.join(ASTC_CODEC_DIR, "src/decoder/physical_astc_block.*"),
|
||||
path.join(ASTC_CODEC_DIR, "src/decoder/quantization.*"),
|
||||
path.join(ASTC_CODEC_DIR, "src/decoder/weight_infill.*"),
|
||||
|
||||
path.join(BIMG_DIR, "3rdparty/tinyexr/deps/miniz/miniz.*"),
|
||||
}
|
||||
|
||||
configuration { "linux-*" }
|
||||
|
3
3rdparty/bimg/scripts/bimg_decode.lua
vendored
3
3rdparty/bimg/scripts/bimg_decode.lua
vendored
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
||||
-- Copyright 2010-2021 Branimir Karadzic. All rights reserved.
|
||||
-- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
|
||||
--
|
||||
|
||||
@ -10,6 +10,7 @@ project "bimg_decode"
|
||||
path.join(BX_DIR, "include"),
|
||||
path.join(BIMG_DIR, "include"),
|
||||
path.join(BIMG_DIR, "3rdparty"),
|
||||
path.join(BIMG_DIR, "3rdparty/tinyexr/deps/miniz"),
|
||||
}
|
||||
|
||||
files {
|
||||
|
16
3rdparty/bimg/scripts/bimg_encode.lua
vendored
16
3rdparty/bimg/scripts/bimg_encode.lua
vendored
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
||||
-- Copyright 2010-2021 Branimir Karadzic. All rights reserved.
|
||||
-- License: https://github.com/bkaradzic/bx#license-bsd-2-clause
|
||||
--
|
||||
|
||||
@ -12,6 +12,7 @@ project "bimg_encode"
|
||||
path.join(BIMG_DIR, "3rdparty"),
|
||||
path.join(BIMG_DIR, "3rdparty/nvtt"),
|
||||
path.join(BIMG_DIR, "3rdparty/iqa/include"),
|
||||
path.join(BIMG_DIR, "3rdparty/tinyexr/deps/miniz"),
|
||||
}
|
||||
|
||||
files {
|
||||
@ -42,4 +43,17 @@ project "bimg_encode"
|
||||
"-fPIC",
|
||||
}
|
||||
|
||||
configuration { "mingw* or linux* or osx*" }
|
||||
buildoptions {
|
||||
"-Wno-implicit-fallthrough",
|
||||
"-Wno-shadow",
|
||||
"-Wno-shift-negative-value",
|
||||
"-Wno-undef",
|
||||
}
|
||||
|
||||
buildoptions_cpp {
|
||||
"-Wno-class-memaccess",
|
||||
"-Wno-deprecated-copy",
|
||||
}
|
||||
|
||||
configuration {}
|
||||
|
2
3rdparty/bimg/scripts/genie.lua
vendored
2
3rdparty/bimg/scripts/genie.lua
vendored
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
||||
-- Copyright 2010-2021 Branimir Karadzic. All rights reserved.
|
||||
-- License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
--
|
||||
|
||||
|
4
3rdparty/bimg/scripts/texturec.lua
vendored
4
3rdparty/bimg/scripts/texturec.lua
vendored
@ -1,5 +1,5 @@
|
||||
--
|
||||
-- Copyright 2010-2019 Branimir Karadzic. All rights reserved.
|
||||
-- Copyright 2010-2021 Branimir Karadzic. All rights reserved.
|
||||
-- License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
--
|
||||
|
||||
@ -26,7 +26,7 @@ project "texturec"
|
||||
configuration { "mingw-*" }
|
||||
targetextension ".exe"
|
||||
|
||||
configuration { "osx" }
|
||||
configuration { "osx*" }
|
||||
links {
|
||||
"Cocoa.framework",
|
||||
}
|
||||
|
4
3rdparty/bimg/src/bimg_p.h
vendored
4
3rdparty/bimg/src/bimg_p.h
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
@ -14,6 +14,8 @@
|
||||
#include <bx/error.h>
|
||||
#include <bx/simd_t.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#define BIMG_CHUNK_MAGIC_TEX BX_MAKEFOURCC('T', 'E', 'X', 0x0)
|
||||
#define BIMG_CHUNK_MAGIC_GNF BX_MAKEFOURCC('G', 'N', 'F', ' ')
|
||||
|
||||
|
59
3rdparty/bimg/src/config.h
vendored
Normal file
59
3rdparty/bimg/src/config.h
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
#ifndef BIMG_CONFIG_H_HEADER_GUARD
|
||||
#define BIMG_CONFIG_H_HEADER_GUARD
|
||||
|
||||
#include <bx/bx.h>
|
||||
|
||||
#ifndef BIMG_DECODE_ENABLE
|
||||
# define BIMG_DECODE_ENABLE 1
|
||||
#endif // BIMG_DECODE_ENABLE
|
||||
|
||||
#ifndef BIMG_DECODE_BC1
|
||||
# define BIMG_DECODE_BC1 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC1
|
||||
|
||||
#ifndef BIMG_DECODE_BC2
|
||||
# define BIMG_DECODE_BC2 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC2
|
||||
|
||||
#ifndef BIMG_DECODE_BC3
|
||||
# define BIMG_DECODE_BC3 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC3
|
||||
|
||||
#ifndef BIMG_DECODE_BC4
|
||||
# define BIMG_DECODE_BC4 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC4
|
||||
|
||||
#ifndef BIMG_DECODE_BC5
|
||||
# define BIMG_DECODE_BC5 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC5
|
||||
|
||||
#ifndef BIMG_DECODE_BC6
|
||||
# define BIMG_DECODE_BC6 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC6
|
||||
|
||||
#ifndef BIMG_DECODE_BC7
|
||||
# define BIMG_DECODE_BC7 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_BC7
|
||||
|
||||
#ifndef BIMG_DECODE_ATC
|
||||
# define BIMG_DECODE_ATC BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_ATC
|
||||
|
||||
#ifndef BIMG_DECODE_ASTC
|
||||
# define BIMG_DECODE_ASTC BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_ASTC
|
||||
|
||||
#ifndef BIMG_DECODE_ETC1
|
||||
# define BIMG_DECODE_ETC1 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_ETC1
|
||||
|
||||
#ifndef BIMG_DECODE_ETC2
|
||||
# define BIMG_DECODE_ETC2 BIMG_DECODE_ENABLE
|
||||
#endif // BIMG_DECODE_ETC2
|
||||
|
||||
#endif // BIMG_CONFIG_H_HEADER_GUARD
|
1268
3rdparty/bimg/src/image.cpp
vendored
1268
3rdparty/bimg/src/image.cpp
vendored
File diff suppressed because it is too large
Load Diff
10
3rdparty/bimg/src/image_cubemap_filter.cpp
vendored
10
3rdparty/bimg/src/image_cubemap_filter.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
@ -336,15 +336,17 @@ namespace bimg
|
||||
if (_input.m_depth != 1
|
||||
&& _input.m_numLayers != 1
|
||||
&& _input.m_format != TextureFormat::RGBA32F
|
||||
&& _input.m_width/6 != _input.m_height)
|
||||
&& ( (_input.m_width != _input.m_height*6) || (_input.m_width*6 != _input.m_height) ) )
|
||||
{
|
||||
BX_ERROR_SET(_err, BIMG_ERROR, "Input image format is not strip projection.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const bool horizontal = _input.m_width == _input.m_height*6;
|
||||
const uint32_t srcPitch = _input.m_width*16;
|
||||
const uint32_t dstWidth = _input.m_height;
|
||||
const uint32_t dstWidth = horizontal ? _input.m_height : _input.m_width;
|
||||
const uint32_t dstPitch = dstWidth*16;
|
||||
const uint32_t step = horizontal ? dstPitch : dstPitch*dstWidth;
|
||||
|
||||
ImageContainer* output = imageAlloc(_allocator
|
||||
, _input.m_format
|
||||
@ -358,7 +360,7 @@ namespace bimg
|
||||
|
||||
const uint8_t* srcData = (const uint8_t*)_input.m_data;
|
||||
|
||||
for (uint8_t side = 0; side < 6 && _err->isOk(); ++side, srcData += dstPitch)
|
||||
for (uint8_t side = 0; side < 6 && _err->isOk(); ++side, srcData += step)
|
||||
{
|
||||
ImageMip dstMip;
|
||||
imageGetRawData(*output, side, 0, output->m_data, output->m_size, dstMip);
|
||||
|
158
3rdparty/bimg/src/image_decode.cpp
vendored
158
3rdparty/bimg/src/image_decode.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
@ -12,11 +12,10 @@ BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wtype-limits")
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-parameter")
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wunused-value")
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG("-Wdeprecated-declarations")
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4018) // warning C4018: '<': signed/unsigned mismatch
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4100) // error C4100: '' : unreferenced formal parameter
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4389) // warning C4389 : '==' : signed / unsigned mismatch
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4505) // warning C4505: 'tinyexr::miniz::def_realloc_func': unreferenced local function has been removed
|
||||
#if BX_PLATFORM_EMSCRIPTEN
|
||||
# include <compat/ctype.h>
|
||||
#endif // BX_PLATFORM_EMSCRIPTEN
|
||||
#define MINIZ_NO_ARCHIVE_APIS
|
||||
#define MINIZ_NO_STDIO
|
||||
#define TINYEXR_IMPLEMENTATION
|
||||
@ -25,6 +24,8 @@ BX_PRAGMA_DIAGNOSTIC_POP()
|
||||
|
||||
BX_PRAGMA_DIAGNOSTIC_PUSH();
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4127) // warning C4127: conditional expression is constant
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4267) // warning C4267: '=' : conversion from 'size_t' to 'unsigned short', possible loss of data
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_MSVC(4334) // warning C4334: '<<' : result of 32 - bit shift implicitly converted to 64 bits(was 64 - bit shift intended ? )
|
||||
#define LODEPNG_NO_COMPILE_ENCODER
|
||||
#define LODEPNG_NO_COMPILE_DISK
|
||||
#define LODEPNG_NO_COMPILE_ANCILLARY_CHUNKS
|
||||
@ -49,9 +50,11 @@ void lodepng_free(void* _ptr)
|
||||
}
|
||||
|
||||
BX_PRAGMA_DIAGNOSTIC_PUSH();
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wint-to-pointer-cast")
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wmissing-field-initializers");
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wshadow");
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wint-to-pointer-cast")
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_CLANG_GCC("-Wsign-compare");
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wunused-but-set-variable");
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Warray-bounds");
|
||||
#if BX_COMPILER_GCC >= 60000
|
||||
BX_PRAGMA_DIAGNOSTIC_IGNORED_GCC("-Wmisleading-indentation");
|
||||
@ -107,8 +110,8 @@ namespace bimg
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
format = bimg::TextureFormat::R8;
|
||||
palette = false;
|
||||
palette = LCT_PALETTE == state.info_raw.colortype;
|
||||
format = palette ? bimg::TextureFormat::RGBA8 : bimg::TextureFormat::R8;
|
||||
supported = true;
|
||||
break;
|
||||
|
||||
@ -140,6 +143,9 @@ namespace bimg
|
||||
palette = true;
|
||||
supported = true;
|
||||
break;
|
||||
|
||||
case LCT_MAX_OCTET_VALUE:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -194,6 +200,9 @@ namespace bimg
|
||||
|
||||
case LCT_PALETTE:
|
||||
break;
|
||||
|
||||
case LCT_MAX_OCTET_VALUE:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -206,7 +215,10 @@ namespace bimg
|
||||
const uint8_t* copyData = data;
|
||||
|
||||
TextureFormat::Enum dstFormat = format;
|
||||
if (1 == state.info_raw.bitdepth
|
||||
if (palette) {
|
||||
copyData = NULL;
|
||||
}
|
||||
else if (1 == state.info_raw.bitdepth
|
||||
|| 2 == state.info_raw.bitdepth
|
||||
|| 4 == state.info_raw.bitdepth)
|
||||
{
|
||||
@ -218,10 +230,6 @@ namespace bimg
|
||||
dstFormat = bimg::TextureFormat::RGBA16;
|
||||
copyData = NULL;
|
||||
}
|
||||
else if (palette)
|
||||
{
|
||||
copyData = NULL;
|
||||
}
|
||||
|
||||
output = imageAlloc(_allocator
|
||||
, dstFormat
|
||||
@ -234,7 +242,48 @@ namespace bimg
|
||||
, copyData
|
||||
);
|
||||
|
||||
if (1 == state.info_raw.bitdepth)
|
||||
if (palette)
|
||||
{
|
||||
if (1 == state.info_raw.bitdepth) {
|
||||
for (uint32_t ii = 0, num = width*height/8; ii < num; ++ii)
|
||||
{
|
||||
uint8_t* dst = (uint8_t*)output->m_data + ii*32;
|
||||
bx::memCopy(dst, state.info_raw.palette + ( (data[ii]>>7)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 4, state.info_raw.palette + ( (data[ii]>>6)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 8, state.info_raw.palette + ( (data[ii]>>5)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 12, state.info_raw.palette + ( (data[ii]>>4)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 16, state.info_raw.palette + ( (data[ii]>>3)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 20, state.info_raw.palette + ( (data[ii]>>2)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 24, state.info_raw.palette + ( (data[ii]>>1)&0x1)*4, 4);
|
||||
bx::memCopy(dst + 28, state.info_raw.palette + ( data[ii] &0x1)*4, 4);
|
||||
}
|
||||
}
|
||||
else if (2 == state.info_raw.bitdepth) {
|
||||
for (uint32_t ii = 0, num = width*height/4; ii < num; ++ii)
|
||||
{
|
||||
uint8_t* dst = (uint8_t*)output->m_data + ii*16;
|
||||
bx::memCopy(dst, state.info_raw.palette + ( (data[ii]>>6)&0x3)*4, 4);
|
||||
bx::memCopy(dst + 4, state.info_raw.palette + ( (data[ii]>>4)&0x3)*4, 4);
|
||||
bx::memCopy(dst + 8, state.info_raw.palette + ( (data[ii]>>2)&0x3)*4, 4);
|
||||
bx::memCopy(dst + 12, state.info_raw.palette + ( data[ii] &0x3)*4, 4);
|
||||
}
|
||||
}
|
||||
else if (4 == state.info_raw.bitdepth) {
|
||||
for (uint32_t ii = 0, num = width*height/2; ii < num; ++ii)
|
||||
{
|
||||
uint8_t* dst = (uint8_t*)output->m_data + ii*8;
|
||||
bx::memCopy(dst, state.info_raw.palette + ( (data[ii]>>4)&0xf)*4, 4);
|
||||
bx::memCopy(dst + 4, state.info_raw.palette + ( data[ii] &0xf)*4, 4);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
|
||||
{
|
||||
bx::memCopy( (uint8_t*)output->m_data + ii*4, state.info_raw.palette + data[ii]*4, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (1 == state.info_raw.bitdepth)
|
||||
{
|
||||
for (uint32_t ii = 0, num = width*height/8; ii < num; ++ii)
|
||||
{
|
||||
@ -296,12 +345,77 @@ namespace bimg
|
||||
dst[3] = UINT16_MAX;
|
||||
}
|
||||
}
|
||||
else if (palette)
|
||||
|
||||
switch (state.info_raw.colortype) //Check for alpha values
|
||||
{
|
||||
for (uint32_t ii = 0, num = width*height; ii < num; ++ii)
|
||||
{
|
||||
bx::memCopy( (uint8_t*)output->m_data + ii*4, state.info_raw.palette + data[ii]*4, 4);
|
||||
}
|
||||
case LCT_GREY:
|
||||
case LCT_RGB:
|
||||
break;
|
||||
|
||||
case LCT_GREY_ALPHA:
|
||||
if (8 == state.info_raw.bitdepth)
|
||||
{
|
||||
for (uint32_t ii = 0, num = width * height; ii < num; ++ii)
|
||||
{
|
||||
const uint8_t* rgba = (uint8_t*)data + ii * 2;
|
||||
bool has_alpha = rgba[1] < UINT8_MAX;
|
||||
if (has_alpha)
|
||||
{
|
||||
output->m_hasAlpha = has_alpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(16 == state.info_raw.bitdepth)
|
||||
{
|
||||
for (uint32_t ii = 0, num = width * height; ii < num; ++ii)
|
||||
{
|
||||
const uint16_t* rgba = (uint16_t*)data + ii * 2;
|
||||
bool has_alpha = rgba[1] < UINT16_MAX;
|
||||
if (has_alpha)
|
||||
{
|
||||
output->m_hasAlpha = has_alpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LCT_RGBA:
|
||||
if (8 == state.info_raw.bitdepth)
|
||||
{
|
||||
for (uint32_t ii = 0, num = width * height; ii < num; ++ii)
|
||||
{
|
||||
const uint8_t* dst = (uint8_t*)output->m_data + ii * 4;
|
||||
bool has_alpha = dst[3] < UINT8_MAX;
|
||||
if (has_alpha)
|
||||
{
|
||||
output->m_hasAlpha = has_alpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (16 == state.info_raw.bitdepth)
|
||||
{
|
||||
for (uint32_t ii = 0, num = width * height; ii < num; ++ii)
|
||||
{
|
||||
const uint16_t* dst = (uint16_t*)output->m_data + ii * 4;
|
||||
bool has_alpha = dst[3] < UINT16_MAX;
|
||||
if (has_alpha)
|
||||
{
|
||||
output->m_hasAlpha = has_alpha;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case LCT_PALETTE:
|
||||
output->m_hasAlpha = lodepng_has_palette_alpha(&state.info_raw);
|
||||
break;
|
||||
|
||||
case LCT_MAX_OCTET_VALUE:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -331,6 +445,8 @@ namespace bimg
|
||||
uint32_t width = 0;
|
||||
uint32_t height = 0;
|
||||
|
||||
bool hasAlpha = false;
|
||||
|
||||
uint8_t* data = NULL;
|
||||
const char* err = NULL;
|
||||
EXRHeader exrHeader;
|
||||
@ -431,6 +547,8 @@ namespace bimg
|
||||
};
|
||||
bx::memCopy(&data[ii * bytesPerPixel], rgba, bytesPerPixel);
|
||||
|
||||
hasAlpha |= (hasAlpha || rgba[3] < 1.0f);
|
||||
|
||||
srcR += stepR;
|
||||
srcG += stepG;
|
||||
srcB += stepB;
|
||||
@ -457,6 +575,8 @@ namespace bimg
|
||||
};
|
||||
bx::memCopy(&data[ii * bytesPerPixel], rgba, bytesPerPixel);
|
||||
|
||||
hasAlpha |= (hasAlpha || rgba[3] < UINT16_MAX);
|
||||
|
||||
srcR += stepR;
|
||||
srcG += stepG;
|
||||
srcB += stepB;
|
||||
@ -512,8 +632,10 @@ namespace bimg
|
||||
, data
|
||||
);
|
||||
BX_FREE(_allocator, data);
|
||||
output->m_hasAlpha = hasAlpha;
|
||||
}
|
||||
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
2
3rdparty/bimg/src/image_encode.cpp
vendored
2
3rdparty/bimg/src/image_encode.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
|
2
3rdparty/bimg/src/image_gnf.cpp
vendored
2
3rdparty/bimg/src/image_gnf.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
|
47
3rdparty/bimg/tools/texturec/texturec.cpp
vendored
47
3rdparty/bimg/tools/texturec/texturec.cpp
vendored
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2019 Branimir Karadzic. All rights reserved.
|
||||
* Copyright 2011-2021 Branimir Karadzic. All rights reserved.
|
||||
* License: https://github.com/bkaradzic/bimg#license-bsd-2-clause
|
||||
*/
|
||||
|
||||
@ -195,20 +195,19 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
}
|
||||
else if (_options.strip)
|
||||
{
|
||||
if (outputDepth == 1
|
||||
&& outputWidth/6 == outputHeight)
|
||||
if (outputDepth == 1
|
||||
&& ( (outputWidth == outputHeight*6) || (outputWidth*6 == outputHeight) ) )
|
||||
{
|
||||
if (outputWidth/6 > _options.maxSize)
|
||||
{
|
||||
outputWidth = _options.maxSize*6;
|
||||
outputHeight = _options.maxSize;
|
||||
}
|
||||
const bool horizontal = outputWidth == outputHeight*6;
|
||||
|
||||
outputWidth = bx::min(outputWidth, horizontal ? _options.maxSize*6 : _options.maxSize);
|
||||
outputHeight = bx::min(outputHeight, horizontal ? _options.maxSize : _options.maxSize*6);
|
||||
}
|
||||
else
|
||||
{
|
||||
bimg::imageFree(input);
|
||||
|
||||
BX_ERROR_SET(_err, TEXTRUREC_ERROR, "Input image format is not horizontal strip.");
|
||||
BX_ERROR_SET(_err, TEXTRUREC_ERROR, "Input image format is not horizontal or vertical strip.");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -325,7 +324,7 @@ bimg::ImageContainer* convert(bx::AllocatorI* _allocator, const void* _inputData
|
||||
|
||||
bimg::ImageContainer* dst;
|
||||
|
||||
if (outputWidth/2 == outputHeight)
|
||||
if (outputWidth == outputHeight*2)
|
||||
{
|
||||
dst = bimg::imageCubemapFromLatLongRgba32F(_allocator, *src, true, _err);
|
||||
bimg::imageFree(src);
|
||||
@ -897,7 +896,7 @@ void help(const char* _error = NULL, bool _showHelp = true)
|
||||
|
||||
bx::printf(
|
||||
"texturec, bgfx texture compiler tool, version %d.%d.%d.\n"
|
||||
"Copyright 2011-2019 Branimir Karadzic. All rights reserved.\n"
|
||||
"Copyright 2011-2021 Branimir Karadzic. All rights reserved.\n"
|
||||
"License: https://github.com/bkaradzic/bimg#license-bsd-2-clause\n\n"
|
||||
, BIMG_TEXTUREC_VERSION_MAJOR
|
||||
, BIMG_TEXTUREC_VERSION_MINOR
|
||||
@ -931,16 +930,16 @@ void help(const char* _error = NULL, bool _showHelp = true)
|
||||
" -q <quality> Encoding quality (default, fastest, highest).\n"
|
||||
" -m, --mips Generate mip-maps.\n"
|
||||
" --mipskip <N> Skip <N> number of mips.\n"
|
||||
" -n, --normalmap Input texture is normal map.\n"
|
||||
" -n, --normalmap Input texture is normal map. (Implies --linear)\n"
|
||||
" --equirect Input texture is equirectangular projection of cubemap.\n"
|
||||
" --strip Input texture is horizontal strip of cubemap.\n"
|
||||
" --strip Input texture is horizontal or vertical strip of cubemap.\n"
|
||||
" --sdf Compute SDF texture.\n"
|
||||
" --ref <alpha> Alpha reference value.\n"
|
||||
" --iqa Image Quality Assessment\n"
|
||||
" --pma Premultiply alpha into RGB channel.\n"
|
||||
" --linear Input and output texture is linear color space (gamma correction won't be applied).\n"
|
||||
" --max <max size> Maximum width/height (image will be scaled down and\n"
|
||||
" aspect ratio will be preserved.\n"
|
||||
" aspect ratio will be preserved)\n"
|
||||
" --radiance <model> Radiance cubemap filter. (Lighting model: Phong, PhongBrdf, Blinn, BlinnBrdf, GGX)\n"
|
||||
" --as <extension> Save as.\n"
|
||||
" --formats List all supported formats.\n"
|
||||
@ -951,17 +950,19 @@ void help(const char* _error = NULL, bool _showHelp = true)
|
||||
);
|
||||
}
|
||||
|
||||
void help(const char* _str, const bx::Error& _err)
|
||||
void help(const bx::StringView _str, const bx::Error& _err)
|
||||
{
|
||||
std::string str;
|
||||
if (_str != NULL)
|
||||
if (!_str.isEmpty() )
|
||||
{
|
||||
str.append(_str);
|
||||
str.append(" ");
|
||||
str.append(_str.getPtr(), _str.getTerm() - _str.getPtr() );
|
||||
str.append(": ");
|
||||
}
|
||||
|
||||
const bx::StringView& sv = _err.getMessage();
|
||||
str.append("'");
|
||||
str.append(sv.getPtr(), sv.getTerm() - sv.getPtr() );
|
||||
str.append("'");
|
||||
|
||||
help(str.c_str(), false);
|
||||
}
|
||||
@ -1089,6 +1090,12 @@ int main(int _argc, const char* _argv[])
|
||||
return bx::kExitFailure;
|
||||
}
|
||||
|
||||
// Normal maps are always linear
|
||||
if (options.normalMap)
|
||||
{
|
||||
options.linear = true;
|
||||
}
|
||||
|
||||
const char* maxSize = cmdLine.findOption("max");
|
||||
if (NULL != maxSize)
|
||||
{
|
||||
@ -1213,6 +1220,8 @@ int main(int _argc, const char* _argv[])
|
||||
|
||||
if (NULL != output)
|
||||
{
|
||||
output->m_srgb = !options.linear;
|
||||
|
||||
bx::FileWriter writer;
|
||||
if (bx::open(&writer, outputFileName, false, &err) )
|
||||
{
|
||||
@ -1277,7 +1286,7 @@ int main(int _argc, const char* _argv[])
|
||||
|
||||
if (!err.isOk() )
|
||||
{
|
||||
help(NULL, err);
|
||||
help("", err);
|
||||
return bx::kExitFailure;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user