Commit 5721b71c for libheif

commit 5721b71c9100c34204d25b2197de083681fb0e1b
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Tue Feb 24 14:05:35 2026 +0100

    omaf: fix compilation and add _omaf_ prefix to types and function names (#1707)

diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc
index 334b5895..24175c81 100644
--- a/examples/heif_enc.cc
+++ b/examples/heif_enc.cc
@@ -127,8 +127,7 @@ std::string option_gimi_track_id;
 std::string option_sai_data_file;

 #if HEIF_WITH_OMAF
-int option_image_projection;
-heif_image_projection image_projection = heif_image_projection::flat;
+std::optional<heif_omaf_image_projection> omaf_image_projection;
 #endif

 enum heif_output_nclx_color_profile_preset
@@ -197,7 +196,7 @@ const int OPTION_SEQUENCES_GIMI_TRACK_ID = 1035;
 const int OPTION_SEQUENCES_SAI_DATA_FILE = 1036;
 const int OPTION_USE_HEVC_COMPRESSION = 1037;
 #if HEIF_WITH_OMAF
-const int OPTION_SET_IMAGE_PROJECTION = 1038;
+const int OPTION_SET_OMAF_IMAGE_PROJECTION = 1038;
 #endif

 static option long_options[] = {
@@ -268,7 +267,7 @@ static option long_options[] = {
     {(char* const) "set-gimi-track-id",           required_argument,       nullptr, OPTION_SEQUENCES_GIMI_TRACK_ID},
     {(char* const) "sai-data-file",               required_argument,       nullptr, OPTION_SEQUENCES_SAI_DATA_FILE},
 #if HEIF_WITH_OMAF
-    {(char* const) "image-projection",            required_argument,       nullptr, OPTION_SET_IMAGE_PROJECTION},
+    {(char* const) "omaf-image-projection",       required_argument,       nullptr, OPTION_SET_OMAF_IMAGE_PROJECTION},
 #endif
     {0, 0,                                                           0,  0}
 };
@@ -405,7 +404,7 @@ void show_help(const char* argv0)
 #endif
 #if HEIF_WITH_OMAF
             << "omnidirectional imagery:\n"
-            << "      --image-projection proj    set the image projection (0 = equirectangular, 1 = cube map)\n"
+            << "      --omaf-image-projection PROJ    set the image projection (equirectangular, cube-map)\n"
 #endif
             ;
 }
@@ -1620,14 +1619,13 @@ int main(int argc, char** argv)
         option_sai_data_file = optarg;
         break;
 #if HEIF_WITH_OMAF
-      case OPTION_SET_IMAGE_PROJECTION:
-        option_image_projection = atoi(optarg);
-        if (option_image_projection == 0) {
-          image_projection = heif_image_projection::equirectangular;
-        } else if (option_image_projection == 1) {
-          image_projection = heif_image_projection::cube_map;
+      case OPTION_SET_OMAF_IMAGE_PROJECTION:
+        if (strcmp(optarg, "equirectangular") == 0) {
+          omaf_image_projection = heif_omaf_image_projection_equirectangular;
+        } else if (strcmp(optarg, "cube-map") == 0) {
+          omaf_image_projection = heif_omaf_image_projection_cube_map;
         } else {
-          std::cerr << "image projection must be 0 or 1\n";
+          std::cerr << "image projection must be 'equirectangular' or 'cube-map'\n";
           return 5;
         }
         break;
@@ -2047,8 +2045,8 @@ int do_encode_images(heif_context* context, heif_encoder* encoder, heif_encoding
     }

 #if HEIF_WITH_OMAF
-    if (image_projection != heif_image_projection::flat) {
-      heif_image_handle_set_image_projection(handle, image_projection);
+    if (omaf_image_projection) {
+      heif_image_handle_set_omaf_image_projection(handle, *omaf_image_projection);
     }
 #endif

diff --git a/examples/heif_info.cc b/examples/heif_info.cc
index c4dc685a..46f1eea2 100644
--- a/examples/heif_info.cc
+++ b/examples/heif_info.cc
@@ -781,16 +781,16 @@ int main(int argc, char** argv)
 #if HEIF_WITH_OMAF
     // --- OMAF

-    if (heif_image_handle_has_image_projection(handle)) {
-      heif_image_projection projection = heif_image_handle_get_image_projection(handle);
+    if (heif_image_handle_has_omaf_image_projection(handle)) {
+      heif_omaf_image_projection projection = heif_image_handle_get_omaf_image_projection(handle);
       std::cout << "  image projection: ";
       switch (projection)
       {
-      case heif_image_projection::equirectangular:
+      case heif_omaf_image_projection_equirectangular:
         std::cout << "equirectangular";
         break;
-      case heif_image_projection::cube_map:
-        std::cout << "cube map";
+      case heif_omaf_image_projection_cube_map:
+        std::cout << "cube-map";
       default:
         std::cout << "(unknown)";
         break;
diff --git a/libheif/api/libheif/heif_image.cc b/libheif/api/libheif/heif_image.cc
index 1f82dfed..013fff39 100644
--- a/libheif/api/libheif/heif_image.cc
+++ b/libheif/api/libheif/heif_image.cc
@@ -308,14 +308,14 @@ void heif_image_handle_set_pixel_aspect_ratio(heif_image_handle* handle, uint32_
 }

 #if HEIF_WITH_OMAF
-heif_image_projection heif_image_get_image_projection(const heif_image* image)
+heif_omaf_image_projection heif_image_get_omaf_image_projection(const heif_image* image)
 {
-  return image->image->get_image_projection();
+  return image->image->get_omaf_image_projection();
 }

-void heif_image_set_image_projection(const heif_image* image, heif_image_projection image_projection)
+void heif_image_set_omaf_image_projection(const heif_image* image, heif_omaf_image_projection image_projection)
 {
-  return image->image->set_image_projection(image_projection);
+  return image->image->set_omaf_image_projection(image_projection);
 }
 #endif

diff --git a/libheif/api/libheif/heif_image.h b/libheif/api/libheif/heif_image.h
index b5b95a0b..7ba290ee 100644
--- a/libheif/api/libheif/heif_image.h
+++ b/libheif/api/libheif/heif_image.h
@@ -96,7 +96,7 @@ typedef enum heif_channel

 #if HEIF_WITH_OMAF
 /**
- * Image projection.
+ * OMAF Image projection.
  *
  * The image projection for most images is flat - it is projected as intended to be shown on
  * a flat screen or print. For immersive or omnidirectional media (e.g. VR headsets, or
@@ -104,29 +104,29 @@ typedef enum heif_channel
  *
  * See ISO/IEC 23090-2 "Omnidirectional media format" for more information.
  */
-typedef enum heif_image_projection
+typedef enum heif_omaf_image_projection
 {
   /**
    * Equirectangular projection.
    */
-  equirectangular = 0x00,
+  heif_omaf_image_projection_equirectangular = 0x00,

   /**
    * Cube map.
    */
-  cube_map = 0x01,
+  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.
    */
-  unknown_other = 0xFE,
+  heif_omaf_image_projection_unknown = 0xFE,

   /**
    * Flat projection, assumed if no projection information provided.
    */
-  flat = 0xFF,
-} heif_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,
@@ -302,10 +302,10 @@ void heif_image_handle_set_pixel_aspect_ratio(heif_image_handle*, uint32_t aspec

 #if HEIF_WITH_OMAF
 LIBHEIF_API
-heif_image_projection heif_image_get_image_projection(const heif_image*);
+heif_omaf_image_projection heif_image_get_omaf_image_projection(const heif_image*);

 LIBHEIF_API
-void heif_image_set_image_projection(const heif_image*, heif_image_projection image_projection);
+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 a5be076f..ad48c2c9 100644
--- a/libheif/api/libheif/heif_properties.cc
+++ b/libheif/api/libheif/heif_properties.cc
@@ -459,22 +459,22 @@ heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_ex
 }

 #if HEIF_WITH_OMAF
-int heif_image_handle_has_image_projection(const heif_image_handle* handle)
+int heif_image_handle_has_omaf_image_projection(const heif_image_handle* handle)
 {
   if (!handle) {
     return false;
   }

-  return handle->image->has_image_projection();
+  return handle->image->has_omaf_image_projection();
 }

-heif_image_projection heif_image_handle_get_image_projection(const heif_image_handle* handle)
+heif_omaf_image_projection heif_image_handle_get_omaf_image_projection(const heif_image_handle* handle)
 {
-  return handle->image->get_image_projection();
+  return handle->image->get_omaf_image_projection();
 }

-void heif_image_handle_set_image_projection(const heif_image_handle* handle, heif_image_projection image_projection)
+void heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_omaf_image_projection image_projection)
 {
-  return handle->image->set_image_projection(image_projection);
+  return handle->image->set_omaf_image_projection(image_projection);
 }
 #endif
diff --git a/libheif/api/libheif/heif_properties.h b/libheif/api/libheif/heif_properties.h
index 5c20befc..8f727856 100644
--- a/libheif/api/libheif/heif_properties.h
+++ b/libheif/api/libheif/heif_properties.h
@@ -229,15 +229,15 @@ heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_ex
                                                             double* out_matrix_row_major);

 #if HEIF_WITH_OMAF
-// ------------------------- projection information -------------------------
+// ------------------------- OMAF projection information -------------------------
 LIBHEIF_API
-int heif_image_handle_has_image_projection(const heif_image_handle* handle);
+int heif_image_handle_has_omaf_image_projection(const heif_image_handle* handle);

 LIBHEIF_API
-heif_image_projection heif_image_handle_get_image_projection(const heif_image_handle* handle);
+heif_omaf_image_projection heif_image_handle_get_omaf_image_projection(const heif_image_handle* handle);

 LIBHEIF_API
-void heif_image_handle_set_image_projection(const heif_image_handle* handle, heif_image_projection image_projection);
+void heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_omaf_image_projection image_projection);
 #endif

 #ifdef __cplusplus
diff --git a/libheif/color-conversion/colorconversion.cc b/libheif/color-conversion/colorconversion.cc
index cf0a60ed..db6b0b5b 100644
--- a/libheif/color-conversion/colorconversion.cc
+++ b/libheif/color-conversion/colorconversion.cc
@@ -485,7 +485,7 @@ Result<std::shared_ptr<HeifPixelImage>> ColorConversionPipeline::convert_image(c
     out->set_sample_duration(in->get_sample_duration());

 #if HEIF_WITH_OMAF
-    out->set_image_projection(in->get_image_projection());
+    out->set_omaf_image_projection(in->get_omaf_image_projection());
 #endif

     const auto& warnings = in->get_warnings();
diff --git a/libheif/context.cc b/libheif/context.cc
index d72cf54d..3bc91f8c 100644
--- a/libheif/context.cc
+++ b/libheif/context.cc
@@ -694,7 +694,7 @@ Error HeifContext::interpret_heif_file_images()
 #if HEIF_WITH_OMAF
     // add image projection information
     if (auto prfr = image->get_property<Box_prfr>()) {
-      image->set_image_projection(prfr->get_image_projection());
+      image->set_omaf_image_projection(prfr->get_omaf_image_projection());
     }
 #endif
   }
diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc
index 71a725de..bb22a2a8 100644
--- a/libheif/image-items/image_item.cc
+++ b/libheif/image-items/image_item.cc
@@ -681,9 +681,9 @@ void ImageItem::set_color_profile_icc(const std::shared_ptr<const color_profile_
 }

 #if HEIF_WITH_OMAF
-void ImageItem::set_image_projection(heif_image_projection projection)
+void ImageItem::set_omaf_image_projection(heif_omaf_image_projection projection)
 {
-  ImageExtraData::set_image_projection(projection);
+  ImageExtraData::set_omaf_image_projection(projection);
   add_property(get_prfr_box(), true);
 }
 #endif
@@ -923,7 +923,7 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem::decode_image(const heif_decod
     // Image projection (OMAF)
     auto prfr = get_property<Box_prfr>();
     if (prfr) {
-      img->set_image_projection(prfr->get_image_projection());
+      img->set_omaf_image_projection(prfr->get_omaf_image_projection());
     }
 #endif
   }
diff --git a/libheif/image-items/image_item.h b/libheif/image-items/image_item.h
index 5932614f..81e28c51 100644
--- a/libheif/image-items/image_item.h
+++ b/libheif/image-items/image_item.h
@@ -288,7 +288,7 @@ public:
   void set_color_profile_icc(const std::shared_ptr<const color_profile_raw>& profile) override;

 #if HEIF_WITH_OMAF
-  void set_image_projection(heif_image_projection image_projection) override;
+  void set_omaf_image_projection(heif_omaf_image_projection image_projection) override;
 #endif

   // --- miaf
diff --git a/libheif/omaf_boxes.cc b/libheif/omaf_boxes.cc
index a264aa5f..c3b6abaf 100644
--- a/libheif/omaf_boxes.cc
+++ b/libheif/omaf_boxes.cc
@@ -37,13 +37,13 @@ Error Box_prfr::parse(BitstreamRange& range, const heif_security_limits* limits)
   switch (projection_type)
   {
   case 0x00:
-    m_projection = heif_image_projection::equirectangular;
+    m_projection = heif_omaf_image_projection::heif_omaf_image_projection_equirectangular;
     break;
   case 0x01:
-    m_projection = heif_image_projection::cube_map;
+    m_projection = heif_omaf_image_projection::heif_omaf_image_projection_cube_map;
     break;
   default:
-    m_projection = heif_image_projection::unknown_other;
+    m_projection = heif_omaf_image_projection::heif_omaf_image_projection_unknown;
     break;
   }
   return range.get_error();
@@ -61,10 +61,10 @@ Error Box_prfr::write(StreamWriter& writer) const
 {
   size_t box_start = reserve_box_header_space(writer);
   switch (m_projection) {
-    case heif_image_projection::equirectangular:
+    case heif_omaf_image_projection::heif_omaf_image_projection_equirectangular:
       writer.write8(0x00);
       break;
-    case heif_image_projection::cube_map:
+    case heif_omaf_image_projection::heif_omaf_image_projection_cube_map:
       writer.write8(0x01);
       break;
     default:
@@ -78,9 +78,9 @@ Error Box_prfr::write(StreamWriter& writer) const
   return Error::Ok;
 }

-Error Box_prfr::set_image_projection(heif_image_projection projection)
+Error Box_prfr::set_image_projection(heif_omaf_image_projection projection)
 {
-  if ((projection == heif_image_projection::equirectangular) || (projection == heif_image_projection::cube_map)) {
+  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 {
diff --git a/libheif/omaf_boxes.h b/libheif/omaf_boxes.h
index 0d82d659..a5f2b393 100644
--- a/libheif/omaf_boxes.h
+++ b/libheif/omaf_boxes.h
@@ -19,8 +19,8 @@
  * along with libheif.  If not, see <http://www.gnu.org/licenses/>.
  */

-#ifndef LIBHEIF_MINI_H
-#define LIBHEIF_MINI_H
+#ifndef LIBHEIF_OMAF_BOXES_H
+#define LIBHEIF_OMAF_BOXES_H

 #include "libheif/heif.h"
 #include "box.h"
@@ -38,9 +38,9 @@ public:
     set_short_type(fourcc("prfr"));
   }

-  heif_image_projection get_image_projection() const { return m_projection; }
+  heif_omaf_image_projection get_omaf_image_projection() const { return m_projection; }

-  Error set_image_projection(heif_image_projection projection);
+  Error set_image_projection(heif_omaf_image_projection projection);

   std::string dump(Indent&) const override;

@@ -54,7 +54,7 @@ protected:
   Error parse(BitstreamRange& range, const heif_security_limits*) override;

 private:
-  heif_image_projection m_projection;
+  heif_omaf_image_projection m_projection;
 };

 #endif
\ No newline at end of file
diff --git a/libheif/pixelimage.cc b/libheif/pixelimage.cc
index b481966c..2ec48234 100644
--- a/libheif/pixelimage.cc
+++ b/libheif/pixelimage.cc
@@ -215,12 +215,12 @@ std::shared_ptr<Box_colr> ImageExtraData::get_colr_box_icc() const
 #if HEIF_WITH_OMAF
 std::shared_ptr<Box_prfr> ImageExtraData::get_prfr_box() const
 {
-  if (!has_image_projection()) {
+  if (!has_omaf_image_projection()) {
     return {};
   }

   auto prfr = std::make_shared<Box_prfr>();
-  prfr->set_image_projection(get_image_projection());
+  prfr->set_image_projection(get_omaf_image_projection());

   return prfr;
 }
@@ -281,9 +281,9 @@ std::vector<std::shared_ptr<Box>> ImageExtraData::generate_property_boxes(bool g
   }

 #if HEIF_WITH_OMAF
-  if (has_image_projection()) {
+  if (has_omaf_image_projection()) {
     auto prfr = std::make_shared<Box_prfr>();
-    prfr->set_image_projection(get_image_projection());
+    prfr->set_image_projection(get_omaf_image_projection());
     properties.push_back(prfr);
   }
 #endif
@@ -1898,7 +1898,7 @@ void HeifPixelImage::forward_all_metadata_from(const std::shared_ptr<const HeifP
   // TODO: should we also forward the warnings? It might be better to do that in ImageItem_Grid.

 #if HEIF_WITH_OMAF
-  set_image_projection(src_image->get_image_projection());
+  set_omaf_image_projection(src_image->get_omaf_image_projection());
 #endif
 }

diff --git a/libheif/pixelimage.h b/libheif/pixelimage.h
index 165302f1..47181119 100644
--- a/libheif/pixelimage.h
+++ b/libheif/pixelimage.h
@@ -181,16 +181,16 @@ public:
   std::string get_gimi_sample_content_id() const { assert(has_gimi_sample_content_id()); return *m_gimi_sample_content_id; }

 #if HEIF_WITH_OMAF
-  bool has_image_projection() const {
-    return (m_image_projection != heif_image_projection::flat);
+  bool has_omaf_image_projection() const {
+    return (m_omaf_image_projection != heif_omaf_image_projection_flat);
   }

-  const heif_image_projection get_image_projection() const {
-    return m_image_projection;
+  const heif_omaf_image_projection get_omaf_image_projection() const {
+    return m_omaf_image_projection;
   }

-  virtual void set_image_projection(const heif_image_projection projection) {
-    m_image_projection = projection;
+  virtual void set_omaf_image_projection(const heif_omaf_image_projection projection) {
+    m_omaf_image_projection = projection;
   }
 #endif

@@ -209,7 +209,7 @@ private:
   std::optional<std::string> m_gimi_sample_content_id;

 #if HEIF_WITH_OMAF
-  heif_image_projection m_image_projection = heif_image_projection::flat;
+  heif_omaf_image_projection m_omaf_image_projection = heif_omaf_image_projection::heif_omaf_image_projection_flat;
 #endif

 protected:
diff --git a/tests/omaf.cc b/tests/omaf.cc
index 9ebc4a3e..cbc8ed61 100644
--- a/tests/omaf.cc
+++ b/tests/omaf.cc
@@ -42,7 +42,7 @@ static heif_encoding_options * set_encoding_options()
   return options;
 }

-static void do_encode(heif_image* input_image, const char* filename, heif_image_projection projection)
+static void do_encode(heif_image* input_image, const char* filename, heif_omaf_image_projection projection)
 {
   REQUIRE(input_image != nullptr);
   heif_init(nullptr);
@@ -58,7 +58,7 @@ static void do_encode(heif_image* input_image, const char* filename, heif_image_

   err = heif_context_encode_image(ctx, input_image, encoder, options, &output_image_handle);
   REQUIRE(err.code == heif_error_Ok);
-  heif_image_handle_set_image_projection(output_image_handle, projection);
+  heif_image_handle_set_omaf_image_projection(output_image_handle, projection);
   err = heif_context_write_to_file(ctx, filename);
   REQUIRE(err.code == heif_error_Ok);

@@ -71,7 +71,7 @@ static void do_encode(heif_image* input_image, const char* filename, heif_image_

   heif_context *readbackCtx = get_context_for_local_file(filename);
   heif_image_handle *readbackHandle = get_primary_image_handle(readbackCtx);
-  heif_image_projection readbackProjection = heif_image_handle_get_image_projection(readbackHandle);
+  heif_omaf_image_projection readbackProjection = heif_image_handle_get_omaf_image_projection(readbackHandle);
   REQUIRE(readbackProjection == projection);
   heif_image_handle_release(readbackHandle);
   heif_context_free(readbackCtx);
@@ -82,11 +82,11 @@ static void do_encode(heif_image* input_image, const char* filename, heif_image_
 TEST_CASE("Encode OMAF HEIC")
 {
   heif_image *input_image = createImage_RGB_planar();
-  do_encode(input_image, "encode_omaf_equirectangular.heic", heif_image_projection::equirectangular);
+  do_encode(input_image, "encode_omaf_equirectangular.heic", heif_omaf_image_projection::heif_omaf_image_projection_equirectangular);
 }

 TEST_CASE("Encode OMAF HEIC Cubemap")
 {
   heif_image *input_image = createImage_RGB_planar();
-  do_encode(input_image, "encode_omaf_cubemap.heic", heif_image_projection::cube_map);
+  do_encode(input_image, "encode_omaf_cubemap.heic", heif_omaf_image_projection::heif_omaf_image_projection_cube_map);
 }
\ No newline at end of file
diff --git a/tests/omaf_boxes.cc b/tests/omaf_boxes.cc
index 73972c6b..dc971be3 100644
--- a/tests/omaf_boxes.cc
+++ b/tests/omaf_boxes.cc
@@ -47,7 +47,7 @@ TEST_CASE("prfr") {
   REQUIRE(box->get_short_type() == fourcc("prfr"));
   REQUIRE(box->get_type_string() == "prfr");
   std::shared_ptr<Box_prfr> prfr = std::dynamic_pointer_cast<Box_prfr>(box);
-  REQUIRE(prfr->get_image_projection() == heif_image_projection::cube_map);
+  REQUIRE(prfr->get_omaf_image_projection() == heif_omaf_image_projection_cube_map);
   Indent indent;
   std::string dumpResult = box->dump(indent);
   REQUIRE(dumpResult == "Box: prfr ----- (Projection Format)\n"