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

Function createDFDUnpacked

external/dfdutils/createdfd.c:190–228  ·  view source on GitHub ↗

* @~English * @brief Create a Data Format Descriptor for an unpacked format. * * @param bigEndian Set to 1 for big-endian byte ordering and 0 for little-endian byte ordering. * @param numChannels The number of color channels. * @param bytes The number of bytes per channel. * @param redBlueSwap Normally channels appear in consecutive R, G, B, A order *

Source from the content-addressed store, hash-verified

188 * for freeing the descriptor.
189 **/
190uint32_t *createDFDUnpacked(int bigEndian, int numChannels, int bytes,
191 int redBlueSwap, enum VkSuffix suffix)
192{
193 uint32_t *DFD;
194 if (bigEndian) {
195 int channelCounter, channelByte;
196 /* Number of samples = number of channels * bytes per channel */
197 DFD = writeHeader(numChannels * bytes, numChannels * bytes, suffix, i_COLOR);
198 /* First loop over the channels */
199 for (channelCounter = 0; channelCounter < numChannels; ++channelCounter) {
200 int channel = channelCounter;
201 if (redBlueSwap && (channel == 0 || channel == 2)) {
202 channel ^= 2;
203 }
204 /* Loop over the bytes that constitute a channel */
205 for (channelByte = 0; channelByte < bytes; ++channelByte) {
206 writeSample(DFD, channelCounter * bytes + channelByte, channel,
207 8, 8 * (channelCounter * bytes + bytes - channelByte - 1),
208 channelByte == bytes-1, channelByte == 0, suffix);
209 }
210 }
211
212 } else { /* Little-endian */
213
214 int sampleCounter;
215 /* One sample per channel */
216 DFD = writeHeader(numChannels, numChannels * bytes, suffix, i_COLOR);
217 for (sampleCounter = 0; sampleCounter < numChannels; ++sampleCounter) {
218 int channel = sampleCounter;
219 if (redBlueSwap && (channel == 0 || channel == 2)) {
220 channel ^= 2;
221 }
222 writeSample(DFD, sampleCounter, channel,
223 8 * bytes, 8 * sampleCounter * bytes,
224 1, 1, suffix);
225 }
226 }
227 return DFD;
228}
229
230/**
231 * @~English

Callers 3

TEST_FFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 2

writeHeaderFunction · 0.85
writeSampleFunction · 0.85

Tested by 3

TEST_FFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68