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

Function EmitGreenIndices

trinity/Tr2DxtCompressor.cpp:579–603  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

577}
578
579void EmitGreenIndices( const uint8_t* block, const int offset, const uint8_t minGreen, const uint8_t maxGreen, uint8_t** outBuff )
580{
581 uint8_t mid = ( maxGreen - minGreen ) / ( 2 * 3 );
582
583 uint8_t gb1 = maxGreen - mid;
584 uint8_t gb2 = ( 2 * maxGreen + 1 * minGreen ) / 3 - mid;
585 uint8_t gb3 = ( 1 * maxGreen + 2 * minGreen ) / 3 - mid;
586
587 block += offset;
588
589 unsigned int result = 0;
590 for( int i = 15; i >= 0; i-- )
591 {
592 result <<= 2;
593 uint8_t g = block[i * 4];
594 int b1 = ( g >= gb1 );
595 int b2 = ( g >= gb2 );
596 int b3 = ( g >= gb3 );
597 int index = ( 4 - b1 - b2 - b3 ) & 3;
598 index ^= ( 2 > index );
599 result |= index;
600 }
601
602 EmitDoubleWord( result, outBuff );
603}
604
605void CompressYCoCgDXT5( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel )
606{

Callers 1

Calls 1

EmitDoubleWordFunction · 0.85

Tested by

no test coverage detected