Apple Log / Rec.2020

图 1:Apple Log / Rec.2020 — CIE 1931 xy。
图 2:Apple Log / Rec.2020 编码曲线,L = 0.18 × 2^stops。
xy
Red0.70800.2920
Green0.17000.7970
Blue0.13100.0460
White (D65)0.31270.3290

传递函数

曲线Apple-log
黑点 / 白点(10-bit 码值)0 / 1023
线性 0 → 编码0.1505
18% 灰 → 编码0.4883
线性 1.0 → 编码0.6946

编码:convertFromLinear

vec4 convertFromLinear(vec4 val, int clip)
{
    float b = 0.00964052;
    float c = 0.08550479;
    float d = 0.69336945;
    float e = 0.05641088;
    float f = 47.28711236;
    float o = 0.208555315954642;
    float o2 = pow(o / f, 0.5) - e; 

    vec3 P = max(val.rgb,-e);

    P.r = P.r > o2 ? c*log(P.r+b)/log(2.0)+d : (P.r + e) * (P.r + e) * f;
    P.g = P.g > o2 ? c*log(P.g+b)/log(2.0)+d : (P.g + e) * (P.g + e) * f;
    P.b = P.b > o2 ? c*log(P.b+b)/log(2.0)+d : (P.b + e) * (P.b + e) * f;

    return vec4(P.rgb, val.a);
}

解码:convertToLinear

vec4 convertToLinear(vec4 val)
{
    float b = 0.00964052;
    float c = 0.08550479;
    float d = 0.69336945;
    float e = 0.05641088;
    float f = 47.28711236;
    float o = 0.208555315954642;

    vec3 P = max(val.rgb,vec3(0.0));

    P.r = P.r > o ? (pow(2.0,((P.r - d) / c))) - b :  pow(P.r / f, 0.5) - e ;
    P.g = P.g > o ? (pow(2.0,((P.g - d) / c))) - b :  pow(P.g / f, 0.5) - e ;
    P.b = P.b > o ? (pow(2.0,((P.b - d) / c))) - b :  pow(P.b / f, 0.5) - e ;

    return vec4(P.rgb, val.a);
}

RGB → XYZ 矩阵

RGB → XYZ
[ 0.636958048301 0.144616903586 0.168880975164 ]
[ 0.262700212011 0.677998071519 0.059301716470 ]
[ 0.000000000000 0.028072693049 1.060985057711 ]

用这个空间 色域比对 ↗ 传递函数比对 ↗

来源

  1. Apple Developer:AVCaptureColorSpace.appleLog