diff --git a/go/heif/heif.go b/go/heif/heif.go index 85706b84cb..55b638706c 100644 --- a/go/heif/heif.go +++ b/go/heif/heif.go @@ -339,6 +339,8 @@ const ( SuberrorUnsupportedGenericCompressionMethod = C.heif_suberror_Unsupported_generic_compression_method + SuberrorUnsupportedEssentialProperty = C.heif_suberror_Unsupported_essential_property + // The conversion of the source image to the requested chroma / colorspace is not supported. SuberrorUnsupportedColorConversion = C.heif_suberror_Unsupported_color_conversion diff --git a/libheif/api/libheif/heif.h b/libheif/api/libheif/heif.h index 97d2396f9a..6753c0054b 100644 --- a/libheif/api/libheif/heif.h +++ b/libheif/api/libheif/heif.h @@ -312,6 +312,8 @@ enum heif_suberror_code // Generically compressed data used an unsupported compression method heif_suberror_Unsupported_generic_compression_method = 3006, + heif_suberror_Unsupported_essential_property = 3007, + // --- Encoder_plugin_error --- heif_suberror_Unsupported_bit_depth = 4000, diff --git a/libheif/api/libheif/heif_emscripten.h b/libheif/api/libheif/heif_emscripten.h index 5b015f1288..46c0c8c7dc 100644 --- a/libheif/api/libheif/heif_emscripten.h +++ b/libheif/api/libheif/heif_emscripten.h @@ -389,6 +389,7 @@ EMSCRIPTEN_BINDINGS(libheif) { .value("heif_suberror_Unsupported_image_type", heif_suberror_Unsupported_image_type) .value("heif_suberror_Unsupported_data_version", heif_suberror_Unsupported_data_version) .value("heif_suberror_Unsupported_generic_compression_method", heif_suberror_Unsupported_generic_compression_method) + .value("heif_suberror_Unsupported_essential_property", heif_suberror_Unsupported_essential_property) .value("heif_suberror_Unsupported_color_conversion", heif_suberror_Unsupported_color_conversion) .value("heif_suberror_Unsupported_item_construction_method", heif_suberror_Unsupported_item_construction_method) .value("heif_suberror_Unsupported_header_compression_method", heif_suberror_Unsupported_header_compression_method) diff --git a/libheif/box.cc b/libheif/box.cc index 858ce43d42..8599519750 100644 --- a/libheif/box.cc +++ b/libheif/box.cc @@ -2471,9 +2471,9 @@ bool Box_ipco::is_property_essential_for_item(heif_item_id itemId, { // find property index - for (int i=0;i<(int)m_children.size();i++) { + for (int i = 0; i < (int) m_children.size(); i++) { if (m_children[i] == property) { - return ipma->is_property_essential_for_item(itemId, i); + return ipma->is_property_essential_for_item(itemId, i + 1); } } diff --git a/libheif/context.cc b/libheif/context.cc index 1a97821f0e..a3afac446f 100644 --- a/libheif/context.cc +++ b/libheif/context.cc @@ -327,7 +327,7 @@ Error HeifContext::interpret_heif_file() } - // --- read through properties for each image and extract image resolutions + // --- process image properties for (auto& pair : m_all_images) { auto& image = pair.second; @@ -339,6 +339,23 @@ Error HeifContext::interpret_heif_file() return err; } + + // --- are there any 'essential' properties that we did not parse? + + + for (const auto& prop : properties) { + if (std::dynamic_pointer_cast(prop) && + get_heif_file()->get_ipco_box()->is_property_essential_for_item(pair.first, prop, get_heif_file()->get_ipma_box())) { + + std::stringstream sstr; + sstr << "could not parse item property '" << prop->get_type_string() << "'"; + return {heif_error_Unsupported_feature, heif_suberror_Unsupported_essential_property, sstr.str()}; + } + } + + + // --- extract image resolution + bool ispe_read = false; for (const auto& prop : properties) { auto ispe = std::dynamic_pointer_cast(prop); diff --git a/libheif/error.cc b/libheif/error.cc index 1caa5348fc..caa2bed943 100644 --- a/libheif/error.cc +++ b/libheif/error.cc @@ -218,6 +218,8 @@ const char* Error::get_error_string(heif_suberror_code err) return "Unsupported header compression method"; case heif_suberror_Unsupported_generic_compression_method: return "Unsupported generic compression method"; + case heif_suberror_Unsupported_essential_property: + return "Unsupported essential item property"; // --- Encoder_plugin_error --