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

Function imageAllocate

lib/astc_codec.cpp:537–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

535
536#if KTX_FEATURE_WRITE
537static astcenc_image*
538imageAllocate(uint32_t bitness,
539 uint32_t dim_x, uint32_t dim_y, uint32_t dim_z) {
540 astcenc_image *img = new astcenc_image;
541 assert(img);
542
543 img->dim_x = dim_x;
544 img->dim_y = dim_y;
545 img->dim_z = dim_z;
546
547 if (bitness == 8) {
548 void **data = new void *[dim_z];
549 img->data_type = ASTCENC_TYPE_U8;
550 img->data = data;
551
552 for (uint32_t z = 0; z < dim_z; z++) {
553 data[z] = new uint8_t[dim_x * dim_y * 4];
554 }
555 }
556 else if (bitness == 16) {
557 void **data = new void *[dim_z];
558 img->data_type = ASTCENC_TYPE_F16;
559 img->data = data;
560
561 for (uint32_t z = 0; z < dim_z; z++) {
562 data[z] = new uint16_t[dim_x * dim_y * 4];
563 }
564 }
565 else { // if (bitness == 32)
566 assert(bitness == 32);
567 void **data = new void *[dim_z];
568 img->data_type = ASTCENC_TYPE_F32;
569 img->data = data;
570
571 for (uint32_t z = 0; z < dim_z; z++) {
572 data[z] = new float[dim_x * dim_y * 4];
573 }
574 }
575
576 return img;
577}
578
579static void
580imageFree(astcenc_image *img) {

Callers 4

unorm8x1ArrayToImageFunction · 0.85
unorm8x2ArrayToImageFunction · 0.85
unorm8x3ArrayToImageFunction · 0.85
unorm8x4ArrayToImageFunction · 0.85

Calls 1

assertFunction · 0.85

Tested by

no test coverage detected