From 859d3644d9bb652e84eb6e2a100eda7878f05059 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Mon, 7 Oct 2024 17:46:37 +0200 Subject: [PATCH] rename 'tild' classes to 'tiled' and image type to 'tili' --- libheif/CMakeLists.txt | 4 +- libheif/api/libheif/heif.cc | 16 ++++---- libheif/api/libheif/heif_experimental.h | 10 ++--- libheif/box.cc | 2 +- libheif/context.cc | 18 ++++---- libheif/context.h | 10 ++--- libheif/image-items/image_item.cc | 6 +-- libheif/image-items/{tild.cc => tiled.cc} | 50 +++++++++++------------ libheif/image-items/{tild.h => tiled.h} | 32 +++++++-------- 9 files changed, 74 insertions(+), 74 deletions(-) rename libheif/image-items/{tild.cc => tiled.cc} (91%) rename libheif/image-items/{tild.h => tiled.h} (85%) diff --git a/libheif/CMakeLists.txt b/libheif/CMakeLists.txt index a5abcaac9e..c83b35f511 100644 --- a/libheif/CMakeLists.txt +++ b/libheif/CMakeLists.txt @@ -105,8 +105,8 @@ set(libheif_sources image-items/overlay.cc image-items/iden.h image-items/iden.cc - image-items/tild.h - image-items/tild.cc + image-items/tiled.h + image-items/tiled.cc color-conversion/colorconversion.cc color-conversion/colorconversion.h color-conversion/rgb2yuv.cc diff --git a/libheif/api/libheif/heif.cc b/libheif/api/libheif/heif.cc index ade20d9917..febd757f7c 100644 --- a/libheif/api/libheif/heif.cc +++ b/libheif/api/libheif/heif.cc @@ -34,7 +34,7 @@ #include "init.h" #include "image-items/grid.h" #include "image-items/overlay.h" -#include "image-items/tild.h" +#include "image-items/tiled.h" #include #include @@ -3491,13 +3491,13 @@ struct heif_error heif_context_add_overlay_image(struct heif_context* ctx, } -struct heif_error heif_context_add_tild_image(struct heif_context* ctx, - const struct heif_tild_image_parameters* parameters, - const struct heif_encoding_options* options, // TODO: do we need this? - struct heif_image_handle** out_grid_image_handle) +struct heif_error heif_context_add_tiled_image(struct heif_context* ctx, + const struct heif_tiled_image_parameters* parameters, + const struct heif_encoding_options* options, // TODO: do we need this? + struct heif_image_handle** out_grid_image_handle) { - Result> gridImageResult; - gridImageResult = ctx->context->add_tild_item(parameters); + Result> gridImageResult; + gridImageResult = ctx->context->add_tiled_item(parameters); if (gridImageResult.error != Error::Ok) { return gridImageResult.error.error_struct(ctx->context.get()); @@ -3520,7 +3520,7 @@ struct heif_error heif_context_add_image_tile(struct heif_context* ctx, struct heif_encoder* encoder) { if (tiled_image->image->get_infe_type() == fourcc("tili")) { - Error err = ctx->context->add_tild_image_tile(tiled_image->image->get_id(), tile_x, tile_y, image->image, encoder); + Error err = ctx->context->add_tiled_image_tile(tiled_image->image->get_id(), tile_x, tile_y, image->image, encoder); return err.error_struct(ctx->context.get()); } #if WITH_UNCOMPRESSED_CODEC diff --git a/libheif/api/libheif/heif_experimental.h b/libheif/api/libheif/heif_experimental.h index 01b75aa877..b98675f12e 100644 --- a/libheif/api/libheif/heif_experimental.h +++ b/libheif/api/libheif/heif_experimental.h @@ -112,7 +112,7 @@ struct heif_error heif_property_camera_extrinsic_matrix_get_world_coordinate_sys // --- Tiled images -struct heif_tild_image_parameters { +struct heif_tiled_image_parameters { int version; // --- version 1 @@ -137,10 +137,10 @@ struct heif_tild_image_parameters { LIBHEIF_API -struct heif_error heif_context_add_tild_image(struct heif_context* ctx, - const struct heif_tild_image_parameters* parameters, - const struct heif_encoding_options* options, // TODO: do we need this? - struct heif_image_handle** out_tild_image_handle); +struct heif_error heif_context_add_tiled_image(struct heif_context* ctx, + const struct heif_tiled_image_parameters* parameters, + const struct heif_encoding_options* options, // TODO: do we need this? + struct heif_image_handle** out_tiled_image_handle); // --- 'unci' images diff --git a/libheif/box.cc b/libheif/box.cc index a380c00fc6..c78880efa8 100644 --- a/libheif/box.cc +++ b/libheif/box.cc @@ -30,7 +30,7 @@ #include "codecs/vvc_boxes.h" #include "codecs/avc_boxes.h" #include "codecs/avif_boxes.h" -#include "image-items/tild.h" +#include "image-items/tiled.h" #include #include diff --git a/libheif/context.cc b/libheif/context.cc index f4c901e215..c4c55cadf6 100644 --- a/libheif/context.cc +++ b/libheif/context.cc @@ -53,7 +53,7 @@ #include "image-items/jpeg2000.h" #include "image-items/grid.h" #include "image-items/overlay.h" -#include "image-items/tild.h" +#include "image-items/tiled.h" #if WITH_UNCOMPRESSED_CODEC #include "image-items/unc_image.h" @@ -269,7 +269,7 @@ static bool item_type_is_image(uint32_t item_type, const std::string& content_ty return (item_type == fourcc("hvc1") || item_type == fourcc("av01") || item_type == fourcc("grid") || - item_type == fourcc("tild") || + item_type == fourcc("tili") || item_type == fourcc("iden") || item_type == fourcc("iovl") || item_type == fourcc("avc1") || @@ -1342,15 +1342,15 @@ Result> HeifContext::add_iovl_item(const Imag } -Result> HeifContext::add_tild_item(const heif_tild_image_parameters* parameters) +Result> HeifContext::add_tiled_item(const heif_tiled_image_parameters* parameters) { - return ImageItem_Tild::add_new_tild_item(this, parameters); + return ImageItem_Tiled::add_new_tiled_item(this, parameters); } -Error HeifContext::add_tild_image_tile(heif_item_id tild_id, uint32_t tile_x, uint32_t tile_y, - const std::shared_ptr& image, - struct heif_encoder* encoder) +Error HeifContext::add_tiled_image_tile(heif_item_id tild_id, uint32_t tile_x, uint32_t tile_y, + const std::shared_ptr& image, + struct heif_encoder* encoder) { auto item = ImageItem::alloc_for_compression_format(this, encoder->plugin->compression_format); @@ -1374,9 +1374,9 @@ Error HeifContext::add_tild_image_tile(heif_item_id tild_id, uint32_t tile_x, ui m_heif_file->append_iloc_data(tild_id, encodeResult.value.bitstream, construction_method); auto imgItem = get_image(tild_id); - auto tildImg = std::dynamic_pointer_cast(imgItem); + auto tildImg = std::dynamic_pointer_cast(imgItem); if (!tildImg) { - return {heif_error_Usage_error, heif_suberror_Invalid_parameter_value, "item ID for add_tild_image_tile() is no 'tild' image."}; + return {heif_error_Usage_error, heif_suberror_Invalid_parameter_value, "item ID for add_tiled_image_tile() is no 'tili' image."}; } auto& header = tildImg->get_tild_header(); diff --git a/libheif/context.h b/libheif/context.h index 7bae2ec3a9..025e4de8d7 100644 --- a/libheif/context.h +++ b/libheif/context.h @@ -51,7 +51,7 @@ class ImageOverlay; class ImageItem; class ImageItem_Overlay; -class ImageItem_Tild; +class ImageItem_Tiled; class ImageItem_uncompressed; @@ -160,11 +160,11 @@ class HeifContext : public ErrorBuffer Result> add_iovl_item(const ImageOverlay& overlayspec); - Result> add_tild_item(const heif_tild_image_parameters* parameters); + Result> add_tiled_item(const heif_tiled_image_parameters* parameters); - Error add_tild_image_tile(heif_item_id tild_id, uint32_t tile_x, uint32_t tile_y, - const std::shared_ptr& image, - struct heif_encoder* encoder); + Error add_tiled_image_tile(heif_item_id tili_id, uint32_t tile_x, uint32_t tile_y, + const std::shared_ptr& image, + struct heif_encoder* encoder); Result> add_unci_item(const heif_unci_image_parameters* parameters, const struct heif_encoding_options* encoding_options, diff --git a/libheif/image-items/image_item.cc b/libheif/image-items/image_item.cc index cfe956cdce..aa48f0866f 100644 --- a/libheif/image-items/image_item.cc +++ b/libheif/image-items/image_item.cc @@ -30,7 +30,7 @@ #include "grid.h" #include "overlay.h" #include "iden.h" -#include "tild.h" +#include "tiled.h" #include "codecs/decoder.h" #include "color-conversion/colorconversion.h" #include "api/libheif/api_structs.h" @@ -150,8 +150,8 @@ std::shared_ptr ImageItem::alloc_for_infe_box(HeifContext* ctx, const else if (item_type == fourcc("iden")) { return std::make_shared(ctx, id); } - else if (item_type == fourcc("tild")) { - return std::make_shared(ctx, id); + else if (item_type == fourcc("tili")) { + return std::make_shared(ctx, id); } else { return nullptr; diff --git a/libheif/image-items/tild.cc b/libheif/image-items/tiled.cc similarity index 91% rename from libheif/image-items/tild.cc rename to libheif/image-items/tiled.cc index d0475d460f..6df735f55e 100644 --- a/libheif/image-items/tild.cc +++ b/libheif/image-items/tiled.cc @@ -18,7 +18,7 @@ * along with libheif. If not, see . */ -#include "tild.h" +#include "tiled.h" #include "context.h" #include "file.h" #include @@ -38,7 +38,7 @@ static uint64_t readvec(const std::vector& data, size_t& ptr, int len) } -uint64_t number_of_tiles(const heif_tild_image_parameters& params) +uint64_t number_of_tiles(const heif_tiled_image_parameters& params) { uint64_t nTiles = nTiles_h(params) * static_cast(nTiles_v(params)); @@ -55,13 +55,13 @@ uint64_t number_of_tiles(const heif_tild_image_parameters& params) } -uint32_t nTiles_h(const heif_tild_image_parameters& params) +uint32_t nTiles_h(const heif_tiled_image_parameters& params) { return (params.image_width + params.tile_width - 1) / params.tile_width; } -uint32_t nTiles_v(const heif_tild_image_parameters& params) +uint32_t nTiles_v(const heif_tiled_image_parameters& params) { return (params.image_height + params.tile_height - 1) / params.tile_height; } @@ -248,7 +248,7 @@ Error Box_tilC::parse(BitstreamRange& range, const heif_security_limits* limits) } -Error TildHeader::set_parameters(const heif_tild_image_parameters& params) +Error TildHeader::set_parameters(const heif_tiled_image_parameters& params) { m_parameters = params; @@ -431,25 +431,25 @@ std::string TildHeader::dump() const } -ImageItem_Tild::ImageItem_Tild(HeifContext* ctx) +ImageItem_Tiled::ImageItem_Tiled(HeifContext* ctx) : ImageItem(ctx) { } -ImageItem_Tild::ImageItem_Tild(HeifContext* ctx, heif_item_id id) +ImageItem_Tiled::ImageItem_Tiled(HeifContext* ctx, heif_item_id id) : ImageItem(ctx, id) { } -heif_compression_format ImageItem_Tild::get_compression_format() const +heif_compression_format ImageItem_Tiled::get_compression_format() const { return compression_format_from_fourcc_infe_type(m_tild_header.get_parameters().compression_type_fourcc); } -Error ImageItem_Tild::on_load_file() +Error ImageItem_Tiled::on_load_file() { auto heif_file = get_context()->get_heif_file(); @@ -467,7 +467,7 @@ Error ImageItem_Tild::on_load_file() "Tiled image without 'ispe' property box."}; } - heif_tild_image_parameters parameters = tilC_box->get_parameters(); + heif_tiled_image_parameters parameters = tilC_box->get_parameters(); parameters.image_width = ispe_box->get_width(); parameters.image_height = ispe_box->get_height(); @@ -498,8 +498,8 @@ Error ImageItem_Tild::on_load_file() } -Result> -ImageItem_Tild::add_new_tild_item(HeifContext* ctx, const heif_tild_image_parameters* parameters) +Result> +ImageItem_Tiled::add_new_tiled_item(HeifContext* ctx, const heif_tiled_image_parameters* parameters) { auto max_tild_tiles = ctx->get_security_limits()->max_number_of_tiles; if (max_tild_tiles && number_of_tiles(*parameters) > max_tild_tiles) { @@ -513,8 +513,8 @@ ImageItem_Tild::add_new_tild_item(HeifContext* ctx, const heif_tild_image_parame auto file = ctx->get_heif_file(); - heif_item_id tild_id = ctx->get_heif_file()->add_new_image(fourcc("tild")); - auto tild_image = std::make_shared(ctx, tild_id); + heif_item_id tild_id = ctx->get_heif_file()->add_new_image(fourcc("tili")); + auto tild_image = std::make_shared(ctx, tild_id); ctx->insert_new_image(tild_id, tild_image); // Create tilC box @@ -564,7 +564,7 @@ ImageItem_Tild::add_new_tild_item(HeifContext* ctx, const heif_tild_image_parame } -void ImageItem_Tild::process_before_write() +void ImageItem_Tiled::process_before_write() { // overwrite offsets @@ -576,7 +576,7 @@ void ImageItem_Tild::process_before_write() Result> -ImageItem_Tild::decode_compressed_image(const struct heif_decoding_options& options, +ImageItem_Tiled::decode_compressed_image(const struct heif_decoding_options& options, bool decode_tile_only, uint32_t tile_x0, uint32_t tile_y0) const { if (decode_tile_only) { @@ -589,12 +589,12 @@ ImageItem_Tild::decode_compressed_image(const struct heif_decoding_options& opti } -Error ImageItem_Tild::append_compressed_tile_data(std::vector& data, uint32_t tx, uint32_t ty) const +Error ImageItem_Tiled::append_compressed_tile_data(std::vector& data, uint32_t tx, uint32_t ty) const { uint32_t idx = (uint32_t) (ty * nTiles_h(m_tild_header.get_parameters()) + tx); if (!m_tild_header.is_tile_offset_known(idx)) { - Error err = const_cast(this)->load_tile_offset_entry(idx); + Error err = const_cast(this)->load_tile_offset_entry(idx); if (err) { return err; } @@ -613,7 +613,7 @@ Error ImageItem_Tild::append_compressed_tile_data(std::vector& data, ui Result> -ImageItem_Tild::decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const +ImageItem_Tiled::decode_grid_tile(const heif_decoding_options& options, uint32_t tx, uint32_t ty) const { heif_compression_format format = compression_format_from_fourcc_infe_type( m_tild_header.get_parameters().compression_type_fourcc); @@ -642,7 +642,7 @@ ImageItem_Tild::decode_grid_tile(const heif_decoding_options& options, uint32_t } -Error ImageItem_Tild::load_tile_offset_entry(uint32_t idx) +Error ImageItem_Tiled::load_tile_offset_entry(uint32_t idx) { uint32_t nEntries = mReadChunkSize_bytes / m_tild_header.get_offset_table_entry_size(); std::pair range = m_tild_header.get_tile_offset_table_range_to_read(idx, nEntries); @@ -651,7 +651,7 @@ Error ImageItem_Tild::load_tile_offset_entry(uint32_t idx) } -heif_image_tiling ImageItem_Tild::get_heif_image_tiling() const +heif_image_tiling ImageItem_Tiled::get_heif_image_tiling() const { heif_image_tiling tiling{}; @@ -672,14 +672,14 @@ heif_image_tiling ImageItem_Tild::get_heif_image_tiling() const } -void ImageItem_Tild::get_tile_size(uint32_t& w, uint32_t& h) const +void ImageItem_Tiled::get_tile_size(uint32_t& w, uint32_t& h) const { w = m_tild_header.get_parameters().tile_width; h = m_tild_header.get_parameters().tile_height; } -Error ImageItem_Tild::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const +Error ImageItem_Tiled::get_coded_image_colorspace(heif_colorspace* out_colorspace, heif_chroma* out_chroma) const { Error err = m_tile_decoder->get_coded_image_colorspace(out_colorspace, out_chroma); if (err) { @@ -692,7 +692,7 @@ Error ImageItem_Tild::get_coded_image_colorspace(heif_colorspace* out_colorspace } -int ImageItem_Tild::get_luma_bits_per_pixel() const +int ImageItem_Tiled::get_luma_bits_per_pixel() const { DataExtent any_tile_extent; append_compressed_tile_data(any_tile_extent.m_raw, 0,0); // TODO: use tile that is already loaded @@ -701,7 +701,7 @@ int ImageItem_Tild::get_luma_bits_per_pixel() const return m_tile_decoder->get_luma_bits_per_pixel(); } -int ImageItem_Tild::get_chroma_bits_per_pixel() const +int ImageItem_Tiled::get_chroma_bits_per_pixel() const { DataExtent any_tile_extent; append_compressed_tile_data(any_tile_extent.m_raw, 0,0); // TODO: use tile that is already loaded diff --git a/libheif/image-items/tild.h b/libheif/image-items/tiled.h similarity index 85% rename from libheif/image-items/tild.h rename to libheif/image-items/tiled.h index c32f288614..c5c8608c4a 100644 --- a/libheif/image-items/tild.h +++ b/libheif/image-items/tiled.h @@ -18,8 +18,8 @@ * along with libheif. If not, see . */ -#ifndef LIBHEIF_TILD_H -#define LIBHEIF_TILD_H +#ifndef LIBHEIF_TILED_H +#define LIBHEIF_TILED_H #include "image_item.h" @@ -31,11 +31,11 @@ #include "libheif/heif_experimental.h" -uint64_t number_of_tiles(const heif_tild_image_parameters& params); +uint64_t number_of_tiles(const heif_tiled_image_parameters& params); -uint32_t nTiles_h(const heif_tild_image_parameters& params); +uint32_t nTiles_h(const heif_tiled_image_parameters& params); -uint32_t nTiles_v(const heif_tild_image_parameters& params); +uint32_t nTiles_v(const heif_tiled_image_parameters& params); class Box_tilC : public FullBox @@ -57,9 +57,9 @@ class Box_tilC : public FullBox void derive_box_version() override; - void set_parameters(const heif_tild_image_parameters& params) { m_parameters = params; } + void set_parameters(const heif_tiled_image_parameters& params) { m_parameters = params; } - const heif_tild_image_parameters& get_parameters() const { return m_parameters; } + const heif_tiled_image_parameters& get_parameters() const { return m_parameters; } Error write(StreamWriter& writer) const override; @@ -69,7 +69,7 @@ class Box_tilC : public FullBox Error parse(BitstreamRange& range, const heif_security_limits* limits) override; private: - heif_tild_image_parameters m_parameters; + heif_tiled_image_parameters m_parameters; }; @@ -80,9 +80,9 @@ class Box_tilC : public FullBox class TildHeader { public: - Error set_parameters(const heif_tild_image_parameters& params); + Error set_parameters(const heif_tiled_image_parameters& params); - const heif_tild_image_parameters& get_parameters() const { return m_parameters; } + const heif_tiled_image_parameters& get_parameters() const { return m_parameters; } Error read_full_offset_table(const std::shared_ptr& file, heif_item_id tild_id, const heif_security_limits* limits); @@ -111,7 +111,7 @@ class TildHeader [[nodiscard]] std::pair get_tile_offset_table_range_to_read(uint32_t idx, uint32_t nEntries) const; private: - heif_tild_image_parameters m_parameters; + heif_tiled_image_parameters m_parameters; struct TileOffset { uint64_t offset = TILD_OFFSET_NOT_LOADED; @@ -126,12 +126,12 @@ class TildHeader }; -class ImageItem_Tild : public ImageItem +class ImageItem_Tiled : public ImageItem { public: - ImageItem_Tild(HeifContext* ctx, heif_item_id id); + ImageItem_Tiled(HeifContext* ctx, heif_item_id id); - ImageItem_Tild(HeifContext* ctx); + ImageItem_Tiled(HeifContext* ctx); uint32_t get_infe_type() const override { return fourcc("tili"); } @@ -140,7 +140,7 @@ class ImageItem_Tild : public ImageItem heif_compression_format get_compression_format() const override; - static Result> add_new_tild_item(HeifContext* ctx, const heif_tild_image_parameters* parameters); + static Result> add_new_tiled_item(HeifContext* ctx, const heif_tiled_image_parameters* parameters); Error on_load_file() override; @@ -194,4 +194,4 @@ class ImageItem_Tild : public ImageItem }; -#endif //LIBHEIF_TILD_H +#endif //LIBHEIF_TILED_H