summaryrefslogtreecommitdiff
path: root/src/static_libs/rg_etc/rg_etc1.h
diff options
context:
space:
mode:
authorMythri Venugopal <mythri.venugopal@samsung.com>2014-02-13 10:13:29 +0900
committerCedric BAIL <cedric.bail@free.fr>2014-04-01 22:00:13 +0900
commitebd318792392ea0bf6093794175b7f191199b6f0 (patch)
tree8f8960403082d4b7dca86eb0c41ff095d3e3ac5d /src/static_libs/rg_etc/rg_etc1.h
parent2cac84f56794bfdff45002099f6c9d95376eff8a (diff)
rg_etc: convert code to C to fit in EFL tree.
Diffstat (limited to 'src/static_libs/rg_etc/rg_etc1.h')
-rw-r--r--src/static_libs/rg_etc/rg_etc1.h73
1 files changed, 31 insertions, 42 deletions
diff --git a/src/static_libs/rg_etc/rg_etc1.h b/src/static_libs/rg_etc/rg_etc1.h
index 9ce89a6cc6..af887013a5 100644
--- a/src/static_libs/rg_etc/rg_etc1.h
+++ b/src/static_libs/rg_etc/rg_etc1.h
@@ -1,52 +1,40 @@
1// File: rg_etc1.h - Fast, high quality ETC1 block packer/unpacker - Rich Geldreich <richgel99@gmail.com> 1// File: rg_etc1.h - Fast, high quality ETC1 block packer/unpacker - Rich Geldreich <richgel99@gmail.com>
2// Please see ZLIB license at the end of this file. 2// Please see ZLIB license at the end of this file.
3#pragma once 3#ifndef __RG_ETC1_H__
4#define __RG_ETC1_H__
4 5
5namespace rg_etc1 6typedef unsigned char bool;
6{ 7
7 // Unpacks an 8-byte ETC1 compressed block to a block of 4x4 32bpp RGBA pixels. 8// 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// 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// 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// 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_block(const void *pETC1_block, unsigned int* pDst_pixels_rgba, bool preserve_alpha = false); 12bool rg_etc1_unpack_block(const void *pETC1_block, unsigned int* pDst_pixels_rgba, bool preserve_alpha);
12 13
13 // Quality setting = the higher the quality, the slower. 14// 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// 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_quality 16typedef enum {
16 { 17 rg_etc1_low_quality,
17 cLowQuality, 18 rg_etc1_medium_quality,
18 cMediumQuality, 19 rg_etc1_high_quality
19 cHighQuality, 20} rg_etc1_quality;
20 };
21
22 struct etc1_pack_params
23 {
24 etc1_quality m_quality;
25 bool m_dithering;
26
27 inline etc1_pack_params()
28 {
29 clear();
30 }
31 21
32 void clear()
33 {
34 m_quality = cHighQuality;
35 m_dithering = false;
36 }
37 };
38 22
39 // Important: pack_etc1_block_init() must be called before calling pack_etc1_block(). 23typedef struct
40 void pack_etc1_block_init(); 24{
25 rg_etc1_quality m_quality;
26 bool m_dithering;
27}rg_etc1_pack_params;
28
29// Important: pack_etc1_block_init() must be called before calling pack_etc1_block().
30void rg_etc1_pack_block_init();
41 31
42 // Packs a 4x4 block of 32bpp RGBA pixels to an 8-byte ETC1 block. 32// 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. 33// 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. 34// Returns squared error of result.
45 // This function is thread safe, and does not dynamically allocate any memory. 35// 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. 36// pack_etc1_block() does not currently support "perceptual" colorspace metrics - it primarily optimizes for RGB RMSE.
47 unsigned int pack_etc1_block(void* pETC1_block, const unsigned int* pSrc_pixels_rgba, etc1_pack_params& pack_params); 37unsigned int rg_etc1_pack_block(void* pETC1_block, const unsigned int* pSrc_pixels_rgba, rg_etc1_pack_params *pack_params);
48
49} // namespace rg_etc1
50 38
51//------------------------------------------------------------------------------ 39//------------------------------------------------------------------------------
52// 40//
@@ -74,3 +62,4 @@ namespace rg_etc1
74// 3. This notice may not be removed or altered from any source distribution. 62// 3. This notice may not be removed or altered from any source distribution.
75// 63//
76//------------------------------------------------------------------------------ 64//------------------------------------------------------------------------------
65#endif // __RG_ETC1_H__