Commit 3a5297bb for libheif

commit 3a5297bb1bf0310023b583ebf00864d09772a4c6
Author: Dirk Farin <dirk.farin@gmail.com>
Date:   Thu Dec 18 17:11:51 2025 +0100

    [BSD3] relax brands check and also accept 'isom' files

diff --git a/libheif/api/libheif/heif_brands.cc b/libheif/api/libheif/heif_brands.cc
index 5219f229..40c15626 100644
--- a/libheif/api/libheif/heif_brands.cc
+++ b/libheif/api/libheif/heif_brands.cc
@@ -361,7 +361,8 @@ heif_error heif_has_compatible_filetype(const uint8_t* data, int len)
 #if ENABLE_EXPERIMENTAL_MINI_FORMAT
       , heif_brand2_mif3
 #endif
-      ,heif_brand2_msf1
+      ,heif_brand2_msf1,
+    heif_brand2_isom
   };

   auto it = supported_brands.find(main_brand);
diff --git a/libheif/api/libheif/heif_brands.h b/libheif/api/libheif/heif_brands.h
index dfead286..064ea780 100644
--- a/libheif/api/libheif/heif_brands.h
+++ b/libheif/api/libheif/heif_brands.h
@@ -251,6 +251,7 @@ typedef uint32_t heif_brand2;
 #define heif_brand2_avcs   heif_fourcc('a','v','c','s')

 #define heif_brand2_iso8   heif_fourcc('i','s','o','8')
+#define heif_brand2_isom   heif_fourcc('i','s','o','m')

 // input data should be at least 12 bytes
 LIBHEIF_API
diff --git a/libheif/file.cc b/libheif/file.cc
index 82fdf251..c527d312 100644
--- a/libheif/file.cc
+++ b/libheif/file.cc
@@ -330,7 +330,8 @@ Error HeifFile::parse_heif_file()

   m_top_level_boxes.push_back(m_ftyp_box);

-  bool is_brand_msf1 = m_ftyp_box->has_compatible_brand(heif_brand2_msf1);
+  bool is_sequence_brand = (m_ftyp_box->has_compatible_brand(heif_brand2_msf1) ||
+                            m_ftyp_box->has_compatible_brand(heif_brand2_isom));

   // --- check whether this is a HEIF file and its structural format

@@ -343,7 +344,8 @@ Error HeifFile::parse_heif_file()
       !(m_ftyp_box->get_major_brand() == heif_brand2_mif3) &&
 #endif
       !m_ftyp_box->has_compatible_brand(heif_brand2_jpeg) &&
-      !is_brand_msf1) {
+      !m_ftyp_box->has_compatible_brand(heif_brand2_isom) &&
+      !m_ftyp_box->has_compatible_brand(heif_brand2_msf1)) {
     std::stringstream sstr;
     sstr << "File does not include any supported brands.\n";

@@ -379,12 +381,12 @@ Error HeifFile::parse_heif_file()

   // if we didn't find the mini box, meta is required

-  if (!m_meta_box && !is_brand_msf1) {
+  if (!m_meta_box && !is_sequence_brand) {
     return Error(heif_error_Invalid_input,
                  heif_suberror_No_meta_box);
   }

-  if (!m_moov_box && is_brand_msf1) {
+  if (!m_moov_box && is_sequence_brand) {
     return Error(heif_error_Invalid_input,
                  heif_suberror_No_moov_box);
   }