Commit 52c91b32 for libheif
commit 52c91b327dfd4eb761c50adb18696bf8a05141c7
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Sun May 17 15:19:12 2026 +0200
remove heif_omaf_image_projection_unknown
diff --git a/libheif/api/libheif/heif_image.h b/libheif/api/libheif/heif_image.h
index 3cdfac14..2e718665 100644
--- a/libheif/api/libheif/heif_image.h
+++ b/libheif/api/libheif/heif_image.h
@@ -154,11 +154,12 @@ typedef enum heif_omaf_image_projection
*/
heif_omaf_image_projection_cube_map = 0x01,
- /* Values 2 through 31 are reserved in ISO/IEC 23090-2:2023 Table 10. */
- /**
- * Projection is specified, but not recognised.
+ /*
+ * Values 2 through 31 are reserved in ISO/IEC 23090-2:2023 Table 10.
+ * Files may carry any of them; libheif passes the raw projection_type
+ * value through unchanged, so callers can log or round-trip it.
+ * Handle anything outside the named constants in a `default:` arm.
*/
- heif_omaf_image_projection_unknown = 0xFE,
/**
* Flat projection. Also returned by the get-projection accessors when no
diff --git a/libheif/omaf_boxes.cc b/libheif/omaf_boxes.cc
index 4b45630f..2297d45c 100644
--- a/libheif/omaf_boxes.cc
+++ b/libheif/omaf_boxes.cc
@@ -34,18 +34,7 @@ Error Box_prfr::parse(BitstreamRange& range, const heif_security_limits* limits)
}
uint8_t projection_type = (range.read8() & 0x1F);
- switch (projection_type)
- {
- case 0x00:
- m_projection = heif_omaf_image_projection::heif_omaf_image_projection_equirectangular;
- break;
- case 0x01:
- m_projection = heif_omaf_image_projection::heif_omaf_image_projection_cube_map;
- break;
- default:
- m_projection = heif_omaf_image_projection::heif_omaf_image_projection_unknown;
- break;
- }
+ m_projection = static_cast<heif_omaf_image_projection>(projection_type);
return range.get_error();
}
@@ -70,35 +59,30 @@ std::string Box_prfr::dump(Indent& indent) const
Error Box_prfr::write(StreamWriter& writer) const
{
- size_t box_start = reserve_box_header_space(writer);
- switch (m_projection) {
- case heif_omaf_image_projection::heif_omaf_image_projection_equirectangular:
- writer.write8(0x00);
- break;
- case heif_omaf_image_projection::heif_omaf_image_projection_cube_map:
- writer.write8(0x01);
- break;
- default:
- return {
- heif_error_Invalid_input,
- heif_suberror_Unspecified,
- "Unsupported image projection value."
+ if (static_cast<uint32_t>(m_projection) >= 32) {
+ return {
+ heif_error_Invalid_input,
+ heif_suberror_Unspecified,
+ "Image projection value out of the 5-bit prfr range."
};
}
+
+ size_t box_start = reserve_box_header_space(writer);
+ writer.write8(static_cast<uint8_t>(m_projection) & 0x1F);
prepend_header(writer, box_start);
return Error::Ok;
}
Error Box_prfr::set_image_projection(heif_omaf_image_projection projection)
{
- if ((projection == heif_omaf_image_projection::heif_omaf_image_projection_equirectangular) || (projection == heif_omaf_image_projection::heif_omaf_image_projection_cube_map)) {
- m_projection = projection;
- return Error::Ok;
- } else {
+ if (static_cast<uint32_t>(projection) >= 32) {
return {
heif_error_Invalid_input,
heif_suberror_Unspecified,
- "Unsupported image projection value."
+ "Image projection value out of the 5-bit prfr range."
};
}
+
+ m_projection = projection;
+ return Error::Ok;
}