|
dfdutils
|
Header file defining the data format descriptor utilities API. More...
#include <KHR/khr_df.h>#include <stdbool.h>#include <vulkan/vulkan_core.h>Data Structures | |
| struct | _InterpretedDFDChannel |
| Interpretation of a channel from the data format descriptor. More... | |
| struct | _Primaries |
| Colourspace primaries information. More... | |
Typedefs | |
| typedef struct _InterpretedDFDChannel | InterpretedDFDChannel |
| Interpretation of a channel from the data format descriptor. | |
| typedef struct _Primaries | Primaries |
| Colourspace primaries information. | |
Functions | |
| uint32_t * | vk2dfd (enum VkFormat format) |
| Create a DFD matching a VkFormat. | |
| enum VkFormat | dfd2vk (uint32_t *dfd) |
| Return a VkFormat matching a DFD. | |
| uint32_t * | createDFDUnpacked (int bigEndian, int numChannels, int bytes, int redBlueSwap, enum VkSuffix suffix) |
| Create a Data Format Descriptor for an unpacked format. | |
| uint32_t * | createDFDPackedShifted (int bigEndian, int numChannels, int bits[], int shiftBits[], int channels[], enum VkSuffix suffix) |
| Create a Data Format Descriptor for a packed format. | |
| uint32_t * | createDFDPacked (int bigEndian, int numChannels, int bits[], int channels[], enum VkSuffix suffix) |
| Create a Data Format Descriptor for a packed format. | |
| uint32_t * | createDFDCompressed (enum VkCompScheme compScheme, int bwidth, int bheight, int bdepth, enum VkSuffix suffix) |
| Create a Data Format Descriptor for a compressed format. | |
| uint32_t * | createDFDDepthStencil (int depthBits, int stencilBits, int sizeBytes) |
| Create a Data Format Descriptor for a depth-stencil format. | |
| uint32_t * | createDFDAlpha (int bigEndian, int bytes, enum VkSuffix suffix) |
| Create a Data Format Descriptor for an alpha-only format. | |
| enum InterpretDFDResult | interpretDFD (const uint32_t *DFD, InterpretedDFDChannel *R, InterpretedDFDChannel *G, InterpretedDFDChannel *B, InterpretedDFDChannel *A, uint32_t *wordBytes) |
| Interpret a Data Format Descriptor for a simple format. | |
| void | printDFD (uint32_t *DFD, uint32_t dataSize) |
| Print a human-readable interpretation of a data format descriptor. | |
| void | printDFDJSON (uint32_t *DFD, uint32_t dataSize, uint32_t base_indent, uint32_t indent_width, bool minified) |
| Print a JSON interpretation of a data format descriptor. | |
| void | getDFDComponentInfoUnpacked (const uint32_t *DFD, uint32_t *numComponents, uint32_t *componentByteLength) |
| Get the number and size of the image components from a DFD. | |
| uint32_t | getDFDNumComponents (const uint32_t *DFD) |
| Return the number of "components" in the data. | |
| void | reconstructDFDBytesPlanesFromSamples (uint32_t *DFD) |
| Reconstruct the values of bytesPlane[01] from sample info. | |
| uint32_t | reconstructDFDBytesPlane0FromSamples (const uint32_t *DFD) |
| Reconstruct the value of bytesPlane0 from sample info. | |
| void | recreateBytesPlane0FromSampleInfo (const uint32_t *DFD, uint32_t *bytesPlane0) |
| Reconstruct the value of bytesPlane0 from sample info. | |
| khr_df_primaries_e | findMapping (const Primaries *p, float latitude) |
| Map a set of primaries to a KDFS primaries enum. | |
| bool | getPrimaries (khr_df_primaries_e primaries, Primaries *p) |
| Get the primaries corresponding to a KDFS primaries enum. | |
Header file defining the data format descriptor utilities API.
| typedef struct _Primaries Primaries |
Colourspace primaries information.
Structure to store the 1931 CIE x,y chromaticities of the red, green, and blue display primaries and the reference white point of a colourspace.
| enum InterpretDFDResult |
Result of interpreting the data format descriptor.
| enum VkCompScheme |
Compression scheme, in Vulkan terms.
| enum VkSuffix |
Qualifier suffix to the format, in Vulkan terms.
| uint32_t * createDFDAlpha | ( | int | bigEndian, |
| int | bytes, | ||
| enum VkSuffix | suffix ) |
Create a Data Format Descriptor for an alpha-only format.
| bigEndian | Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering. |
| bytes | The number of bytes per channel. |
| suffix | Indicates the format suffix for the type. |
| uint32_t * createDFDCompressed | ( | enum VkCompScheme | compScheme, |
| int | bwidth, | ||
| int | bheight, | ||
| int | bdepth, | ||
| enum VkSuffix | suffix ) |
Create a Data Format Descriptor for a compressed format.
| compScheme | Vulkan-style compression scheme enumeration. |
| bwidth | Block width in texel coordinates. |
| bheight | Block height in texel coordinates. |
| bdepth | Block depth in texel coordinates. |
| suffix | Indicates the format suffix for the type. |
| uint32_t * createDFDDepthStencil | ( | int | depthBits, |
| int | stencilBits, | ||
| int | sizeBytes ) |
Create a Data Format Descriptor for a depth-stencil format.
| depthBits | The numeber of bits in the depth channel. |
| stencilBits | The numeber of bits in the stencil channel. |
| sizeBytes | The total byte size of the texel. |
| uint32_t * createDFDPacked | ( | int | bigEndian, |
| int | numChannels, | ||
| int | bits[], | ||
| int | channels[], | ||
| enum VkSuffix | suffix ) |
Create a Data Format Descriptor for a packed format.
| bigEndian | Big-endian flag: Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering. |
| numChannels | The number of color channels. |
| bits[] | An array of length numChannels. Each entry is the number of bits composing the channel, in order starting at bit 0 of the packed type. |
| channels[] | An array of length numChannels. Each entry enumerates the channel type: 0 = red, 1 = green, 2 = blue, 15 = alpha, in order starting at bit 0 of the packed type. These values match channel IDs for RGBSDA in the Khronos Data Format header. To simplify iteration through channels, channel id 3 is a synonym for alpha. |
| suffix | Indicates the format suffix for the type. |
| uint32_t * createDFDPackedShifted | ( | int | bigEndian, |
| int | numChannels, | ||
| int | bits[], | ||
| int | shiftBits[], | ||
| int | channels[], | ||
| enum VkSuffix | suffix ) |
Create a Data Format Descriptor for a packed format.
| bigEndian | Big-endian flag: Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering. |
| numChannels | The number of color channels. |
| bits[] | An array of length numChannels. Each entry is the number of bits composing the channel, in order starting at bit 0 of the packed type. |
| shiftBits[] | An array of length numChannels. Each entry is the number of bits each channel is shifted and thus padded with insignificant bits. |
| channels[] | An array of length numChannels. Each entry enumerates the channel type: 0 = red, 1 = green, 2 = blue, 15 = alpha, in order starting at bit 0 of the packed type. These values match channel IDs for RGBSDA in the Khronos Data Format header. To simplify iteration through channels, channel id 3 is a synonym for alpha. |
| suffix | Indicates the format suffix for the type. |
| uint32_t * createDFDUnpacked | ( | int | bigEndian, |
| int | numChannels, | ||
| int | bytes, | ||
| int | redBlueSwap, | ||
| enum VkSuffix | suffix ) |
Create a Data Format Descriptor for an unpacked format.
| bigEndian | Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering. |
| numChannels | The number of color channels. |
| bytes | The number of bytes per channel. |
| redBlueSwap | Normally channels appear in consecutive R, G, B, A order in memory; redBlueSwap inverts red and blue, allowing B, G, R, A. |
| suffix | Indicates the format suffix for the type. |
| enum VkFormat dfd2vk | ( | uint32_t * | dfd | ) |
Return a VkFormat matching a DFD.
| [in] | dfd | Pointer to the DFD. |
| khr_df_primaries_e findMapping | ( | const Primaries * | p, |
| float | latitude ) |
Map a set of primaries to a KDFS primaries enum.
| [in] | p | pointer to a Primaries struct filled in with the primary values. |
| [in] | latitude | tolerance to use while matching. A suitable value might be 0.002 but it depends on the application. |
| void getDFDComponentInfoUnpacked | ( | const uint32_t * | DFD, |
| uint32_t * | numComponents, | ||
| uint32_t * | componentByteLength ) |
Get the number and size of the image components from a DFD.
This simplified function is for use only with the DFDs for unpacked formats which means all components have the same size.
| DFD | Pointer to a Data Format Descriptor to interpret, described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block. |
| numComponents | pointer to a 32-bit word in which the number of components will be written. |
| componentByteLength | pointer to a 32-bit word in which the size of a component in bytes will be written. |
| uint32_t getDFDNumComponents | ( | const uint32_t * | DFD | ) |
Return the number of "components" in the data.
Calculates the number of uniques samples in the DFD by combining multiple samples for the same channel. For uncompressed colorModels this is the same as the number of components in the image data. For block-compressed color models this is the number of samples in the color model, typically 1 and in a few cases 2.
| DFD | Pointer to a Data Format Descriptor for which, described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block. |
| bool getPrimaries | ( | khr_df_primaries_e | primaries, |
| Primaries * | p ) |
Get the primaries corresponding to a KDFS primaries enum.
| [in] | primaries | the enum identifying the KDFS primaries. |
| [out] | p | pointer to a Primaries struct that will be filled with the primary values. |
| enum InterpretDFDResult interpretDFD | ( | const uint32_t * | DFD, |
| InterpretedDFDChannel * | R, | ||
| InterpretedDFDChannel * | G, | ||
| InterpretedDFDChannel * | B, | ||
| InterpretedDFDChannel * | A, | ||
| uint32_t * | wordBytes ) |
Interpret a Data Format Descriptor for a simple format.
Handles "simple" cases that can be translated to things a GPU can access. For simplicity, it ignores the compressed formats, which are generally a single sample (and I believe are all defined to be little-endian in their in-memory layout, even if some documentation confuses this). Focuses on the layout and ignores sRGB except for reporting if that is the transfer function by way of a bit in the returned value.
| [in] | DFD | Pointer to a Data Format Descriptor to interpret, described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block. |
| R[in,out] | Pointer to struct to receive information about the decoded red channel, the Y channel, if YUV, or the depth channel, if any. | |
| G[in,out] | Pointer to struct to receive information about the decoded green channel, the U (Cb) channel, if YUV, or the stencil channel, if any. | |
| B[in,out] | Pointer to struct to receive information about the decoded blue channel, if any or the V (Cr) channel, if YUV. | |
| A[in,out] | Pointer to struct to receive information about the decoded alpha channel, if any or the second Y channel, if YUV and any. | |
| wordBytes[in,out] | Pointer to a uint32_t to receive the byte size of the channels (unpacked) or total size (packed). |
The mapping of YUV channels to the parameter names used here is based on the channel ids in khr_df.h and is different from the convention used in format names in the Vulkan specification where G == Y, R = Cr and B = Cb.
| void printDFD | ( | uint32_t * | DFD, |
| uint32_t | dataSize ) |
Print a human-readable interpretation of a data format descriptor.
| DFD | Pointer to a data format descriptor. |
| dataSize | The maximum size that can be considered as part of the DFD. |
| void printDFDJSON | ( | uint32_t * | DFD, |
| uint32_t | dataSize, | ||
| uint32_t | base_indent, | ||
| uint32_t | indent_width, | ||
| bool | minified ) |
Print a JSON interpretation of a data format descriptor.
| DFD | Pointer to a data format descriptor. |
| dataSize | The maximum size that can be considered as part of the DFD. |
| base_indent | The number of indentations to include at the front of every line |
| indent_width | The number of spaces to add with each nested scope |
| minified | Specifies whether the JSON output should be minified |
Prints an enum as string or number
Prints an enum as string or number if the to string function fails with a trailing comma
Prints an enum as string or number if the to string function fails without a trailing comma
| uint32_t reconstructDFDBytesPlane0FromSamples | ( | const uint32_t * | DFD | ) |
Reconstruct the value of bytesPlane0 from sample info.
Reconstruct the value for data that has been variable-rate compressed and and whose bytesPlane0 value has been set to 0. For DFDs that are valid for KTX files. Little-endian data only and no multi-plane models except ETC1S.
| DFD | Pointer to the Data Format Descriptor for which to provide the value described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block. |
| void reconstructDFDBytesPlanesFromSamples | ( | uint32_t * | DFD | ) |
Reconstruct the values of bytesPlane[01] from sample info.
Reconstruct the values for data that has been variable-rate compressed and whose bytesPlane[01] values have been set to 0 and update the fields of the target DFD. For DFDs that are valid for KTX files. Little-endian data only and no multi-plane models except ETC1S hence only looking at bytesPlane0 abd bytesPlane1.
| DFD | Pointer to a Data Format Descriptor for which, described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block. |
| void recreateBytesPlane0FromSampleInfo | ( | const uint32_t * | DFD, |
| uint32_t * | bytesPlane0 ) |
Reconstruct the value of bytesPlane0 from sample info.
| DFD | Pointer to the Data Format Descriptor for which to provide the value described as 32-bit words in native endianness. Note that this is the whole descriptor, not just the basic descriptor block. |
| bytesPlane0 | pointer to a 32-bit word in which the recreated value of bytesPlane0 will be written. |
| uint32_t * vk2dfd | ( | enum VkFormat | format | ) |
Create a DFD matching a VkFormat.
| [in] | format | VkFormat for which to create a DFD. |