X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=9d12a120f16cc8863defadf3151a0c2d30a4f653;hp=b377309638114057f2d99a56c852ee010bebb18f;hb=4f8b89618d6d09b4df811c4e2d7dcfa20815dcb3;hpb=9c6b86affb570a2e2d18c6da795c359da393f9a3 diff --git a/test_util.cpp b/test_util.cpp index b377309..9d12a12 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -46,9 +46,8 @@ void vertical_flip(T *data, unsigned width, unsigned height) EffectChainTester::EffectChainTester(const float *data, unsigned width, unsigned height, MovitPixelFormat pixel_format, Colorspace color_space, GammaCurve gamma_curve, - GLenum framebuffer_format, - GLenum intermediate_format) - : chain(width, height, get_static_pool(), intermediate_format), + GLenum framebuffer_format) + : chain(width, height, get_static_pool()), width(width), height(height), framebuffer_format(framebuffer_format), @@ -351,4 +350,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