Commit 77767946 for libheif

commit 77767946186d65571fbb20e80d7b64103ab8190f
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Sun May 17 18:26:22 2026 +0200

    remove cmake HEIF_WITH_OMAF option

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0f89ea4d..3e34b00a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -77,8 +77,6 @@ include (TestBigEndian)
 TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
 add_compile_definitions(IS_BIG_ENDIAN=${IS_BIG_ENDIAN})

-option(HEIF_WITH_OMAF "Enable omnidirectional media format (OMAF) support." ON)
-
 # --- codec plugins

 option(ENABLE_PLUGIN_LOADING "Support loading of plugins" ON)
@@ -532,12 +530,6 @@ else()
   set(LIBS_PRIVATE "-lstdc++")
 endif()

-if(HEIF_WITH_OMAF)
-  set(WITH_OMAF "1")
-else ()
-  set(WITH_OMAF "0")
-endif()
-
 configure_file(libheif.pc.in ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc @ONLY)

 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libheif.pc
diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc
index c5be8aa9..a26ec3d4 100644
--- a/examples/heif_enc.cc
+++ b/examples/heif_enc.cc
@@ -146,9 +146,7 @@ int sequence_max_frames = 0; // 0 -> no maximum
 std::string option_gimi_track_id;
 std::string option_sai_data_file;

-#if HEIF_WITH_OMAF
 std::optional<heif_omaf_image_projection> omaf_image_projection;
-#endif
 std::vector<heif_brand2> additional_compatible_brands;

 enum heif_output_nclx_color_profile_preset
@@ -230,9 +228,7 @@ const int OPTION_METADATA_COMPRESSION = 1034;
 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_OMAF_IMAGE_PROJECTION = 1038;
-#endif
 const int OPTION_ADD_COMPATIBLE_BRAND = 1039;
 const int OPTION_UNIF = 1040;
 const int OPTION_RAW_WIDTH = 1041;
@@ -425,9 +421,7 @@ static option long_options[] = {
     {(char* const) "max-keyframe-distance",       required_argument,       nullptr, OPTION_SEQUENCES_MAX_KEYFRAME_DISTANCE},
     {(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) "omaf-image-projection",       required_argument,       nullptr, OPTION_SET_OMAF_IMAGE_PROJECTION},
-#endif
     {(char* const) "add-compatible-brand",        required_argument,       nullptr, OPTION_ADD_COMPATIBLE_BRAND},
     {(char* const) "unif",                      no_argument,             nullptr, OPTION_UNIF},
 #if ENABLE_EXPERIMENTAL_MINI_FORMAT
@@ -591,10 +585,8 @@ void show_help(const char* argv0)
             << "      --set-gimi-track-id ID     set the GIMI track ID for the visual track (experimental)\n"
             << "      --sai-data-file FILE       use the specified FILE as input data for the video frames SAI data\n"
 #endif
-#if HEIF_WITH_OMAF
             << "omnidirectional imagery:\n"
             << "      --omaf-image-projection PROJ    set the image projection (equirectangular, cube-map)\n"
-#endif
             ;
 }

@@ -1881,7 +1873,6 @@ int main(int argc, char** argv)
       case OPTION_SEQUENCES_SAI_DATA_FILE:
         option_sai_data_file = optarg;
         break;
-#if HEIF_WITH_OMAF
       case OPTION_SET_OMAF_IMAGE_PROJECTION:
         if (strcmp(optarg, "equirectangular") == 0) {
           omaf_image_projection = heif_omaf_image_projection_equirectangular;
@@ -1892,7 +1883,6 @@ int main(int argc, char** argv)
           return 5;
         }
         break;
-#endif
       case OPTION_ADD_COMPATIBLE_BRAND:
         if (strlen(optarg) != 4) {
           std::cerr << "Brand must be exactly 4 characters\n";
@@ -2449,11 +2439,9 @@ int do_encode_images(heif_context* context, heif_encoder* encoder, heif_encoding
     }
 #endif

-#if HEIF_WITH_OMAF
     if (omaf_image_projection) {
       heif_image_handle_set_omaf_image_projection(handle, *omaf_image_projection);
     }
-#endif

     if (option_component_content_ids && force_enc_uncompressed) {
       uint32_t num_components = heif_image_handle_get_number_of_cmpd_components(handle);
diff --git a/examples/heif_info.cc b/examples/heif_info.cc
index b54a1de9..484a9811 100644
--- a/examples/heif_info.cc
+++ b/examples/heif_info.cc
@@ -946,7 +946,6 @@ int main(int argc, char** argv)
       properties_shown = true;
     }

-#if HEIF_WITH_OMAF
     // --- OMAF

     heif_omaf_image_projection projection = heif_image_handle_get_omaf_image_projection(handle);
@@ -966,7 +965,6 @@ int main(int argc, char** argv)
       std::cout << "\n";
       properties_shown = true;
     }
-#endif

     if (!properties_shown) {
       std::cout << "none\n";
diff --git a/libheif.pc.in b/libheif.pc.in
index 8a62403c..1057594d 100644
--- a/libheif.pc.in
+++ b/libheif.pc.in
@@ -12,4 +12,4 @@ Requires.private: @REQUIRES_PRIVATE@
 Libs: -L${libdir} -lheif
 Libs.private: @LIBS_PRIVATE@
 Cflags: -I${includedir}
-Cflags.private: -DLIBHEIF_STATIC_BUILD -DHEIF_WITH_OMAF=@WITH_OMAF@
+Cflags.private: -DLIBHEIF_STATIC_BUILD
diff --git a/libheif/CMakeLists.txt b/libheif/CMakeLists.txt
index ffd066a7..3b5b9887 100644
--- a/libheif/CMakeLists.txt
+++ b/libheif/CMakeLists.txt
@@ -338,12 +338,9 @@ if (ENABLE_EXPERIMENTAL_MINI_FORMAT)
             mini.cc)
 endif ()

-if (HEIF_WITH_OMAF)
-    target_compile_definitions(heif PUBLIC HEIF_WITH_OMAF=1)
-    target_sources(heif PRIVATE
-            omaf_boxes.h
-            omaf_boxes.cc)
-endif ()
+target_sources(heif PRIVATE
+        omaf_boxes.h
+        omaf_boxes.cc)

 write_basic_package_version_file(${PROJECT_NAME}-config-version.cmake COMPATIBILITY ExactVersion)

diff --git a/libheif/api/libheif/heif_image.cc b/libheif/api/libheif/heif_image.cc
index b2106c1c..2dd2d9bf 100644
--- a/libheif/api/libheif/heif_image.cc
+++ b/libheif/api/libheif/heif_image.cc
@@ -317,22 +317,12 @@ void heif_image_handle_set_pixel_aspect_ratio(heif_image_handle* handle, uint32_

 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)
 {
-#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,
diff --git a/libheif/api/libheif/heif_image.h b/libheif/api/libheif/heif_image.h
index 2e718665..a6c08378 100644
--- a/libheif/api/libheif/heif_image.h
+++ b/libheif/api/libheif/heif_image.h
@@ -136,11 +136,6 @@ 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
 {
diff --git a/libheif/api/libheif/heif_properties.cc b/libheif/api/libheif/heif_properties.cc
index 4ed65065..656086b6 100644
--- a/libheif/api/libheif/heif_properties.cc
+++ b/libheif/api/libheif/heif_properties.cc
@@ -460,26 +460,14 @@ heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_ex

 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
 }

 heif_error heif_image_handle_set_omaf_image_projection(const heif_image_handle* handle, heif_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 aafa7a9e..41487eb4 100644
--- a/libheif/api/libheif/heif_properties.h
+++ b/libheif/api/libheif/heif_properties.h
@@ -229,9 +229,6 @@ heif_error heif_camera_extrinsic_matrix_get_rotation_matrix(const heif_camera_ex
                                                             double* out_matrix_row_major);

 // ------------------------- OMAF projection information -------------------------
-// These accessors are always present in the API. When libheif was built without
-// OMAF support, the getter reports "no projection" (heif_omaf_image_projection_flat)
-// and the setter returns heif_error_Unsupported_feature.
 // To test whether projection information is present, compare the getter's result
 // against heif_omaf_image_projection_flat.
 LIBHEIF_API
diff --git a/libheif/box.cc b/libheif/box.cc
index 81ed5c71..49dfc55d 100644
--- a/libheif/box.cc
+++ b/libheif/box.cc
@@ -905,12 +905,10 @@ Error Box::read(BitstreamRange& range, std::shared_ptr<Box>* result, const heif_
       box = std::make_shared<Box_sdtp>();
       break;

-#if HEIF_WITH_OMAF
     // OMAF
     case fourcc("prfr"):
       box = std::make_shared<Box_prfr>();
       break;
-#endif

     default:
       box = std::make_shared<Box_other>(hdr.get_short_type());
diff --git a/libheif/context.cc b/libheif/context.cc
index 408fd930..c0b7312a 100644
--- a/libheif/context.cc
+++ b/libheif/context.cc
@@ -796,12 +796,10 @@ Error HeifContext::interpret_heif_file_images()
       image->set_gimi_sample_content_id(box_gimi_content_id->get_content_id());
     }

-#if HEIF_WITH_OMAF
     // add image projection information
     if (auto prfr = image->get_property<Box_prfr>()) {
       image->ImageDescription::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 23ac5865..c8aa47fd 100644
--- a/libheif/image-items/image_item.cc
+++ b/libheif/image-items/image_item.cc
@@ -833,13 +833,11 @@ void ImageItem::set_color_profile_icc(const std::shared_ptr<const color_profile_
   add_property(create_colr_box_icc(), false);
 }

-#if HEIF_WITH_OMAF
 void ImageItem::set_omaf_image_projection(heif_omaf_image_projection projection)
 {
   ImageDescription::set_omaf_image_projection(projection);
   add_property(create_prfr_box(), true);
 }
-#endif


 Result<std::shared_ptr<HeifPixelImage>> ImageItem::decode_image(const heif_decoding_options& options,
@@ -1123,13 +1121,11 @@ Result<std::shared_ptr<HeifPixelImage>> ImageItem::decode_image(const heif_decod
       img->set_gimi_sample_content_id(gimi_content_id->get_content_id());
     }

-#if HEIF_WITH_OMAF
     // Image projection (OMAF)
     auto prfr = get_property<Box_prfr>();
     if (prfr) {
       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 cc7ddefe..4d8ff51e 100644
--- a/libheif/image-items/image_item.h
+++ b/libheif/image-items/image_item.h
@@ -330,9 +330,7 @@ public:

   void set_color_profile_icc(const std::shared_ptr<const color_profile_raw>& profile) override;

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

   // --- miaf

diff --git a/libheif/image/image_description.cc b/libheif/image/image_description.cc
index 723c6ef3..f87c8c1c 100644
--- a/libheif/image/image_description.cc
+++ b/libheif/image/image_description.cc
@@ -149,9 +149,7 @@ void ImageDescription::copy_metadata_from(const ImageDescription& other)

   m_sample_duration = other.m_sample_duration;

-#if HEIF_WITH_OMAF
   m_omaf_image_projection = other.m_omaf_image_projection;
-#endif
 }


@@ -235,7 +233,6 @@ std::shared_ptr<Box_colr> ImageDescription::create_colr_box_icc() const
   return colr;
 }

-#if HEIF_WITH_OMAF
 std::shared_ptr<Box_prfr> ImageDescription::create_prfr_box() const
 {
   if (!has_omaf_image_projection()) {
@@ -249,7 +246,6 @@ std::shared_ptr<Box_prfr> ImageDescription::create_prfr_box() const

   return prfr;
 }
-#endif

 std::vector<std::shared_ptr<Box>> ImageDescription::generate_property_boxes(bool generate_colr_boxes) const
 {
@@ -313,13 +309,11 @@ std::vector<std::shared_ptr<Box>> ImageDescription::generate_property_boxes(bool
     }
   }

-#if HEIF_WITH_OMAF
   if (has_omaf_image_projection()) {
     auto prfr = std::make_shared<Box_prfr>();
     prfr->set_image_projection(get_omaf_image_projection());
     properties.push_back(prfr);
   }
-#endif

 #if WITH_UNCOMPRESSED_CODEC
   if (has_component_content_ids()) {
diff --git a/libheif/image/image_description.h b/libheif/image/image_description.h
index 82977a7b..6d2f3b3b 100644
--- a/libheif/image/image_description.h
+++ b/libheif/image/image_description.h
@@ -25,9 +25,7 @@
 #include "nclx.h"
 #include <libheif/heif_experimental.h>
 #include <libheif/heif_uncompressed.h>
-#if HEIF_WITH_OMAF
 #include "omaf_boxes.h"
-#endif

 #include <cassert>
 #include <map>
@@ -405,7 +403,6 @@ public:
   uint32_t get_sample_duration() const { return m_sample_duration; }


-#if HEIF_WITH_OMAF
   bool has_omaf_image_projection() const {
     return (m_omaf_image_projection != heif_omaf_image_projection_flat);
   }
@@ -417,7 +414,6 @@ public:
   virtual void set_omaf_image_projection(const heif_omaf_image_projection projection) {
     m_omaf_image_projection = projection;
   }
-#endif

   // Copies all per-image metadata from `other` (color profiles, premultiplied
   // alpha, pixel aspect ratio, clli, mdcv, tai timestamp, gimi sample content
@@ -468,9 +464,7 @@ private:

   uint32_t m_sample_duration = 0; // duration of a sequence frame, 0 for stills

-#if HEIF_WITH_OMAF
   heif_omaf_image_projection m_omaf_image_projection = heif_omaf_image_projection::heif_omaf_image_projection_flat;
-#endif

 protected:
   std::shared_ptr<Box_clli> create_clli_box() const;
@@ -483,9 +477,7 @@ protected:

   std::shared_ptr<Box_colr> create_colr_box_icc() const;

-#if HEIF_WITH_OMAF
   std::shared_ptr<Box_prfr> create_prfr_box() const;
-#endif
 };

 #endif
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4e7da1ea..4278af8c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -83,12 +83,10 @@ if (ENABLE_EXPERIMENTAL_MINI_FORMAT)
     add_libheif_test(mini_decode)
 endif()

-if (HEIF_WITH_OMAF)
-    if (NOT WITH_REDUCED_VISIBILITY)
-        add_libheif_test(omaf_boxes)
-    endif()
-    add_libheif_test(omaf)
+if (NOT WITH_REDUCED_VISIBILITY)
+    add_libheif_test(omaf_boxes)
 endif()
+add_libheif_test(omaf)

 if (WITH_UNCOMPRESSED_CODEC)
     add_libheif_test(uncompressed_decode)
diff --git a/tests/image_description_metadata.cc b/tests/image_description_metadata.cc
index b32ab7e4..b898a319 100644
--- a/tests/image_description_metadata.cc
+++ b/tests/image_description_metadata.cc
@@ -54,9 +54,7 @@ struct MetadataFixture
   SensorNonUniformityCorrection nuc;
   uint8_t chroma_location = 2;
   uint32_t sample_duration = 33; // sequence frame duration
-#if HEIF_WITH_OMAF
   heif_omaf_image_projection omaf = heif_omaf_image_projection_equirectangular;
-#endif

   MetadataFixture()
   {
@@ -152,9 +150,7 @@ build_image(MetadataFixture& fix, uint32_t& comp1, uint32_t& comp2)

   img->set_chroma_location(fix.chroma_location);

-#if HEIF_WITH_OMAF
   img->set_omaf_image_projection(fix.omaf);
-#endif

   return img;
 }
@@ -218,9 +214,7 @@ static void check_metadata(const std::shared_ptr<HeifPixelImage>& img,

   REQUIRE(img->get_sample_duration() == fix.sample_duration);

-#if HEIF_WITH_OMAF
   REQUIRE(img->get_omaf_image_projection() == fix.omaf);
-#endif

   // Two monochrome components must still be there, with their gimi content IDs.
   // Rotate / crop re-mint component IDs; create_clone_image_at_new_size reuses