iPhone 15 to have true log / ACES support

Here’s the Apple Log Profile ACES IDT based on the Apple White Paper in GLSL. The matrix values are derived from BT2020 with CIECAT02 adaptation. Maybe someone can convert it to a DCTL and compare to the reference implementation (?) in Resolve.

// Apple Log Gamma to Linear Decoding Function
float appleLogToLinear(float x)  {

    const float R_0 = -0.05641088;
    const float R_t = 0.01;
    const float c = 47.28711236;
    const float beta = 0.00964052;
    const float gamma = 0.08550479;
    const float delta = 0.69336945;
    const float P_t = c * pow(R_t - R_0, 2.0);

    if (x >= P_t) {
        return pow(2.0, (x - delta) / gamma) - beta;
    } else if (x >= 0.0 && x < P_t) {
        return sqrt(x / c) + R_0;
    } else {
        return R_0;
    }

}
// Apple Log Profile to ACES_2065-1 (AP0) Linear
vec3 IDT(vec3 AppleLog) {
  float r_lin = appleLogToLinear(AppleLog.x);
  float g_lin = appleLogToLinear(AppleLog.y);
  float b_lin = appleLogToLinear(AppleLog.z);
  vec3 oces = vec3(
    r_lin * 0.6788911506598102 + g_lin * 0.15886842237789234 + b_lin * 0.16224042703562752,
    r_lin * 0.04557083087232135 + g_lin * 0.8607127720474108 + b_lin * 0.0937163970408747,
    r_lin * -0.0004857103518124508 + g_lin * 0.025060195735059528 + b_lin * 0.9754255145687619
  );
  return oces;
}
2 Likes