Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ad5eb4a authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix broken opto-electronic transfer functions"

parents 53a9de75 3944d06e
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ constexpr mat3 ColorSpace::computeXYZMatrix(
}

static constexpr float rcpResponse(float x, float g,float a, float b, float c, float d) {
    return x >= d * c ? std::pow(x / a, 1.0f / g) - b / a : x / c;
    return x >= d * c ? (std::pow(x, 1.0f / g) - b) / a : x / c;
}

static constexpr float response(float x, float g, float a, float b, float c, float d) {
@@ -216,7 +216,7 @@ const ColorSpace ColorSpace::DCIP3() {
    return {
        "SMPTE RP 431-2-2007 DCI (P3)",
        {{float2{0.680f, 0.320f}, {0.265f, 0.690f}, {0.150f, 0.060f}}},
        {0.3127f, 0.3290f},
        {0.314f, 0.351f},
        std::bind(powf, _1, 1.0f / 2.6f),
        std::bind(powf, _1, 2.6f)
    };
+5 −0
Original line number Diff line number Diff line
@@ -106,6 +106,11 @@ TEST_F(ColorSpaceTest, XYZFromPrimaries) {
TEST_F(ColorSpaceTest, TransferFunctions) {
    ColorSpace sRGB = ColorSpace::sRGB();

    EXPECT_NEAR(0.0f, sRGB.getEOTF()(0.0f), 1e-6f);
    EXPECT_NEAR(0.0f, sRGB.getOETF()(0.0f), 1e-6f);
    EXPECT_NEAR(1.0f, sRGB.getEOTF()(1.0f), 1e-6f);
    EXPECT_NEAR(1.0f, sRGB.getOETF()(1.0f), 1e-6f);

    for (float v = 0.0f; v <= 0.5f; v += 1e-3f) {
        ASSERT_TRUE(v >= sRGB.getEOTF()(v));
        ASSERT_TRUE(v <= sRGB.getOETF()(v));