// However, the accuracy tests are somewhat simpler, since we
// only need to care about absolute errors and not relative.
+#include <epoxy/gl.h>
#include <math.h>
-#include <GL/glew.h>
+
#include "gtest/gtest.h"
+#include "gtest/gtest-message.h"
#include "image_format.h"
#include "test_util.h"
+namespace movit {
+
TEST(GammaCompressionEffectTest, sRGB_KeyValues) {
float data[] = {
0.0f, 1.0f,
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);
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);
// precision and inaccuracies in the polynomial approximation.
expect_equal(expected_data, out_data, 4096, 1, 1.2 / 4095.0, 1e-5);
}
+
+} // namespace movit