| 1 | // File: rg_etc1.h - Fast, high quality ETC1 block packer/unpacker - Rich Geldreich <[email protected]>cxx . . $ `<file>/extern/rg_etc1_v104/rg_etc1.h`/ |
| 2 | // Please see ZLIB license at the end of this file. |
| 3 | #pragma once |
| 4 | |
| 5 | namespace rg_etc1cxx . . $ rg_etc1/ |
| 6 | { |
| 7 | // Unpacks an 8-byte ETC1 compressed block to a block of 4x4 32bpp RGBA pixels. |
| 8 | // Returns false if the block is invalid. Invalid blocks will still be unpacked with clamping. |
| 9 | // This function is thread safe, and does not dynamically allocate any memory. |
| 10 | // If preserve_alpha is true, the alpha channel of the destination pixels will not be overwritten. Otherwise, alpha will be set to 255. |
| 11 | bool unpack_etc1_blockcxx . . $ rg_etc1/unpack_etc1_block(d717e89c9ce4488b).(const void *pETC1_block, unsigned int* pDst_pixels_rgba, bool preserve_alpha = false); |
| 12 | |
| 13 | // Quality setting = the higher the quality, the slower. |
| 14 | // To pack large textures, it is highly recommended to call pack_etc1_block() in parallel, on different blocks, from multiple threads (particularly when using cHighQuality). |
| 15 | enum etc1_qualitycxx . . $ rg_etc1/etc1_quality# |
| 16 | { |
| 17 | cLowQualitycxx . . $ rg_etc1/cLowQuality., |
| 18 | cMediumQualitycxx . . $ rg_etc1/cMediumQuality., |
| 19 | cHighQualitycxx . . $ rg_etc1/cHighQuality., |
| 20 | }; |
| 21 | |
| 22 | struct etc1_pack_paramscxx . . $ rg_etc1/etc1_pack_params# |
| 23 | { |
| 24 | etc1_qualitycxx . . $ rg_etc1/etc1_quality# m_qualitycxx . . $ rg_etc1/etc1_pack_params#m_quality.; |
| 25 | bool m_ditheringcxx . . $ rg_etc1/etc1_pack_params#m_dithering.; |
| 26 | |
| 27 | inline etc1_pack_paramscxx . . $ rg_etc1/etc1_pack_params#etc1_pack_params(49f6e7a06ebc5aa8).() |
| 28 | { |
| 29 | clearcxx . . $ rg_etc1/etc1_pack_params#clear(49f6e7a06ebc5aa8).(); |
| 30 | } |
| 31 | |
| 32 | void clearcxx . . $ rg_etc1/etc1_pack_params#clear(49f6e7a06ebc5aa8).() |
| 33 | { |
| 34 | m_qualitycxx . . $ rg_etc1/etc1_pack_params#m_quality. = cHighQualitycxx . . $ rg_etc1/cHighQuality.; |
| 35 | m_ditheringcxx . . $ rg_etc1/etc1_pack_params#m_dithering. = false; |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | // Important: pack_etc1_block_init() must be called before calling pack_etc1_block(). |
| 40 | void pack_etc1_block_initcxx . . $ rg_etc1/pack_etc1_block_init(49f6e7a06ebc5aa8).(); |
| 41 | |
| 42 | // Packs a 4x4 block of 32bpp RGBA pixels to an 8-byte ETC1 block. |
| 43 | // 32-bit RGBA pixels must always be arranged as (R,G,B,A) (R first, A last) in memory, independent of platform endianness. A should always be 255. |
| 44 | // Returns squared error of result. |
| 45 | // This function is thread safe, and does not dynamically allocate any memory. |
| 46 | // pack_etc1_block() does not currently support "perceptual" colorspace metrics - it primarily optimizes for RGB RMSE. |
| 47 | unsigned int pack_etc1_blockcxx . . $ rg_etc1/pack_etc1_block(98d6bbb97bd1b72).(void* pETC1_block, const unsigned int* pSrc_pixels_rgba, etc1_pack_paramscxx . . $ rg_etc1/etc1_pack_params#& pack_params); |
| 48 | |
| 49 | } // namespace rg_etc1 |
| 50 | |
| 51 | //------------------------------------------------------------------------------ |
| 52 | // |
| 53 | // rg_etc1 uses the ZLIB license: |
| 54 | // http://opensource.org/licenses/Zlib |
| 55 | // |
| 56 | // Copyright (c) 2012 Rich Geldreich |
| 57 | // |
| 58 | // This software is provided 'as-is', without any express or implied |
| 59 | // warranty. In no event will the authors be held liable for any damages |
| 60 | // arising from the use of this software. |
| 61 | // |
| 62 | // Permission is granted to anyone to use this software for any purpose, |
| 63 | // including commercial applications, and to alter it and redistribute it |
| 64 | // freely, subject to the following restrictions: |
| 65 | // |
| 66 | // 1. The origin of this software must not be misrepresented; you must not |
| 67 | // claim that you wrote the original software. If you use this software |
| 68 | // in a product, an acknowledgment in the product documentation would be |
| 69 | // appreciated but is not required. |
| 70 | // |
| 71 | // 2. Altered source versions must be plainly marked as such, and must not be |
| 72 | // misrepresented as being the original software. |
| 73 | // |
| 74 | // 3. This notice may not be removed or altered from any source distribution. |
| 75 | // |
| 76 | //------------------------------------------------------------------------------ |