| 603 | } |
| 604 | |
| 605 | void 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 | |
| 644 | void CompressImageSquish( const uint8_t* inBuf, |
| 645 | unsigned width, |
no test coverage detected