| 1486 | #endif |
| 1487 | |
| 1488 | static float MapToF16(float f, bool isSigned) |
| 1489 | { |
| 1490 | const float normalization = 1.0; // For future use |
| 1491 | |
| 1492 | float result = 0.0f; |
| 1493 | |
| 1494 | // negative infinity for signed formats |
| 1495 | if (isSigned && cmp_isinf(f) && f < 0.0f) |
| 1496 | { |
| 1497 | result = F16_MAX_NEGATIVE_BITS; |
| 1498 | } |
| 1499 | // positive infinity |
| 1500 | else if (cmp_isinf(f) && f > 0.0f) |
| 1501 | { |
| 1502 | result = F16_MAX_BITS; |
| 1503 | } |
| 1504 | // NaN, or negative infinity for non-signed formats |
| 1505 | else if (cmp_isnan(f) || cmp_isinf(f)) |
| 1506 | { |
| 1507 | result = 0.0f; |
| 1508 | } |
| 1509 | // signed number is very close to zero |
| 1510 | else if (isSigned && f > -0.00001f && f < 0.00001f) |
| 1511 | { |
| 1512 | result = 0.0f; |
| 1513 | } |
| 1514 | // non-signed number is negative or very close to zero |
| 1515 | else if (!isSigned && f < 0.00001f) |
| 1516 | { |
| 1517 | result = 0.0f; |
| 1518 | } |
| 1519 | else if (isSigned && f < 0.0f) |
| 1520 | { |
| 1521 | result = -CMP_HALF(abs(f / normalization)).bits(); |
| 1522 | } |
| 1523 | else |
| 1524 | { |
| 1525 | result = CMP_HALF(f / normalization).bits(); |
| 1526 | } |
| 1527 | |
| 1528 | return result; |
| 1529 | } |
| 1530 | |
| 1531 | float BC6HBlockEncoder::CompressBlock(float in[MAX_SUBSET_SIZE][MAX_DIMENSION_BIG], BYTE out[COMPRESSED_BLOCK_SIZE]) |
| 1532 | { |
no test coverage detected