0fd9a71dd57518e8b28fba15268a7690fa2754b6
[movit] / gamma_expansion_effect_test.cpp
1 // Unit tests for GammaExpansionEffect.
2
3 #include "test_util.h"
4 #include "gtest/gtest.h"
5 #include "gamma_expansion_effect.h"
6
7 TEST(GammaExpansionEffectTest, sRGB_KeyValues) {
8         float data[] = {
9                 0.0f, 1.0f,
10                 0.040f, 0.041f,  // On either side of the discontinuity.
11         };
12         float expected_data[] = {
13                 0.0f, 1.0f,
14                 0.00309f, 0.00317f, 
15         };
16         float out_data[4];
17         EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_sRGB);
18         tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
19
20         expect_equal(expected_data, out_data, 2, 2);
21 }
22
23 TEST(GammaExpansionEffectTest, sRGB_RampAlwaysIncreases) {
24         float data[256], out_data[256];
25         for (unsigned i = 0; i < 256; ++i) {
26                 data[i] = i / 255.0f;
27         }
28         EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_sRGB);
29         tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR);
30
31         for (unsigned i = 1; i < 256; ++i) {
32                 EXPECT_GT(out_data[i], out_data[i - 1])
33                    << "No increase between " << i-1 << " and " << i;
34         }
35 }