X-Git-Url: https://git.sesse.net/?p=movit;a=blobdiff_plain;f=gamma_compression_effect_test.cpp;h=db2023457142411415a4a2ad5aa57916458a774b;hp=41a700ca0b0c188f5997c8364110c74c38f929ba;hb=34776d3ed2565ee834405e575bf3bfc7f7933e36;hpb=9651a4eaae012cdc49c1aa38197861e04f62e91e diff --git a/gamma_compression_effect_test.cpp b/gamma_compression_effect_test.cpp index 41a700c..db20234 100644 --- a/gamma_compression_effect_test.cpp +++ b/gamma_compression_effect_test.cpp @@ -5,7 +5,7 @@ // However, the accuracy tests are somewhat simpler, since we // only need to care about absolute errors and not relative. -#include +#include #include #include "gtest/gtest.h" @@ -13,6 +13,8 @@ #include "image_format.h" #include "test_util.h" +namespace movit { + TEST(GammaCompressionEffectTest, sRGB_KeyValues) { float data[] = { 0.0f, 1.0f, @@ -24,7 +26,7 @@ TEST(GammaCompressionEffectTest, sRGB_KeyValues) { 0.040f, 0.041f, 0.0f, 1.0f, }; - float out_data[4]; + float out_data[6]; EffectChainTester tester(data, 2, 3, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR); tester.run(out_data, GL_RED, COLORSPACE_sRGB, GAMMA_sRGB); @@ -52,13 +54,7 @@ TEST(GammaCompressionEffectTest, sRGB_Accuracy) { double x = i / 255.0; expected_data[i] = x; - - // From the Wikipedia article on sRGB. - if (x < 0.04045) { - data[i] = x / 12.92; - } else { - data[i] = pow((x + 0.055) / 1.055, 2.4); - } + data[i] = srgb_to_linear(x); } EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_LINEAR, GL_RGBA32F); @@ -212,3 +208,5 @@ TEST(GammaCompressionEffectTest, Rec2020_12Bit_Inaccuracy) { // precision and inaccuracies in the polynomial approximation. expect_equal(expected_data, out_data, 4096, 1, 1.2 / 4095.0, 1e-5); } + +} // namespace movit