Skip to content

Commit

Permalink
show error when an essential item property was not parsed (#1153)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Aug 16, 2024
1 parent 6b9ca71 commit 03cf1f6
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 3 deletions.
2 changes: 2 additions & 0 deletions go/heif/heif.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions libheif/api/libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions libheif/api/libheif/heif_emscripten.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
19 changes: 18 additions & 1 deletion libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Box_other>(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<Box_ispe>(prop);
Expand Down
2 changes: 2 additions & 0 deletions libheif/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 --

Expand Down

0 comments on commit 03cf1f6

Please sign in to comment.