facebook360_dep
Facebook360 Depth Estimation Pipeline
ispc_texcomp.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2019, Intel Corporation
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
20 // IN THE SOFTWARE.
22 
23 #include <stdint.h>
24 
26 {
27  uint8_t* ptr;
28  int32_t width;
29  int32_t height;
30  int32_t stride; // in bytes
31 };
32 
34 {
35  bool mode_selection[4];
37 
38  bool skip_mode2;
42 
45 
46  int channels;
47 };
48 
50 {
51  bool slow_mode;
52  bool fast_mode;
56 };
57 
59 {
61 };
62 
64 {
67  int channels;
68 
71 };
72 
73 // profiles for RGB data (alpha channel will be ignored)
74 extern "C" void GetProfile_ultrafast(bc7_enc_settings* settings);
75 extern "C" void GetProfile_veryfast(bc7_enc_settings* settings);
76 extern "C" void GetProfile_fast(bc7_enc_settings* settings);
77 extern "C" void GetProfile_basic(bc7_enc_settings* settings);
78 extern "C" void GetProfile_slow(bc7_enc_settings* settings);
79 
80 // profiles for RGBA inputs
81 extern "C" void GetProfile_alpha_ultrafast(bc7_enc_settings* settings);
82 extern "C" void GetProfile_alpha_veryfast(bc7_enc_settings* settings);
83 extern "C" void GetProfile_alpha_fast(bc7_enc_settings* settings);
84 extern "C" void GetProfile_alpha_basic(bc7_enc_settings* settings);
85 extern "C" void GetProfile_alpha_slow(bc7_enc_settings* settings);
86 
87 // profiles for BC6H (RGB HDR)
88 extern "C" void GetProfile_bc6h_veryfast(bc6h_enc_settings* settings);
89 extern "C" void GetProfile_bc6h_fast(bc6h_enc_settings* settings);
90 extern "C" void GetProfile_bc6h_basic(bc6h_enc_settings* settings);
91 extern "C" void GetProfile_bc6h_slow(bc6h_enc_settings* settings);
92 extern "C" void GetProfile_bc6h_veryslow(bc6h_enc_settings* settings);
93 
94 // profiles for ETC
95 extern "C" void GetProfile_etc_slow(etc_enc_settings* settings);
96 
97 // profiles for ASTC
98 extern "C" void GetProfile_astc_fast(astc_enc_settings* settings, int block_width, int block_height);
99 extern "C" void GetProfile_astc_alpha_fast(astc_enc_settings* settings, int block_width, int block_height);
100 extern "C" void GetProfile_astc_alpha_slow(astc_enc_settings* settings, int block_width, int block_height);
101 
102 // helper function to replicate border pixels for the desired block sizes (bpp = 32 or 64)
103 extern "C" void ReplicateBorders(rgba_surface* dst_slice, const rgba_surface* src_tex, int x, int y, int bpp);
104 
105 /*
106 Notes:
107  - input width and height need to be a multiple of block size
108  - LDR input is 32 bit/pixel (sRGB), HDR is 64 bit/pixel (half float)
109  - dst buffer must be allocated with enough space for the compressed texture:
110  - 8 bytes/block for BC1/ETC1,
111  - 16 bytes/block for BC3/BC6H/BC7/ASTC
112  - the blocks are stored in raster scan order (natural CPU texture layout)
113  - use the GetProfile_* functions to select various speed/quality tradeoffs
114  - the RGB profiles are slightly faster as they ignore the alpha channel
115 */
116 
117 extern "C" void CompressBlocksBC1(const rgba_surface* src, uint8_t* dst);
118 extern "C" void CompressBlocksBC3(const rgba_surface* src, uint8_t* dst);
119 extern "C" void CompressBlocksBC6H(const rgba_surface* src, uint8_t* dst, bc6h_enc_settings* settings);
120 extern "C" void CompressBlocksBC7(const rgba_surface* src, uint8_t* dst, bc7_enc_settings* settings);
121 extern "C" void CompressBlocksETC1(const rgba_surface* src, uint8_t* dst, etc_enc_settings* settings);
122 extern "C" void CompressBlocksASTC(const rgba_surface* src, uint8_t* dst, astc_enc_settings* settings);
void CompressBlocksASTC(const rgba_surface *src, uint8_t *dst, astc_enc_settings *settings)
Definition: ispc_texcomp_astc.cpp:498
int fastSkipTreshold_mode7
Definition: ispc_texcomp.h:41
int fastSkipTreshold
Definition: ispc_texcomp.h:60
int fastSkipTreshold
Definition: ispc_texcomp.h:69
void GetProfile_alpha_slow(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:338
void GetProfile_alpha_basic(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:303
void ReplicateBorders(rgba_surface *dst_slice, const rgba_surface *src_tex, int x, int y, int bpp)
Definition: ispc_texcomp.cpp:424
void CompressBlocksBC3(const rgba_surface *src, uint8_t *dst)
Definition: ispc_texcomp.cpp:454
void GetProfile_bc6h_fast(bc6h_enc_settings *settings)
Definition: ispc_texcomp.cpp:383
void CompressBlocksETC1(const rgba_surface *src, uint8_t *dst, etc_enc_settings *settings)
Definition: ispc_texcomp.cpp:469
bool mode_selection[4]
Definition: ispc_texcomp.h:35
void GetProfile_alpha_veryfast(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:233
int refineIterations_1p
Definition: ispc_texcomp.h:53
void CompressBlocksBC1(const rgba_surface *src, uint8_t *dst)
Definition: ispc_texcomp.cpp:449
bool slow_mode
Definition: ispc_texcomp.h:51
int refineIterations[8]
Definition: ispc_texcomp.h:36
Definition: ispc_texcomp.h:33
void GetProfile_astc_fast(astc_enc_settings *settings, int block_width, int block_height)
Definition: ispc_texcomp_astc.cpp:24
Definition: ispc_texcomp.h:58
int mode45_channel0
Definition: ispc_texcomp.h:43
int block_height
Definition: ispc_texcomp.h:66
void GetProfile_etc_slow(etc_enc_settings *settings)
Definition: ispc_texcomp.cpp:419
int refineIterations
Definition: ispc_texcomp.h:70
void GetProfile_basic(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:129
void GetProfile_astc_alpha_slow(astc_enc_settings *settings, int block_width, int block_height)
Definition: ispc_texcomp_astc.cpp:44
Definition: ispc_texcomp.h:49
int32_t stride
Definition: ispc_texcomp.h:30
void GetProfile_slow(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:163
int channels
Definition: ispc_texcomp.h:67
void GetProfile_bc6h_veryslow(bc6h_enc_settings *settings)
Definition: ispc_texcomp.cpp:410
int32_t width
Definition: ispc_texcomp.h:28
int fastSkipTreshold
Definition: ispc_texcomp.h:55
void GetProfile_bc6h_veryfast(bc6h_enc_settings *settings)
Definition: ispc_texcomp.cpp:374
void GetProfile_alpha_fast(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:268
int block_width
Definition: ispc_texcomp.h:65
bool skip_mode2
Definition: ispc_texcomp.h:38
void CompressBlocksBC6H(const rgba_surface *src, uint8_t *dst, bc6h_enc_settings *settings)
Definition: ispc_texcomp.cpp:464
int fastSkipTreshold_mode3
Definition: ispc_texcomp.h:40
int fastSkipTreshold_mode1
Definition: ispc_texcomp.h:39
void GetProfile_astc_alpha_fast(astc_enc_settings *settings, int block_width, int block_height)
Definition: ispc_texcomp_astc.cpp:34
void GetProfile_bc6h_basic(bc6h_enc_settings *settings)
Definition: ispc_texcomp.cpp:392
void GetProfile_veryfast(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:61
void CompressBlocksBC7(const rgba_surface *src, uint8_t *dst, bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:459
int refineIterations_2p
Definition: ispc_texcomp.h:54
Definition: ispc_texcomp.h:63
void GetProfile_fast(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:95
bool fast_mode
Definition: ispc_texcomp.h:52
int refineIterations_channel
Definition: ispc_texcomp.h:44
Definition: ispc_texcomp.h:25
void GetProfile_alpha_ultrafast(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:198
uint8_t * ptr
Definition: ispc_texcomp.h:27
void GetProfile_ultrafast(bc7_enc_settings *settings)
Definition: ispc_texcomp.cpp:27
int32_t height
Definition: ispc_texcomp.h:29
void GetProfile_bc6h_slow(bc6h_enc_settings *settings)
Definition: ispc_texcomp.cpp:401
int channels
Definition: ispc_texcomp.h:46