| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef _DFD_H_ |
| 19 |
#define _DFD_H_ |
| 20 |
|
| 21 |
#include <KHR/khr_df.h> |
| 22 |
#include <stdbool.h> |
| 23 |
|
| 24 |
#ifdef __cplusplus |
| 25 |
extern "C" { |
| 26 |
#endif |
| 27 |
|
| 28 |
|
| 29 |
enum VkSuffix { |
| 30 |
s_UNORM, |
| 31 |
s_SNORM, |
| 32 |
s_USCALED, |
| 33 |
s_SSCALED, |
| 34 |
s_UINT, |
| 35 |
s_SINT, |
| 36 |
s_SFLOAT, |
| 37 |
s_UFLOAT, |
| 38 |
s_SRGB, |
| 39 |
s_SFIXED5 |
| 40 |
}; |
| 41 |
|
| 42 |
|
| 43 |
enum VkCompScheme { |
| 44 |
c_BC1_RGB, |
| 45 |
c_BC1_RGBA, |
| 46 |
c_BC2, |
| 47 |
c_BC3, |
| 48 |
c_BC4, |
| 49 |
c_BC5, |
| 50 |
c_BC6H, |
| 51 |
c_BC7, |
| 52 |
c_ETC2_R8G8B8, |
| 53 |
c_ETC2_R8G8B8A1, |
| 54 |
c_ETC2_R8G8B8A8, |
| 55 |
c_EAC_R11, |
| 56 |
c_EAC_R11G11, |
| 57 |
c_ASTC, |
| 58 |
c_ETC1S, |
| 59 |
c_PVRTC, |
| 60 |
c_PVRTC2 |
| 61 |
}; |
| 62 |
|
| 63 |
typedef unsigned int uint32_t; |
| 64 |
|
| 65 |
#if !defined(LIBKTX) |
| 66 |
#include <vulkan/vulkan_core.h> |
| 67 |
#else |
| 68 |
#include "../../lib/vkformat_enum.h" |
| 69 |
#endif |
| 70 |
|
| 71 |
uint32_t* vk2dfd(enum VkFormat format); |
| 72 |
enum VkFormat dfd2vk(uint32_t* dfd); |
| 73 |
|
| 74 |
|
| 75 |
uint32_t *createDFDUnpacked(int bigEndian, int numChannels, int bytes, |
| 76 |
int redBlueSwap, enum VkSuffix suffix); |
| 77 |
|
| 78 |
|
| 79 |
uint32_t *createDFDPackedShifted(int bigEndian, int numChannels, |
| 80 |
int bits[], int shiftBits[], |
| 81 |
int channels[], enum VkSuffix suffix); |
| 82 |
|
| 83 |
|
| 84 |
uint32_t *createDFDPacked(int bigEndian, int numChannels, |
| 85 |
int bits[], int channels[], |
| 86 |
enum VkSuffix suffix); |
| 87 |
|
| 88 |
|
| 89 |
uint32_t *createDFD422(int bigEndian, int numChannels, |
| 90 |
int bits[], int shiftBits[], int channels[], |
| 91 |
int position_xs[], int position_ys[], |
| 92 |
enum VkSuffix suffix); |
| 93 |
|
| 94 |
|
| 95 |
uint32_t *createDFDCompressed(enum VkCompScheme compScheme, |
| 96 |
int bwidth, int bheight, int bdepth, |
| 97 |
enum VkSuffix suffix); |
| 98 |
|
| 99 |
|
| 100 |
uint32_t *createDFDDepthStencil(int depthBits, |
| 101 |
int stencilBits, |
| 102 |
int sizeBytes); |
| 103 |
|
| 104 |
|
| 105 |
uint32_t *createDFDAlpha(int bigEndian, int bytes, |
| 106 |
enum VkSuffix suffix); |
| 107 |
|
| 108 |
|
| 109 |
enum InterpretDFDResult { |
| 110 |
i_LITTLE_ENDIAN_FORMAT_BIT = 0, |
| 111 |
i_BIG_ENDIAN_FORMAT_BIT = 1u << 0u, |
| 112 |
i_PACKED_FORMAT_BIT = 1u << 1u, |
| 113 |
i_SRGB_FORMAT_BIT = 1u << 2u, |
| 114 |
i_NORMALIZED_FORMAT_BIT = 1u << 3u, |
| 115 |
i_SIGNED_FORMAT_BIT = 1u << 4u, |
| 116 |
i_FIXED_FORMAT_BIT = 1u << 5u, |
| 117 |
i_FLOAT_FORMAT_BIT = 1u << 6u, |
| 118 |
i_COMPRESSED_FORMAT_BIT = 1u << 7u, |
| 119 |
i_YUVSDA_FORMAT_BIT = 1u << 8u, |
| 120 |
i_UNSUPPORTED_ERROR_BIT = 1u << 9u, |
| 121 |
|
| 122 |
|
| 123 |
i_UNSUPPORTED_NONTRIVIAL_ENDIANNESS = i_UNSUPPORTED_ERROR_BIT, |
| 124 |
|
| 125 |
|
| 126 |
i_UNSUPPORTED_MULTIPLE_SAMPLE_LOCATIONS = i_UNSUPPORTED_ERROR_BIT + 1, |
| 127 |
|
| 128 |
i_UNSUPPORTED_MULTIPLE_PLANES = i_UNSUPPORTED_ERROR_BIT + 2, |
| 129 |
|
| 130 |
i_UNSUPPORTED_CHANNEL_TYPES = i_UNSUPPORTED_ERROR_BIT + 3, |
| 131 |
|
| 132 |
|
| 133 |
i_UNSUPPORTED_MIXED_CHANNELS = i_UNSUPPORTED_ERROR_BIT + 4, |
| 134 |
|
| 135 |
i_UNSUPPORTED_BLOCK_DIMENSIONS = i_UNSUPPORTED_ERROR_BIT + 5, |
| 136 |
}; |
| 137 |
|
| 138 |
|
| 139 |
typedef struct _InterpretedDFDChannel { |
| 140 |
uint32_t offset; |
| 141 |
uint32_t size; |
| 142 |
} InterpretedDFDChannel; |
| 143 |
|
| 144 |
|
| 145 |
enum InterpretDFDResult interpretDFD(const uint32_t *DFD, |
| 146 |
InterpretedDFDChannel *R, |
| 147 |
InterpretedDFDChannel *G, |
| 148 |
InterpretedDFDChannel *B, |
| 149 |
InterpretedDFDChannel *A, |
| 150 |
uint32_t *wordBytes); |
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
const char* dfdToStringVendorID(khr_df_vendorid_e value); |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
const char* dfdToStringDescriptorType(khr_df_khr_descriptortype_e value); |
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
const char* dfdToStringVersionNumber(khr_df_versionnumber_e value); |
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
const char* dfdToStringFlagsBit(uint32_t bit_index, bool bit_value); |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
const char* dfdToStringTransferFunction(khr_df_transfer_e value); |
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
const char* dfdToStringColorPrimaries(khr_df_primaries_e value); |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
const char* dfdToStringColorModel(khr_df_model_e value); |
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
const char* dfdToStringSampleDatatypeQualifiersBit(uint32_t bit_index, bool bit_value); |
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
const char* dfdToStringChannelId(khr_df_model_e model, khr_df_model_channels_e value); |
| 187 |
|
| 188 |
|
| 189 |
void printDFD(uint32_t *DFD, uint32_t dataSize); |
| 190 |
|
| 191 |
|
| 192 |
void printDFDJSON(uint32_t *DFD, uint32_t dataSize, uint32_t base_indent, uint32_t indent_width, bool minified); |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
void getDFDComponentInfoUnpacked(const uint32_t* DFD, uint32_t* numComponents, |
| 198 |
uint32_t* componentByteLength); |
| 199 |
|
| 200 |
|
| 201 |
uint32_t getDFDNumComponents(const uint32_t* DFD); |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
void reconstructDFDBytesPlanesFromSamples(uint32_t* DFD); |
| 207 |
|
| 208 |
uint32_t reconstructDFDBytesPlane0FromSamples(const uint32_t* DFD); |
| 209 |
|
| 210 |
void recreateBytesPlane0FromSampleInfo(const uint32_t* DFD, |
| 211 |
uint32_t* bytesPlane0); |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
typedef struct _Primaries { |
| 219 |
float Rx; |
| 220 |
float Ry; |
| 221 |
float Gx; |
| 222 |
float Gy; |
| 223 |
float Bx; |
| 224 |
float By; |
| 225 |
float Wx; |
| 226 |
float Wy; |
| 227 |
} Primaries; |
| 228 |
|
| 229 |
khr_df_primaries_e findMapping(const Primaries *p, float latitude); |
| 230 |
bool getPrimaries(khr_df_primaries_e primaries, Primaries *p); |
| 231 |
|
| 232 |
#ifdef __cplusplus |
| 233 |
} |
| 234 |
#endif |
| 235 |
|
| 236 |
#endif |