Commit b51817ba for libheif
commit b51817ba5324d8d006ef8f2a311df593b284a491
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Fri May 15 23:28:31 2026 +0200
colr mismatch: refer to both 14496-12 and 23000-22
diff --git a/libheif/api/libheif/heif_error.h b/libheif/api/libheif/heif_error.h
index 29a09f10..c0de48f1 100644
--- a/libheif/api/libheif/heif_error.h
+++ b/libheif/api/libheif/heif_error.h
@@ -192,7 +192,8 @@ typedef enum heif_suberror_code
heif_suberror_No_moov_box = 151,
// The colr (NCLX) box and the codec bitstream VUI/color signalling disagree.
- // Per ISO/IEC 14496-12 the colr box takes precedence, but the conflict is reported as a warning.
+ // Per ISO/IEC 14496-12 and ISO/IEC 23000-22 (MIAF) the colr box takes precedence,
+ // but the conflict is reported as a warning.
heif_suberror_NCLX_colr_VUI_mismatch = 152,
// --- Memory_allocation_error ---
diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc
index 9314cb40..23ac5865 100644
--- a/libheif/image-items/image_item.cc
+++ b/libheif/image-items/image_item.cc
@@ -1042,10 +1042,11 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem::decode_image(const heif_decod
if (!nclx.is_undefined()) {
// If the decoder plugin populated an NCLX profile from the bitstream's
// color signalling (e.g. HEVC SPS VUI, AV1 sequence header), compare it
- // against the colr box. Per ISO/IEC 14496-12 §12.1.5.1 the colr box
- // overrides the bitstream, but a mismatch is a strong indication of a
- // muxer bug (e.g. some Sony cameras mis-tag full_range_flag in colr while
- // the bitstream VUI is correct) and is worth surfacing as a warning.
+ // against the colr box. Per ISO/IEC 14496-12 and ISO/IEC 23000-22 (MIAF)
+ // the colr box overrides the bitstream, but a mismatch is a strong
+ // indication of a muxer bug (e.g. some Sony cameras mis-tag full_range_flag
+ // in colr while the bitstream VUI is correct, see issue #1770) and is
+ // worth surfacing as a warning.
auto bitstream_nclx = img->get_color_profile_nclx();
if (!bitstream_nclx.is_undefined()) {
auto cicp_mismatch = [](uint16_t bs, uint16_t cr) {
@@ -1066,7 +1067,7 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem::decode_image(const heif_decod
<< bitstream_nclx.m_transfer_characteristics << "/"
<< bitstream_nclx.m_matrix_coefficients << "/"
<< (bitstream_nclx.m_full_range_flag ? "full" : "limited")
- << "); colr takes precedence per ISO/IEC 14496-12";
+ << "); colr takes precedence per ISO/IEC 14496-12 and ISO/IEC 23000-22 (MIAF)";
add_decoding_warning({heif_error_Invalid_input,
heif_suberror_NCLX_colr_VUI_mismatch,
msg.str()});