MCPcopy Create free account
hub / github.com/crownengine/crown / decodeBlockDxt

Function decodeBlockDxt

3rdparty/bimg/src/image.cpp:1395–1429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1393 }
1394
1395 static void decodeBlockDxt(uint8_t _dst[16*4], const uint8_t _src[8])
1396 {
1397 if (!BX_ENABLED(BIMG_DECODE_BC2 || BIMG_DECODE_BC3) )
1398 {
1399 return;
1400 }
1401
1402 uint8_t colors[4*3];
1403
1404 uint32_t c0 = _src[0] | (_src[1] << 8);
1405 colors[0] = bitRangeConvert( (c0>> 0)&0x1f, 5, 8);
1406 colors[1] = bitRangeConvert( (c0>> 5)&0x3f, 6, 8);
1407 colors[2] = bitRangeConvert( (c0>>11)&0x1f, 5, 8);
1408
1409 uint32_t c1 = _src[2] | (_src[3] << 8);
1410 colors[3] = bitRangeConvert( (c1>> 0)&0x1f, 5, 8);
1411 colors[4] = bitRangeConvert( (c1>> 5)&0x3f, 6, 8);
1412 colors[5] = bitRangeConvert( (c1>>11)&0x1f, 5, 8);
1413
1414 colors[6] = (2*colors[0] + colors[3]) / 3;
1415 colors[7] = (2*colors[1] + colors[4]) / 3;
1416 colors[8] = (2*colors[2] + colors[5]) / 3;
1417
1418 colors[ 9] = (colors[0] + 2*colors[3]) / 3;
1419 colors[10] = (colors[1] + 2*colors[4]) / 3;
1420 colors[11] = (colors[2] + 2*colors[5]) / 3;
1421
1422 for (uint32_t ii = 0, next = 8*4; ii < 16*4; ii += 4, next += 2)
1423 {
1424 int idx = ( (_src[next>>3] >> (next & 7) ) & 3) * 3;
1425 _dst[ii+0] = colors[idx+0];
1426 _dst[ii+1] = colors[idx+1];
1427 _dst[ii+2] = colors[idx+2];
1428 }
1429 }
1430
1431 static void decodeBlockDxt1(uint8_t _dst[16*4], const uint8_t _src[8])
1432 {

Callers 1

imageDecodeToBgra8Function · 0.85

Calls 1

bitRangeConvertFunction · 0.85

Tested by

no test coverage detected