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

Function CompressYCoCgDXT5

trinity/Tr2DxtCompressor.cpp:605–642  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

603}
604
605void CompressYCoCgDXT5( const uint8_t* inBuf, uint8_t* outBuf, int width, int height, ptrdiff_t& outputBytes, volatile const bool& cancel )
606{
607 uint8_t block[64];
608 uint8_t minColor[4];
609 uint8_t maxColor[4];
610
611 uint8_t** outData = &outBuf;
612
613 for( int j = 0; j < height; j += 4, inBuf += width * 4 * 4 )
614 {
615 if( cancel )
616 {
617 return;
618 }
619 for( int i = 0; i < width; i += 4 )
620 {
621
622 ExtractBlock( inBuf + i * 4, width, block );
623
624 GetMinMaxYCoCg( block, minColor, maxColor );
625 ScaleYCoCg( block, minColor, maxColor );
626 InsetYCoCgBBox( minColor, maxColor );
627 SelectYCoCgDiagonal( block, minColor, maxColor );
628
629 EmitByte( maxColor[3], outData );
630 EmitByte( minColor[3], outData );
631
632 EmitAlphaIndices( block, minColor[3], maxColor[3], outData );
633
634 EmitWord( ColorTo565( maxColor ), outData );
635 EmitWord( ColorTo565( minColor ), outData );
636
637 EmitColorIndices( block, minColor, maxColor, outData );
638 }
639 }
640
641 outputBytes = *outData - outBuf;
642}
643
644void CompressImageSquish( const uint8_t* inBuf,
645 unsigned width,

Callers 1

Tr2DxtCompressSurfaceFunction · 0.85

Calls 10

ExtractBlockFunction · 0.85
GetMinMaxYCoCgFunction · 0.85
ScaleYCoCgFunction · 0.85
InsetYCoCgBBoxFunction · 0.85
SelectYCoCgDiagonalFunction · 0.85
EmitByteFunction · 0.85
EmitAlphaIndicesFunction · 0.85
EmitWordFunction · 0.85
ColorTo565Function · 0.85
EmitColorIndicesFunction · 0.85

Tested by

no test coverage detected