Skip to content

Commit

Permalink
fix tild decoder initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 6, 2024
1 parent c721741 commit e8fa68c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libheif/api/libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,7 @@ enum heif_chroma_upsampling_algorithm
heif_chroma_upsampling_bilinear = 2
};


struct heif_color_conversion_options
{
// 'version' must be 1.
Expand All @@ -1652,7 +1653,8 @@ struct heif_color_conversion_options
// at the cost of slightly higher computation times.
uint8_t only_use_preferred_chroma_algorithm;

// --- Note that we cannot extend this struct because it is embedded in other structs (heif_decoding_options and heif_encoding_options).
// --- Note that we cannot extend this struct because it is embedded in
// other structs (heif_decoding_options and heif_encoding_options).
};

// Assumes that it is a version=1 struct.
Expand Down
14 changes: 14 additions & 0 deletions libheif/image-items/image_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,15 @@ Error ImageItem::check_resolution(uint32_t w, uint32_t h) const
}


Error ImageItem::init_decoder_from_item(heif_item_id id)
{
m_id = id;

Error err = on_load_file();
return err;
}


heif_compression_format ImageItem::compression_format_from_fourcc_infe_type(uint32_t type)
{
switch (type) {
Expand Down Expand Up @@ -944,6 +953,11 @@ Result<std::vector<uint8_t>> ImageItem::read_bitstream_configuration_data_overri
auto item_codec = ImageItem::alloc_for_compression_format(const_cast<HeifContext*>(get_context()), format);
assert(item_codec);

Error err = item_codec->init_decoder_from_item(itemId);
if (err) {
return err;
}

return item_codec->read_bitstream_configuration_data(itemId);
}

Expand Down
2 changes: 2 additions & 0 deletions libheif/image-items/image_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ class ImageItem : public ErrorBuffer

virtual Error on_load_file() { return Error::Ok; }

Error init_decoder_from_item(heif_item_id id);

Result<std::shared_ptr<HeifPixelImage>> decode_image(const struct heif_decoding_options& options,
bool decode_tile_only, uint32_t tile_x0, uint32_t tile_y0) const;

Expand Down

0 comments on commit e8fa68c

Please sign in to comment.