Commit 36a0bcf5 for libheif
commit 36a0bcf5dd9c81649d788d569d41a69710d64e9d
Author: Dirk Farin <dirk.farin@gmail.com>
Date: Thu Dec 18 17:26:41 2025 +0100
[BSD3] relax brands check and also accept 'mp41' and 'mp42' files
diff --git a/libheif/api/libheif/heif_brands.cc b/libheif/api/libheif/heif_brands.cc
index 40c15626..f5d14ed7 100644
--- a/libheif/api/libheif/heif_brands.cc
+++ b/libheif/api/libheif/heif_brands.cc
@@ -362,7 +362,9 @@ heif_error heif_has_compatible_filetype(const uint8_t* data, int len)
, heif_brand2_mif3
#endif
,heif_brand2_msf1,
- heif_brand2_isom
+ heif_brand2_isom,
+ heif_brand2_mp41,
+ heif_brand2_mp42
};
auto it = supported_brands.find(main_brand);
diff --git a/libheif/api/libheif/heif_brands.h b/libheif/api/libheif/heif_brands.h
index 064ea780..b6eb2104 100644
--- a/libheif/api/libheif/heif_brands.h
+++ b/libheif/api/libheif/heif_brands.h
@@ -252,6 +252,8 @@ typedef uint32_t heif_brand2;
#define heif_brand2_iso8 heif_fourcc('i','s','o','8')
#define heif_brand2_isom heif_fourcc('i','s','o','m')
+#define heif_brand2_mp41 heif_fourcc('m','p','4','1')
+#define heif_brand2_mp42 heif_fourcc('m','p','4','2')
// input data should be at least 12 bytes
LIBHEIF_API
diff --git a/libheif/file.cc b/libheif/file.cc
index c527d312..89d0e8fa 100644
--- a/libheif/file.cc
+++ b/libheif/file.cc
@@ -331,7 +331,9 @@ Error HeifFile::parse_heif_file()
m_top_level_boxes.push_back(m_ftyp_box);
bool is_sequence_brand = (m_ftyp_box->has_compatible_brand(heif_brand2_msf1) ||
- m_ftyp_box->has_compatible_brand(heif_brand2_isom));
+ m_ftyp_box->has_compatible_brand(heif_brand2_isom) ||
+ m_ftyp_box->has_compatible_brand(heif_brand2_mp41) ||
+ m_ftyp_box->has_compatible_brand(heif_brand2_mp42));
// --- check whether this is a HEIF file and its structural format
@@ -345,6 +347,8 @@ Error HeifFile::parse_heif_file()
#endif
!m_ftyp_box->has_compatible_brand(heif_brand2_jpeg) &&
!m_ftyp_box->has_compatible_brand(heif_brand2_isom) &&
+ !m_ftyp_box->has_compatible_brand(heif_brand2_mp42) &&
+ !m_ftyp_box->has_compatible_brand(heif_brand2_mp41) &&
!m_ftyp_box->has_compatible_brand(heif_brand2_msf1)) {
std::stringstream sstr;
sstr << "File does not include any supported brands.\n";