From e8b8c6c9dbb4c5c68b70f43f45764e8dac404bff Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 12 Oct 2012 22:52:28 +0200 Subject: [PATCH 1/1] Add unit tests for Rec. 709 gamma expansion. --- gamma_expansion_effect_test.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/gamma_expansion_effect_test.cpp b/gamma_expansion_effect_test.cpp index 0fd9a71..b315d8f 100644 --- a/gamma_expansion_effect_test.cpp +++ b/gamma_expansion_effect_test.cpp @@ -33,3 +33,33 @@ TEST(GammaExpansionEffectTest, sRGB_RampAlwaysIncreases) { << "No increase between " << i-1 << " and " << i; } } + +TEST(GammaExpansionEffectTest, Rec709_KeyValues) { + float data[] = { + 0.0f, 1.0f, + 0.080f, 0.082f, // On either side of the discontinuity. + }; + float expected_data[] = { + 0.0f, 1.0f, + 0.017778f, 0.018167f, + }; + float out_data[4]; + EffectChainTester tester(data, 2, 2, COLORSPACE_sRGB, GAMMA_REC_709); + tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + + expect_equal(expected_data, out_data, 2, 2); +} + +TEST(GammaExpansionEffectTest, Rec709_RampAlwaysIncreases) { + float data[256], out_data[256]; + for (unsigned i = 0; i < 256; ++i) { + data[i] = i / 255.0f; + } + EffectChainTester tester(data, 256, 1, COLORSPACE_sRGB, GAMMA_REC_709); + tester.run(out_data, COLORSPACE_sRGB, GAMMA_LINEAR); + + for (unsigned i = 1; i < 256; ++i) { + EXPECT_GT(out_data[i], out_data[i - 1]) + << "No increase between " << i-1 << " and " << i; + } +} -- 2.39.2