diff --git a/libheif/image-items/tiled.cc b/libheif/image-items/tiled.cc index 121257269b..0adf0d707c 100644 --- a/libheif/image-items/tiled.cc +++ b/libheif/image-items/tiled.cc @@ -770,12 +770,9 @@ Error ImageItem_Tiled::append_compressed_tile_data(std::vector& data, u } -Result> -ImageItem_Tiled::decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const +Result +ImageItem_Tiled::get_compressed_data_for_tile(uint32_t tx, uint32_t ty) const { -// heif_compression_format format = compression_format_from_fourcc_infe_type( -// m_tild_header.get_parameters().compression_format_fourcc); - // --- get compressed data Error err = m_tile_item->init_decoder_from_item(0); @@ -799,7 +796,19 @@ ImageItem_Tiled::decode_grid_tile(const heif_decoding_options& options, uint32_t DataExtent extent; extent.m_raw = data; - m_tile_decoder->set_data_extent(std::move(extent)); + return extent; +} + + +Result> +ImageItem_Tiled::decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const +{ + Result extentResult = get_compressed_data_for_tile(tx, ty); + if (extentResult.error) { + return extentResult.error; + } + + m_tile_decoder->set_data_extent(std::move(*extentResult)); return m_tile_decoder->decode_single_frame_from_compressed_data(options); } @@ -844,6 +853,15 @@ void ImageItem_Tiled::get_tile_size(uint32_t& w, uint32_t& h) const Error ImageItem_Tiled::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const { + uint32_t tx=0, ty=0; // TODO: find a tile that is defined. + + Result extentResult = get_compressed_data_for_tile(tx, ty); + if (extentResult.error) { + return extentResult.error; + } + + m_tile_decoder->set_data_extent(std::move(*extentResult)); + Error err = m_tile_decoder->get_coded_image_colorspace(out_colorspace, out_chroma); if (err) { return err; diff --git a/libheif/image-items/tiled.h b/libheif/image-items/tiled.h index f895bc38f4..4ff32afa89 100644 --- a/libheif/image-items/tiled.h +++ b/libheif/image-items/tiled.h @@ -23,6 +23,7 @@ #include "image_item.h" +#include "codecs/decoder.h" #include "box.h" #include #include @@ -205,6 +206,9 @@ class ImageItem_Tiled : public ImageItem std::shared_ptr m_tile_item; std::shared_ptr m_tile_decoder; + Result + get_compressed_data_for_tile(uint32_t tx, uint32_t ty) const; + Result> decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const; Error load_tile_offset_entry(uint32_t idx);