dfdutils
Loading...
Searching...
No Matches
queries.c File Reference

Utilities for querying info from a data format descriptor. More...

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <KHR/khr_df.h>
#include "dfd.h"

Functions

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.
uint32_t reconstructDFDBytesPlane0FromSamples (const uint32_t *DFD)
 Reconstruct the value of bytesPlane0 from sample info.
void reconstructDFDBytesPlanesFromSamples (uint32_t *DFD)
 Reconstruct the values of bytesPlane[01] from sample info.
void recreateBytesPlane0FromSampleInfo (const uint32_t *DFD, uint32_t *bytesPlane0)
 Reconstruct the value of bytesPlane0 from sample info.

Detailed Description

Utilities for querying info from a data format descriptor.

Author
Mark Callow

Function Documentation

◆ getDFDComponentInfoUnpacked()

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.

Parameters
DFDPointer 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.
numComponentspointer to a 32-bit word in which the number of components will be written.
componentByteLengthpointer to a 32-bit word in which the size of a component in bytes will be written.

◆ getDFDNumComponents()

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.

Parameters
DFDPointer 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.

◆ reconstructDFDBytesPlane0FromSamples()

uint32_t reconstructDFDBytesPlane0FromSamples ( const uint32_t * DFD)

Reconstruct the value of bytesPlane0 from sample info.

Deprecated
Use reconstructDFDBytesPlanesFromSamples. This does not handle the possible second plane of the ETC1S model.

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.

Parameters
DFDPointer 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.
Returns
The number of bytes a pixel occupies in bytesPlane0.

◆ reconstructDFDBytesPlanesFromSamples()

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.

Parameters
DFDPointer 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.

◆ recreateBytesPlane0FromSampleInfo()

void recreateBytesPlane0FromSampleInfo ( const uint32_t * DFD,
uint32_t * bytesPlane0 )

Reconstruct the value of bytesPlane0 from sample info.

See also
reconstructDFDBytesPlane0FromSamples for details.
Deprecated
For backward comparibility only. Use reconstructDFDBytesPlanesFromSamples.
Parameters
DFDPointer 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.
bytesPlane0pointer to a 32-bit word in which the recreated value of bytesPlane0 will be written.