MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / getDFDComponentInfoUnpacked

Function getDFDComponentInfoUnpacked

external/dfdutils/queries.c:38–65  ·  view source on GitHub ↗

* @~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

Source from the content-addressed store, hash-verified

36 a component in bytes will be written.
37 */
38void
39getDFDComponentInfoUnpacked(const uint32_t* DFD, uint32_t* numComponents,
40 uint32_t* componentByteLength)
41{
42 const uint32_t *BDFDB = DFD+1;
43 uint32_t numSamples = KHR_DFDSAMPLECOUNT(BDFDB);
44 uint32_t sampleNumber;
45 uint32_t currentChannel = ~0U; /* Don't start matched. */
46
47 /* This is specifically for unpacked formats which means the size of */
48 /* each component is the same. */
49 *numComponents = 0;
50 for (sampleNumber = 0; sampleNumber < numSamples; ++sampleNumber) {
51 uint32_t sampleByteLength = (KHR_DFDSVAL(BDFDB, sampleNumber, BITLENGTH) + 1) >> 3U;
52 uint32_t sampleChannel = KHR_DFDSVAL(BDFDB, sampleNumber, CHANNELID);
53
54 if (sampleChannel == currentChannel) {
55 /* Continuation of the same channel. */
56 /* Accumulate the byte length. */
57 *componentByteLength += sampleByteLength;
58 } else {
59 /* Everything is new. Hopefully. */
60 currentChannel = sampleChannel;
61 (*numComponents)++;
62 *componentByteLength = sampleByteLength;
63 }
64 }
65}
66
67/**
68 * @~English

Callers 3

Calls

no outgoing calls

Tested by

no test coverage detected