MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / computePSNR

Function computePSNR

tests/unit/engine/Poseidon/Graphics/test_image.cpp:51–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49// --- Helper: compute PSNR between two RGBA buffers ---
50
51static double computePSNR(const uint8_t* a, const uint8_t* b, int w, int h)
52{
53 double mse = 0;
54 int n = w * h * 4;
55 for (int i = 0; i < n; ++i)
56 {
57 double d = static_cast<double>(a[i]) - static_cast<double>(b[i]);
58 mse += d * d;
59 }
60 mse /= n;
61 if (mse == 0.0)
62 return 100.0;
63 return 10.0 * std::log10(255.0 * 255.0 / mse);
64}
65
66// --- Image construction ---
67

Callers 1

test_image.cppFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected