X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=test_util.cpp;h=05eac31451f833687eff9b552abd098dbfcbbcc6;hp=ada84dca8832f24513c40a05d58fae7f6de97869;hb=34776d3ed2565ee834405e575bf3bfc7f7933e36;hpb=d2050acb601e0d16bb33b1c1e7cf443dce2d3c93 diff --git a/test_util.cpp b/test_util.cpp index ada84dc..05eac31 100644 --- a/test_util.cpp +++ b/test_util.cpp @@ -46,8 +46,14 @@ 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) - : chain(width, height, get_static_pool()), width(width), height(height), framebuffer_format(framebuffer_format), output_added(false), finalized(false) + GLenum framebuffer_format, + GLenum intermediate_format) + : chain(width, height, get_static_pool(), intermediate_format), + width(width), + height(height), + framebuffer_format(framebuffer_format), + output_added(false), + finalized(false) { CHECK(init_movit(".", MOVIT_DEBUG_OFF)); @@ -345,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