X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=05eac31451f833687eff9b552abd098dbfcbbcc6;hp=b377309638114057f2d99a56c852ee010bebb18f;hb=d2eee22b0440147f69038e3cf829910b18526efc;hpb=72c893b5313744226d9496e8682071dfb373d56c diff --git a/test_util.cpp b/test_util.cpp index b377309..05eac31 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -351,4 +351,24 @@ void test_accuracy(const float *expected, const float *result, unsigned num_valu EXPECT_LT(rms, rms_limit); } +double srgb_to_linear(double x) +{ + // From the Wikipedia article on sRGB. + if (x < 0.04045) { + return x / 12.92; + } else { + return pow((x + 0.055) / 1.055, 2.4); + } +} + +double linear_to_srgb(double x) +{ + // From the Wikipedia article on sRGB. + if (x < 0.0031308) { + return 12.92 * x; + } else { + return 1.055 * pow(x, 1.0 / 2.4) - 0.055; + } +} + } // namespace movit