MCPcopy Create free account
hub / github.com/GPUOpen-Tools/compressonator / DecompressBlock

Method DecompressBlock

cmp_compressonatorlib/astc/astc_decode.cpp:244–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242// }
243
244void ASTCBlockDecoder::DecompressBlock(BYTE BlockWidth, BYTE BlockHeight, BYTE bitness, float out[][4], BYTE in[ASTC_COMPRESSED_BLOCK_SIZE])
245{
246 // Results Buffer
247 astc_codec_image_cpu* img = allocate_image_cpu(bitness, BlockWidth, BlockHeight, 1, 0);
248 initialize_image_cpu(img);
249
250 ASTC_Encoder::uint8_t* bp = in;
251 physical_compressed_block_cpu pcb = *(physical_compressed_block_cpu*)bp;
252 symbolic_compressed_block_cpu scb;
253
254 physical_to_symbolic_cpu(BlockWidth, BlockHeight, 1, pcb, &scb);
255
256 swizzlepattern_cpu swz_decode = {0, 1, 2, 3};
257 imageblock_cpu pb;
258
259 // astc_decode_mode decode_mode1 = DECODE_HDR;
260 // decompress_symbolic_block((astc_decode_mode)decode_mode1, BlockWidth, BlockHeight, 1, 0, 0, 0, (symbolic_compressed_block*)&scb, (imageblock_cpu *)&pb);
261
262 ASTC_Encoder::astc_decode_mode decode_mode = ASTC_Encoder::DECODE_HDR;
263 decompress_symbolic_block_cpu(decode_mode, BlockWidth, BlockHeight, 1, 0, 0, 0, &scb, &pb);
264
265 write_imageblock_cpu(img, &pb, BlockWidth, BlockHeight, 1, 0, 0, 0, swz_decode);
266
267 // copy results to our output buffer
268 int x, y, z;
269 int index = 0;
270
271 int exsize = img->xsize + 2 * img->padding;
272 int eysize = img->ysize + 2 * img->padding;
273 int ezsize = (img->zsize == 1) ? 1 : img->zsize + 2 * img->padding;
274
275 if (img->imagedata8)
276 {
277 for (z = 0; z < ezsize; z++)
278 for (y = 0; y < eysize; y++)
279 {
280 for (x = 0; x < exsize; x++)
281 {
282 out[index][0] = img->imagedata8[z][y][4 * x];
283 out[index][1] = img->imagedata8[z][y][4 * x + 1];
284 out[index][2] = img->imagedata8[z][y][4 * x + 2];
285 out[index][3] = img->imagedata8[z][y][4 * x + 3];
286 index++;
287 }
288 }
289 }
290 else if (img->imagedata16)
291 {
292 for (z = 0; z < ezsize; z++)
293 for (y = 0; y < eysize; y++)
294 for (x = 0; x < exsize; x++)
295 {
296 out[index][0] = img->imagedata16[z][y][4 * x];
297 out[index][1] = img->imagedata16[z][y][4 * x + 1];
298 out[index][2] = img->imagedata16[z][y][4 * x + 2];
299 out[index][3] = img->imagedata16[z][y][4 * x + 3];
300 }
301 }

Callers 2

DecompressMethod · 0.45
CMP_DecodeASTCBlockFunction · 0.45

Calls 6

allocate_image_cpuFunction · 0.85
initialize_image_cpuFunction · 0.85
physical_to_symbolic_cpuFunction · 0.85
write_imageblock_cpuFunction · 0.85
destroy_image_cpuFunction · 0.85

Tested by

no test coverage detected