]> git.sesse.net Git - movit/blobdiff - gamma_expansion_effect_test.cpp
Add an assertion failure that we don't add the same effect instance twice.
[movit] / gamma_expansion_effect_test.cpp
index 94f574999692aeacff184c9bc2310da6c27e21db..dc50f911f9dca122e1e6e67a1eee6131b1305dbd 100644 (file)
@@ -1,8 +1,10 @@
 // Unit tests for GammaExpansionEffect.
 
-#include "test_util.h"
-#include "gtest/gtest.h"
+#include <GL/glew.h>
+
 #include "gamma_expansion_effect.h"
+#include "gtest/gtest.h"
+#include "test_util.h"
 
 TEST(GammaExpansionEffectTest, sRGB_KeyValues) {
        float data[] = {
@@ -93,3 +95,24 @@ TEST(GammaExpansionEffectTest, Rec709_AlphaIsUnchanged) {
 
        expect_equal(data, out_data, 5, 1);
 }
+
+TEST(GammaExpansionEffectTest, Rec2020_12BitIsVeryCloseToRec709) {
+       float data[256];
+       for (unsigned i = 0; i < 256; ++i) {
+               data[i] = i / 255.0f;
+       }
+       float out_data_709[256];
+       float out_data_2020[256];
+
+       EffectChainTester tester(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_709);
+       tester.run(out_data_709, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+       EffectChainTester tester2(data, 256, 1, FORMAT_GRAYSCALE, COLORSPACE_sRGB, GAMMA_REC_2020_12_BIT);
+       tester2.run(out_data_2020, GL_RED, COLORSPACE_sRGB, GAMMA_LINEAR);
+
+       double sqdiff = 0.0;
+       for (unsigned i = 0; i < 256; ++i) {
+               EXPECT_NEAR(out_data_709[i], out_data_2020[i], 1e-3);
+               sqdiff += (out_data_709[i] - out_data_2020[i]) * (out_data_709[i] - out_data_2020[i]);
+       }
+       EXPECT_GT(sqdiff, 1e-6);
+}