MCPcopy Create free account
hub / github.com/carbonengine/trinity / EmitColorIndices

Function EmitColorIndices

trinity/Tr2DxtCompressor.cpp:421–457  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

419}
420
421void EmitColorIndices( const uint8_t* colorBlock, const uint8_t* minColor, const uint8_t* maxColor, uint8_t** outBuff )
422{
423 word colors[4][4];
424 dword result = 0;
425 colors[0][0] = ( maxColor[0] & C565_5_MASK ) | ( maxColor[0] >> 5 );
426 colors[0][1] = ( maxColor[1] & C565_6_MASK ) | ( maxColor[1] >> 6 );
427 colors[0][2] = ( maxColor[2] & C565_5_MASK ) | ( maxColor[2] >> 5 );
428 colors[1][0] = ( minColor[0] & C565_5_MASK ) | ( minColor[0] >> 5 );
429 colors[1][1] = ( minColor[1] & C565_6_MASK ) | ( minColor[1] >> 6 );
430 colors[1][2] = ( minColor[2] & C565_5_MASK ) | ( minColor[2] >> 5 );
431 colors[2][0] = ( 2 * colors[0][0] + 1 * colors[1][0] ) / 3;
432 colors[2][1] = ( 2 * colors[0][1] + 1 * colors[1][1] ) / 3;
433 colors[2][2] = ( 2 * colors[0][2] + 1 * colors[1][2] ) / 3;
434 colors[3][0] = ( 1 * colors[0][0] + 2 * colors[1][0] ) / 3;
435 colors[3][1] = ( 1 * colors[0][1] + 2 * colors[1][1] ) / 3;
436 colors[3][2] = ( 1 * colors[0][2] + 2 * colors[1][2] ) / 3;
437 for( int i = 15; i >= 0; i-- )
438 {
439 int c0 = colorBlock[i * 4 + 0];
440 int c1 = colorBlock[i * 4 + 1];
441 int c2 = colorBlock[i * 4 + 2];
442 int d0 = abs( colors[0][0] - c0 ) + abs( colors[0][1] - c1 ) + abs( colors[0][2] - c2 );
443 int d1 = abs( colors[1][0] - c0 ) + abs( colors[1][1] - c1 ) + abs( colors[1][2] - c2 );
444 int d2 = abs( colors[2][0] - c0 ) + abs( colors[2][1] - c1 ) + abs( colors[2][2] - c2 );
445 int d3 = abs( colors[3][0] - c0 ) + abs( colors[3][1] - c1 ) + abs( colors[3][2] - c2 );
446 int b0 = d0 > d3;
447 int b1 = d1 > d2;
448 int b2 = d0 > d2;
449 int b3 = d1 > d3;
450 int b4 = d2 > d3;
451 int x0 = b1 & b2;
452 int x1 = b0 & b3;
453 int x2 = b0 & b4;
454 result |= ( x2 | ( ( x0 | x1 ) << 1 ) ) << ( i << 1 );
455 }
456 EmitDoubleWord( result, outBuff );
457}
458void GetMinMaxNormalsBBox( const uint8_t* block, uint8_t* minNormal, uint8_t* maxNormal )
459{
460

Callers 4

CompressYCoCgDXT5Function · 0.85
CompressImageDXT5Function · 0.85
CompressNormalMapDXT5Function · 0.85
CompressImageDXT1Function · 0.85

Calls 1

EmitDoubleWordFunction · 0.85

Tested by

no test coverage detected