Commit b81e1487 for libheif
commit b81e1487a34750dc2bd83f1b24cd5745b6235a70
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Sun May 17 15:06:43 2026 +0200
avoid HEIF_WITH_OMAF in public header
diff --git a/libheif/api/libheif/heif_image.cc b/libheif/api/libheif/heif_image.cc
index bc54219f..b2106c1c 100644
--- a/libheif/api/libheif/heif_image.cc
+++ b/libheif/api/libheif/heif_image.cc
@@ -315,17 +315,25 @@ void heif_image_handle_set_pixel_aspect_ratio(heif_image_handle* handle, uint32_
handle->image->set_pixel_ratio(aspect_h, aspect_v);
}
-#if HEIF_WITH_OMAF
heif_omaf_image_projection heif_image_get_omaf_image_projection(const heif_image* image)
{
+#if HEIF_WITH_OMAF
return image->image->get_omaf_image_projection();
+#else
+ (void) image;
+ return heif_omaf_image_projection_flat;
+#endif
}
void heif_image_set_omaf_image_projection(const heif_image* image, heif_omaf_image_projection image_projection)
{
- return image->image->set_omaf_image_projection(image_projection);
-}
+#if HEIF_WITH_OMAF
+ image->image->set_omaf_image_projection(image_projection);
+#else
+ (void) image;
+ (void) image_projection;
#endif
+}
heif_error heif_image_create(int width, int height,
heif_colorspace colorspace,
diff --git a/libheif/api/libheif/heif_image.h b/libheif/api/libheif/heif_image.h
index b5bcdf6e..665303fa 100644
--- a/libheif/api/libheif/heif_image.h
+++ b/libheif/api/libheif/heif_image.h
@@ -128,7 +128,6 @@ typedef enum heif_channel
heif_channel_unknown = 65535
} heif_channel;
-#if HEIF_WITH_OMAF
/**
* OMAF Image projection.
*
@@ -137,6 +136,11 @@ typedef enum heif_channel
* equivalent), there are alternatives such as an equirectangular projection or cubemap projection.
*
* See ISO/IEC 23090-2 "Omnidirectional media format" for more information.
+ *
+ * The accessor functions are always present in the API, but reading/writing OMAF
+ * projection information only has an effect when libheif was built with OMAF
+ * support. Without it, the getters return `heif_omaf_image_projection_flat` and
+ * the setters are no-ops.
*/
typedef enum heif_omaf_image_projection
{
@@ -161,7 +165,6 @@ typedef enum heif_omaf_image_projection
*/
heif_omaf_image_projection_flat = 0xFF,
} heif_omaf_image_projection;
-#endif
// An heif_image contains a decoded pixel image in various colorspaces, chroma formats,
// and bit depths.
@@ -360,13 +363,11 @@ void heif_image_set_pixel_aspect_ratio(heif_image*, uint32_t aspect_h, uint32_t
LIBHEIF_API
void heif_image_handle_set_pixel_aspect_ratio(heif_image_handle*, uint32_t aspect_h, uint32_t aspect_v);
-#if HEIF_WITH_OMAF
LIBHEIF_API
heif_omaf_image_projection heif_image_get_omaf_image_projection(const heif_image*);
LIBHEIF_API
void heif_image_set_omaf_image_projection(const heif_image*, heif_omaf_image_projection image_projection);
-#endif
// --- heif_image allocation
diff --git a/libheif/api/libheif/heif_properties.cc b/libheif/api/libheif/heif_properties.cc
index ad48c2c9..4e809956 100644
--- a/libheif/api/libheif/heif_properties.cc
+++ b/libheif/api/libheif/heif_properties.cc
@@ -458,23 +458,41 @@ heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_ex
return heif_error_success;
}
-#if HEIF_WITH_OMAF
int heif_image_handle_has_omaf_image_projection(const heif_image_handle* handle)
{
if (!handle) {
return false;
}
+#if HEIF_WITH_OMAF
return handle->image->has_omaf_image_projection();
+#else
+ return false;
+#endif
}
heif_omaf_image_projection heif_image_handle_get_omaf_image_projection(const heif_image_handle* handle)
{
+#if HEIF_WITH_OMAF
return handle->image->get_omaf_image_projection();
+#else
+ (void) handle;
+ return heif_omaf_image_projection_flat;
+#endif
}
-void heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_omaf_image_projection image_projection)
+heif_error heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_omaf_image_projection image_projection)
{
- return handle->image->set_omaf_image_projection(image_projection);
-}
+#if HEIF_WITH_OMAF
+ if (!handle) {
+ return heif_error_null_pointer_argument;
+ }
+ handle->image->set_omaf_image_projection(image_projection);
+ return heif_error_success;
+#else
+ (void) handle;
+ (void) image_projection;
+ return {heif_error_Unsupported_feature, heif_suberror_Unspecified,
+ "libheif was built without OMAF support"};
#endif
+}
diff --git a/libheif/api/libheif/heif_properties.h b/libheif/api/libheif/heif_properties.h
index 8f727856..ca33a7b1 100644
--- a/libheif/api/libheif/heif_properties.h
+++ b/libheif/api/libheif/heif_properties.h
@@ -228,8 +228,11 @@ LIBHEIF_API
heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_extrinsic_matrix*,
double* out_matrix_row_major);
-#if HEIF_WITH_OMAF
// ------------------------- OMAF projection information -------------------------
+// These accessors are always present in the API. When libheif was built without
+// OMAF support, the query functions report "no projection" (0 /
+// heif_omaf_image_projection_flat) and the setter returns
+// heif_error_Unsupported_feature.
LIBHEIF_API
int heif_image_handle_has_omaf_image_projection(const heif_image_handle* handle);
@@ -237,8 +240,7 @@ LIBHEIF_API
heif_omaf_image_projection heif_image_handle_get_omaf_image_projection(const heif_image_handle* handle);
LIBHEIF_API
-void heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_omaf_image_projection image_projection);
-#endif
+heif_error heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_omaf_image_projection image_projection);
#ifdef __cplusplus
}