Commit 1b5c3cc2 for libheif

commit 1b5c3cc211fe538229c38e6924c7fab1d40dfd08
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Thu Dec 18 18:13:32 2025 +0100

    support reading 'nclc' color profile

diff --git a/libheif/nclx.cc b/libheif/nclx.cc
index a08c70a5..4e11f68c 100644
--- a/libheif/nclx.cc
+++ b/libheif/nclx.cc
@@ -234,6 +234,26 @@ Error color_profile_nclx::parse(BitstreamRange& range)
   return Error::Ok;
 }

+Error color_profile_nclx::parse_nclc(BitstreamRange& range)
+{
+  StreamReader::grow_status status;
+  status = range.wait_for_available_bytes(6);
+  if (status != StreamReader::grow_status::size_reached) {
+    // TODO: return recoverable error at timeout
+    return Error(heif_error_Invalid_input,
+                 heif_suberror_End_of_data);
+  }
+
+  m_profile.m_colour_primaries = range.read16();
+  m_profile.m_transfer_characteristics = range.read16();
+  m_profile.m_matrix_coefficients = range.read16();
+
+  // use full range for RGB, limited range otherwise
+  m_profile.m_full_range_flag = (m_profile.m_matrix_coefficients == 0);
+
+  return Error::Ok;
+}
+
 Error nclx_profile::get_nclx_color_profile(heif_color_profile_nclx** out_data) const
 {
   *out_data = nullptr;
@@ -371,6 +391,14 @@ Error Box_colr::parse(BitstreamRange& range, const heif_security_limits* limits)
       return err;
     }
   }
+  else if (colour_type == fourcc("nclc")) {
+    auto color_profile = std::make_shared<color_profile_nclx>();
+    m_color_profile = color_profile;
+    Error err = color_profile->parse_nclc(range);
+    if (err) {
+      return err;
+    }
+  }
   else if (colour_type == fourcc("prof") ||
            colour_type == fourcc("rICC")) {
     if (!has_fixed_box_size()) {
diff --git a/libheif/nclx.h b/libheif/nclx.h
index 17f893ab..715fa5f8 100644
--- a/libheif/nclx.h
+++ b/libheif/nclx.h
@@ -185,6 +185,8 @@ public:

   Error parse(BitstreamRange& range);

+  Error parse_nclc(BitstreamRange& range);
+
   Error write(StreamWriter& writer) const override;

   nclx_profile get_nclx_color_profile() const { return m_profile; }