Commit 4c395a45 for libheif

commit 4c395a450b3cc565a2ea12da3ad8f121c241a395
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Fri May 15 17:38:00 2026 +0200

    add human-readable output of nclx/clli (#1789)

diff --git a/examples/heif_info.cc b/examples/heif_info.cc
index f84b4872..d391abe6 100644
--- a/examples/heif_info.cc
+++ b/examples/heif_info.cc
@@ -120,6 +120,73 @@ public:
 };


+static const char* color_primaries_name(uint16_t v)
+{
+  switch (v) {
+    case heif_color_primaries_ITU_R_BT_709_5: return "BT.709";
+    case heif_color_primaries_unspecified: return "unspecified";
+    case heif_color_primaries_ITU_R_BT_470_6_System_M: return "BT.470 System M";
+    case heif_color_primaries_ITU_R_BT_470_6_System_B_G: return "BT.470 System B/G";
+    case heif_color_primaries_ITU_R_BT_601_6: return "BT.601";
+    case heif_color_primaries_SMPTE_240M: return "SMPTE 240M";
+    case heif_color_primaries_generic_film: return "generic film";
+    case heif_color_primaries_ITU_R_BT_2020_2_and_2100_0: return "BT.2020 / BT.2100";
+    case heif_color_primaries_SMPTE_ST_428_1: return "SMPTE ST 428-1";
+    case heif_color_primaries_SMPTE_RP_431_2: return "SMPTE RP 431-2 (DCI P3)";
+    case heif_color_primaries_SMPTE_EG_432_1: return "SMPTE EG 432-1 (Display P3)";
+    case heif_color_primaries_EBU_Tech_3213_E: return "EBU Tech 3213-E";
+    default: return "unknown";
+  }
+}
+
+
+static const char* transfer_characteristics_name(uint16_t v)
+{
+  switch (v) {
+    case heif_transfer_characteristic_ITU_R_BT_709_5: return "BT.709";
+    case heif_transfer_characteristic_unspecified: return "unspecified";
+    case heif_transfer_characteristic_ITU_R_BT_470_6_System_M: return "BT.470 System M";
+    case heif_transfer_characteristic_ITU_R_BT_470_6_System_B_G: return "BT.470 System B/G";
+    case heif_transfer_characteristic_ITU_R_BT_601_6: return "BT.601";
+    case heif_transfer_characteristic_SMPTE_240M: return "SMPTE 240M";
+    case heif_transfer_characteristic_linear: return "linear";
+    case heif_transfer_characteristic_logarithmic_100: return "log 100:1";
+    case heif_transfer_characteristic_logarithmic_100_sqrt10: return "log 100*sqrt(10):1";
+    case heif_transfer_characteristic_IEC_61966_2_4: return "IEC 61966-2-4";
+    case heif_transfer_characteristic_ITU_R_BT_1361: return "BT.1361";
+    case heif_transfer_characteristic_IEC_61966_2_1: return "IEC 61966-2-1 (sRGB)";
+    case heif_transfer_characteristic_ITU_R_BT_2020_2_10bit: return "BT.2020 10-bit";
+    case heif_transfer_characteristic_ITU_R_BT_2020_2_12bit: return "BT.2020 12-bit";
+    case heif_transfer_characteristic_ITU_R_BT_2100_0_PQ: return "BT.2100 PQ";
+    case heif_transfer_characteristic_SMPTE_ST_428_1: return "SMPTE ST 428-1";
+    case heif_transfer_characteristic_ITU_R_BT_2100_0_HLG: return "BT.2100 HLG";
+    default: return "unknown";
+  }
+}
+
+
+static const char* matrix_coefficients_name(uint16_t v)
+{
+  switch (v) {
+    case heif_matrix_coefficients_RGB_GBR: return "RGB/GBR";
+    case heif_matrix_coefficients_ITU_R_BT_709_5: return "BT.709";
+    case heif_matrix_coefficients_unspecified: return "unspecified";
+    case heif_matrix_coefficients_US_FCC_T47: return "US FCC T47";
+    case heif_matrix_coefficients_ITU_R_BT_470_6_System_B_G: return "BT.470 System B/G";
+    case heif_matrix_coefficients_ITU_R_BT_601_6: return "BT.601";
+    case heif_matrix_coefficients_SMPTE_240M: return "SMPTE 240M";
+    case heif_matrix_coefficients_YCgCo: return "YCgCo";
+    case heif_matrix_coefficients_ITU_R_BT_2020_2_non_constant_luminance: return "BT.2020 NCL";
+    case heif_matrix_coefficients_ITU_R_BT_2020_2_constant_luminance: return "BT.2020 CL";
+    case heif_matrix_coefficients_SMPTE_ST_2085: return "SMPTE ST 2085";
+    case heif_matrix_coefficients_chromaticity_derived_non_constant_luminance: return "chromaticity-derived NCL";
+    case heif_matrix_coefficients_chromaticity_derived_constant_luminance: return "chromaticity-derived CL";
+    case heif_matrix_coefficients_ICtCp: return "ICtCp";
+    default: return "unknown";
+  }
+}
+
+
 int main(int argc, char** argv)
 {
   // This takes care of initializing libheif and also deinitializing it at the end to free all resources.
@@ -378,15 +445,27 @@ int main(int argc, char** argv)

     uint32_t profileType = heif_image_handle_get_color_profile_type(handle);
     printf("  color profile: %s\n", profileType ? heif_examples::fourcc_to_string(profileType).c_str() : "no");
-
-    heif_color_profile_nclx* nclx = NULL;
+
+    heif_color_profile_nclx* nclx = nullptr;
     err = heif_image_handle_get_nclx_color_profile(handle, &nclx);
     if (err.code == heif_error_Ok && nclx) {
-      printf("    matrix coefficients: %d, transfer characteristics: %d, colour primaries: %d, full range flag: %d\n",
-             nclx->matrix_coefficients, nclx->transfer_characteristics, nclx->color_primaries, nclx->full_range_flag);
+      printf("    colour primaries: %d (%s)\n",
+             nclx->color_primaries, color_primaries_name(nclx->color_primaries));
+      printf("    transfer characteristics: %d (%s)\n",
+             nclx->transfer_characteristics, transfer_characteristics_name(nclx->transfer_characteristics));
+      printf("    matrix coefficients: %d (%s)\n",
+             nclx->matrix_coefficients, matrix_coefficients_name(nclx->matrix_coefficients));
+      printf("    full range flag: %d (%s)\n",
+             nclx->full_range_flag, nclx->full_range_flag ? "full" : "limited");
+    }
+    heif_nclx_color_profile_free(nclx);
+
+    heif_content_light_level cll = {0, 0};
+    if (heif_image_handle_get_content_light_level(handle, &cll) &&
+        (cll.max_content_light_level > 0 || cll.max_pic_average_light_level > 0)) {
+      printf("  content light level: MaxCLL=%u MaxFALL=%u\n",
+             cll.max_content_light_level, cll.max_pic_average_light_level);
     }
-    if(nclx)
-      heif_nclx_color_profile_free(nclx);

     // --- depth information

@@ -496,14 +575,7 @@ int main(int argc, char** argv)
     else {
       printf("  none\n");
     }
-
-    heif_content_light_level cll = { 0,0 };
-    if (heif_image_handle_get_content_light_level(handle, &cll)) {
-      if (cll.max_content_light_level > 0 || cll.max_pic_average_light_level > 0) {
-        printf("content light level metadata: MaxCLL=%d MaxFALL=%d\n", cll.max_content_light_level, cll.max_pic_average_light_level);
-      }
-    }
-
+
     // --- transforms

 #define MAX_PROPERTIES 50