From 0b3b41534624ded34184105d105fcffb4c2fb944 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Sun, 6 Oct 2024 16:58:55 +0200 Subject: [PATCH] (cleanup) --- libheif/image-items/image_item.cc | 36 ++++++++++++++----------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc index 15766e92da..af61b20896 100644 --- a/libheif/image-items/image_item.cc +++ b/libheif/image-items/image_item.cc @@ -428,33 +428,19 @@ Error ImageItem::postprocess_coded_image_colorspace(heif_colorspace* inout_color } -// TODO: when all decoders are implemented, this function should just forward to the Decoder object. Error ImageItem::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const { - heif_item_id id; - Error err = m_heif_context->get_id_of_non_virtual_child_image(m_id, id); - if (err) { - return err; - } + auto decoder = get_decoder(); + assert(decoder); - // TODO: should we use this or maybe use this just as an additional check that pixi and coded colorspace match? - auto pixi = m_heif_context->get_heif_file()->get_property(id); - if (pixi && pixi->get_num_channels() == 1) { - *out_colorspace = heif_colorspace_monochrome; - *out_chroma = heif_chroma_monochrome; + Error err = decoder->get_coded_image_colorspace(out_colorspace, out_chroma); + if (err) { return err; } - auto nclx = get_color_profile_nclx(); - if (nclx && nclx->get_matrix_coefficients() == 0) { - *out_colorspace = heif_colorspace_RGB; - *out_chroma = heif_chroma_444; - return err; - } + postprocess_coded_image_colorspace(out_colorspace, out_chroma); - auto decoder = get_decoder(); - assert(decoder); - return decoder->get_coded_image_colorspace(out_colorspace, out_chroma); + return Error::Ok; } @@ -698,6 +684,9 @@ Result> ImageItem::decode_image(const struct hei } } + + // --- transform tile position + if (decode_tile_only && options.ignore_transformations == false) { Result>> propertiesResult = get_properties(); if (propertiesResult.error) { @@ -1046,6 +1035,9 @@ Error ImageItem::process_image_transformations_on_tiling(heif_image_tiling& tili uint32_t bottom_excess = tiling.image_height % tiling.tile_height; for (const auto& property : properties) { + + // --- rotation + if (auto rot = std::dynamic_pointer_cast(property)) { int angle = rot->get_rotation_ccw(); if (angle == 90 || angle == 270) { @@ -1083,6 +1075,8 @@ Error ImageItem::process_image_transformations_on_tiling(heif_image_tiling& tili } } + // --- mirror + if (auto mirror = std::dynamic_pointer_cast(property)) { switch (mirror->get_mirror_direction()) { case heif_transform_mirror_direction_horizontal: @@ -1097,6 +1091,8 @@ Error ImageItem::process_image_transformations_on_tiling(heif_image_tiling& tili } } + // --- crop + if (auto clap = std::dynamic_pointer_cast(property)) { std::shared_ptr clap_img;