MCPcopy Create free account
hub / github.com/KhronosGroup/KTX-Software / compareUnorm8

Function compareUnorm8

tests/ktxdiff/ktxdiff_main.cpp:244–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242};
243
244CompareResult compareUnorm8(const char* rawLhs, const char* rawRhs, std::size_t rawSize, float tolerance) {
245 const auto* lhs = reinterpret_cast<const uint8_t*>(rawLhs);
246 const auto* rhs = reinterpret_cast<const uint8_t*>(rawRhs);
247 const auto element_size = sizeof(uint8_t);
248 const auto count = rawSize / element_size;
249
250 for (std::size_t i = 0; i < count; ++i) {
251 const auto diff = std::abs(static_cast<float>(lhs[i]) / 255.f - static_cast<float>(rhs[i]) / 255.f);
252 if (diff > tolerance)
253 return CompareResult{false, diff, i, i * element_size};
254 }
255
256 return CompareResult{};
257}
258
259CompareResult compareSFloat32(const char* rawLhs, const char* rawRhs, std::size_t rawSize, float tolerance) {
260 const auto* lhs = reinterpret_cast<const float*>(rawLhs);

Callers 2

compareAstcFunction · 0.85
compareFunction · 0.85

Calls 1

absFunction · 0.50

Tested by

no test coverage detected