/* -*- tab-width: 4; -*- */ /* vi: set sw=2 ts=4 expandtab: */ /* Copyright 2019-2020 The Khronos Group Inc. * SPDX-License-Identifier: Apache-2.0 */ /** * @file * @~English * @brief Utilities for querying info from a data format descriptor. * @author Mark Callow */ #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <KHR/khr_df.h> #include "dfd.h" /** * @~English * @brief 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. * * @param 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. * @param numComponents pointer to a 32-bit word in which the number of components will be written. * @param componentByteLength pointer to a 32-bit word in which the size of a component in bytes will be written. */ void getDFDComponentInfoUnpacked(const uint32_t* DFD, uint32_t* numComponents, uint32_t* componentByteLength) { … } /** * @~English * @brief 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. * * @param 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. */ uint32_t getDFDNumComponents(const uint32_t* DFD) { … } /** * @~English * @brief Reconstruct the value of bytesPlane0 from sample info. * * Reconstruct the value for data that has been variable-rate compressed so * has bytesPlane0 = 0. For DFDs that are valid for KTX files. Little-endian * data only and no multi-plane formats. * * @param 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. */ uint32_t reconstructDFDBytesPlane0FromSamples(const uint32_t* DFD) { … } /** * @~English * @brief Reconstruct the value of bytesPlane0 from sample info. * * @see reconstructDFDBytesPlane0FromSamples for details. * @deprecated For backward comparibility only. Use * reconstructDFDBytesPlane0FromSamples. * * @param 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. * @param bytesPlane0 pointer to a 32-bit word in which the recreated * value of bytesPlane0 will be written. */ void recreateBytesPlane0FromSampleInfo(const uint32_t* DFD, uint32_t* bytesPlane0) { … }