| 4363 | } |
| 4364 | |
| 4365 | int CMP_CDECL CompressBlockBC6(const CGU_UINT16* srcBlock, |
| 4366 | unsigned int srcStrideInShorts, |
| 4367 | CMP_GLOBAL CGU_UINT8 cmpBlock[16], |
| 4368 | const CMP_GLOBAL void* options = NULL) |
| 4369 | { |
| 4370 | CGU_UINT16 inBlock[48] = {}; |
| 4371 | |
| 4372 | //---------------------------------- |
| 4373 | // Fill the inBlock with source data |
| 4374 | //---------------------------------- |
| 4375 | CGU_INT srcpos = 0; |
| 4376 | CGU_INT dstptr = 0; |
| 4377 | for (CGU_UINT8 row = 0; row < 4; row++) |
| 4378 | { |
| 4379 | srcpos = row * srcStrideInShorts; |
| 4380 | for (CGU_UINT8 col = 0; col < 4; col++) |
| 4381 | { |
| 4382 | inBlock[dstptr++] = CGU_UINT16(srcBlock[srcpos++]); |
| 4383 | inBlock[dstptr++] = CGU_UINT16(srcBlock[srcpos++]); |
| 4384 | inBlock[dstptr++] = CGU_UINT16(srcBlock[srcpos++]); |
| 4385 | } |
| 4386 | } |
| 4387 | |
| 4388 | BC6H_Encode* BC6HEncode = (BC6H_Encode*)options; |
| 4389 | BC6H_Encode BC6HEncodeDefault; |
| 4390 | |
| 4391 | if (BC6HEncode == NULL) |
| 4392 | { |
| 4393 | BC6HEncode = &BC6HEncodeDefault; |
| 4394 | SetDefaultBC6Options(BC6HEncode); |
| 4395 | } |
| 4396 | |
| 4397 | BC6H_Encode_local BC6HEncode_local; |
| 4398 | memset((CGU_UINT8*)&BC6HEncode_local, 0, sizeof(BC6H_Encode_local)); |
| 4399 | CGU_UINT8 blkindex = 0; |
| 4400 | for (CGU_INT32 j = 0; j < 16; j++) |
| 4401 | { |
| 4402 | BC6HEncode_local.din[j][0] = inBlock[blkindex++]; // R |
| 4403 | BC6HEncode_local.din[j][1] = inBlock[blkindex++]; // G |
| 4404 | BC6HEncode_local.din[j][2] = inBlock[blkindex++]; // B |
| 4405 | BC6HEncode_local.din[j][3] = 0; // A |
| 4406 | } |
| 4407 | |
| 4408 | CompressBlockBC6_Internal(cmpBlock, 0, &BC6HEncode_local, BC6HEncode); |
| 4409 | |
| 4410 | return CGU_CORE_OK; |
| 4411 | } |
| 4412 | |
| 4413 | int CMP_CDECL DecompressBlockBC6(const unsigned char cmpBlock[16], CGU_UINT16 srcBlock[48], const void* options = NULL) |
| 4414 | { |