MCPcopy Create free account
hub / github.com/ARM-software/astc-encoder / mpsnr_operator

Function mpsnr_operator

Source/astcenccli_error_metrics.cpp:67–78  ·  view source on GitHub ↗

* @brief mPSNR tone-mapping operator for HDR images. * * @param val The color value to tone map * @param fstop The exposure fstop; should be in range [-125, 125] * * @return The mapped color value in [0.0f, 255.0f] range */

Source from the content-addressed store, hash-verified

65 * @return The mapped color value in [0.0f, 255.0f] range
66 */
67static float mpsnr_operator(
68 float val,
69 int fstop
70) {
71 // Fast implementation of pow(2.0, fstop), assuming IEEE float layout
72 // Memcpy to uint avoids ubsan complaints shift of negative int
73 unsigned int uscale = 0x3f800000u + (astc::int_as_uint(fstop) << 23);
74 float scale = astc::uint_as_float(uscale);
75
76 val = powf(val * scale, (1.0f / 2.2f));
77 return astc::clamp(val * 255.0f, 0.0f, 255.0f);
78}
79
80/**
81 * @brief mPSNR difference between two values.

Callers 1

mpsnr_sumdiffFunction · 0.85

Calls 3

int_as_uintFunction · 0.85
uint_as_floatFunction · 0.85
clampFunction · 0.70

Tested by

no test coverage detected