| 3515 | } |
| 3516 | |
| 3517 | int CMP_CDECL CompressBlockBC7(const unsigned char* srcBlock, unsigned int srcStrideInBytes, CMP_GLOBAL unsigned char cmpBlock[16], const void* options = NULL) |
| 3518 | { |
| 3519 | CMP_Vec4uc inBlock[SOURCE_BLOCK_SIZE]; |
| 3520 | |
| 3521 | //---------------------------------- |
| 3522 | // Fill the inBlock with source data |
| 3523 | //---------------------------------- |
| 3524 | CGU_INT srcpos = 0; |
| 3525 | CGU_INT dstptr = 0; |
| 3526 | for (CGU_UINT8 row = 0; row < 4; row++) |
| 3527 | { |
| 3528 | srcpos = row * srcStrideInBytes; |
| 3529 | for (CGU_UINT8 col = 0; col < 4; col++) |
| 3530 | { |
| 3531 | inBlock[dstptr].x = CGU_UINT8(srcBlock[srcpos++]); |
| 3532 | inBlock[dstptr].y = CGU_UINT8(srcBlock[srcpos++]); |
| 3533 | inBlock[dstptr].z = CGU_UINT8(srcBlock[srcpos++]); |
| 3534 | inBlock[dstptr].w = CGU_UINT8(srcBlock[srcpos++]); |
| 3535 | dstptr++; |
| 3536 | } |
| 3537 | } |
| 3538 | |
| 3539 | BC7_Encode* u_BC7Encode = (BC7_Encode*)options; |
| 3540 | BC7_Encode BC7EncodeDefault = {0}; |
| 3541 | if (u_BC7Encode == NULL) |
| 3542 | { |
| 3543 | u_BC7Encode = &BC7EncodeDefault; |
| 3544 | SetDefaultBC7Options(u_BC7Encode); |
| 3545 | init_BC7ramps(); |
| 3546 | } |
| 3547 | |
| 3548 | BC7_EncodeState EncodeState |
| 3549 | #ifndef ASPM |
| 3550 | = {0} |
| 3551 | #endif |
| 3552 | ; |
| 3553 | EncodeState.best_err = CMP_FLOAT_MAX; |
| 3554 | EncodeState.validModeMask = u_BC7Encode->validModeMask; |
| 3555 | EncodeState.part_count = u_BC7Encode->part_count; |
| 3556 | EncodeState.channels = CMP_STATIC_CAST(CGU_UINT8, u_BC7Encode->channels); |
| 3557 | |
| 3558 | CGU_UINT8 offsetR = 0; |
| 3559 | CGU_UINT8 offsetG = 16; |
| 3560 | CGU_UINT8 offsetB = 32; |
| 3561 | CGU_UINT8 offsetA = 48; |
| 3562 | CGU_UINT32 offsetSRC = 0; |
| 3563 | for (CGU_UINT8 i = 0; i < SOURCE_BLOCK_SIZE; i++) |
| 3564 | { |
| 3565 | EncodeState.image_src[offsetR++] = (CGV_FLOAT)inBlock[offsetSRC].x; |
| 3566 | EncodeState.image_src[offsetG++] = (CGV_FLOAT)inBlock[offsetSRC].y; |
| 3567 | EncodeState.image_src[offsetB++] = (CGV_FLOAT)inBlock[offsetSRC].z; |
| 3568 | EncodeState.image_src[offsetA++] = (CGV_FLOAT)inBlock[offsetSRC].w; |
| 3569 | offsetSRC++; |
| 3570 | } |
| 3571 | |
| 3572 | BC7_CompressBlock(&EncodeState, u_BC7Encode); |
| 3573 | |
| 3574 | if (EncodeState.cmp_isout16Bytes) |