Skip to content

Commit

Permalink
fix getting colorspace from ImageItem_Tiled
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Nov 5, 2024
1 parent dd9aeee commit 9ce4f3e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
30 changes: 24 additions & 6 deletions libheif/image-items/tiled.cc
Original file line number Diff line number Diff line change
Expand Up @@ -770,12 +770,9 @@ Error ImageItem_Tiled::append_compressed_tile_data(std::vector<uint8_t>& data, u
}


Result<std::shared_ptr<HeifPixelImage>>
ImageItem_Tiled::decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const
Result<DataExtent>
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);
Expand All @@ -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<std::shared_ptr<HeifPixelImage>>
ImageItem_Tiled::decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const
{
Result<DataExtent> 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);
}
Expand Down Expand Up @@ -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<DataExtent> 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;
Expand Down
4 changes: 4 additions & 0 deletions libheif/image-items/tiled.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@


#include "image_item.h"
#include "codecs/decoder.h"
#include "box.h"
#include <vector>
#include <string>
Expand Down Expand Up @@ -205,6 +206,9 @@ class ImageItem_Tiled : public ImageItem
std::shared_ptr<ImageItem> m_tile_item;
std::shared_ptr<class Decoder> m_tile_decoder;

Result<DataExtent>
get_compressed_data_for_tile(uint32_t tx, uint32_t ty) const;

Result<std::shared_ptr<HeifPixelImage>> decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const;

Error load_tile_offset_entry(uint32_t idx);
Expand Down

0 comments on commit 9ce4f3e

Please sign in to comment.