Commit 1b10345f for libheif
commit 1b10345fea42b16fcf69e583743b4e75d28fce37
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Sat May 16 01:20:42 2026 +0200
add TODO comment for 'BT.2020 CL' implementation
diff --git a/libheif/color-conversion/rgb2yuv.cc b/libheif/color-conversion/rgb2yuv.cc
index da952900..03d39690 100644
--- a/libheif/color-conversion/rgb2yuv.cc
+++ b/libheif/color-conversion/rgb2yuv.cc
@@ -58,6 +58,9 @@ Op_RGB_to_YCbCr<Pixel>::state_after_conversion(const ColorState& input_state,
if (matrix == 11 || matrix == 14) {
return {};
}
+ // TODO: matrix == 10 (BT.2020 CL) currently falls through and is encoded as if it were
+ // BT.2020 NCL. A correct CL path needs OETF application before deriving Y'C, not the
+ // linear matrix below.
std::vector<ColorStateWithCost> states;
diff --git a/libheif/color-conversion/yuv2rgb.cc b/libheif/color-conversion/yuv2rgb.cc
index 134afa19..2f9da948 100644
--- a/libheif/color-conversion/yuv2rgb.cc
+++ b/libheif/color-conversion/yuv2rgb.cc
@@ -52,6 +52,8 @@ Op_YCbCr_to_RGB<Pixel>::state_after_conversion(const ColorState& input_state,
if (matrix == 11 || matrix == 14) {
return {};
}
+ // TODO: matrix == 10 (BT.2020 CL) currently falls through and is decoded as if it were
+ // BT.2020 NCL. A correct CL path needs EOTF inversion on Cb/Cr, not the linear matrix below.
bool hdr = !std::is_same<Pixel, uint8_t>::value;
diff --git a/libheif/nclx.cc b/libheif/nclx.cc
index 4e11f68c..f048c5b9 100644
--- a/libheif/nclx.cc
+++ b/libheif/nclx.cc
@@ -127,6 +127,9 @@ Kr_Kb get_Kr_Kb(uint16_t matrix_coefficients_idx, uint16_t primaries_idx)
break;
case 9:
case 10:
+ // TODO: case 10 is BT.2020 constant-luminance, which is not a linear matrix conversion
+ // (Y' is derived from gamma-corrected linear luminance; Cb/Cr need EOTF inversion).
+ // We currently fall through to the NCL coefficients, which is wrong for CL content.
result.Kr = 0.2627f;
result.Kb = 0.0593f;
break;