Skip to content

Commit

Permalink
rename 'tild' classes to 'tiled' and image type to 'tili'
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 7, 2024
1 parent 45e4d24 commit 859d364
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions libheif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions libheif/api/libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <set>
#include <limits>

Expand Down Expand Up @@ -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<std::shared_ptr<ImageItem_Tild>> gridImageResult;
gridImageResult = ctx->context->add_tild_item(parameters);
Result<std::shared_ptr<ImageItem_Tiled>> gridImageResult;
gridImageResult = ctx->context->add_tiled_item(parameters);

if (gridImageResult.error != Error::Ok) {
return gridImageResult.error.error_struct(ctx->context.get());
Expand All @@ -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
Expand Down
10 changes: 5 additions & 5 deletions libheif/api/libheif/heif_experimental.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion libheif/box.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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 <iomanip>
#include <utility>
Expand Down
18 changes: 9 additions & 9 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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") ||
Expand Down Expand Up @@ -1342,15 +1342,15 @@ Result<std::shared_ptr<ImageItem_Overlay>> HeifContext::add_iovl_item(const Imag
}


Result<std::shared_ptr<ImageItem_Tild>> HeifContext::add_tild_item(const heif_tild_image_parameters* parameters)
Result<std::shared_ptr<ImageItem_Tiled>> 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<HeifPixelImage>& 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<HeifPixelImage>& image,
struct heif_encoder* encoder)
{
auto item = ImageItem::alloc_for_compression_format(this, encoder->plugin->compression_format);

Expand All @@ -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<ImageItem_Tild>(imgItem);
auto tildImg = std::dynamic_pointer_cast<ImageItem_Tiled>(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();
Expand Down
10 changes: 5 additions & 5 deletions libheif/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ImageOverlay;

class ImageItem;
class ImageItem_Overlay;
class ImageItem_Tild;
class ImageItem_Tiled;
class ImageItem_uncompressed;


Expand Down Expand Up @@ -160,11 +160,11 @@ class HeifContext : public ErrorBuffer

Result<std::shared_ptr<ImageItem_Overlay>> add_iovl_item(const ImageOverlay& overlayspec);

Result<std::shared_ptr<ImageItem_Tild>> add_tild_item(const heif_tild_image_parameters* parameters);
Result<std::shared_ptr<ImageItem_Tiled>> 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<HeifPixelImage>& 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<HeifPixelImage>& image,
struct heif_encoder* encoder);

Result<std::shared_ptr<ImageItem_uncompressed>> add_unci_item(const heif_unci_image_parameters* parameters,
const struct heif_encoding_options* encoding_options,
Expand Down
6 changes: 3 additions & 3 deletions libheif/image-items/image_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -150,8 +150,8 @@ std::shared_ptr<ImageItem> ImageItem::alloc_for_infe_box(HeifContext* ctx, const
else if (item_type == fourcc("iden")) {
return std::make_shared<ImageItem_iden>(ctx, id);
}
else if (item_type == fourcc("tild")) {
return std::make_shared<ImageItem_Tild>(ctx, id);
else if (item_type == fourcc("tili")) {
return std::make_shared<ImageItem_Tiled>(ctx, id);
}
else {
return nullptr;
Expand Down
50 changes: 25 additions & 25 deletions libheif/image-items/tild.cc → libheif/image-items/tiled.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* along with libheif. If not, see <http://www.gnu.org/licenses/>.
*/

#include "tild.h"
#include "tiled.h"
#include "context.h"
#include "file.h"
#include <algorithm>
Expand All @@ -38,7 +38,7 @@ static uint64_t readvec(const std::vector<uint8_t>& 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<uint64_t>(nTiles_v(params));

Expand All @@ -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;
}
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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();

Expand All @@ -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();

Expand Down Expand Up @@ -498,8 +498,8 @@ Error ImageItem_Tild::on_load_file()
}


Result<std::shared_ptr<ImageItem_Tild>>
ImageItem_Tild::add_new_tild_item(HeifContext* ctx, const heif_tild_image_parameters* parameters)
Result<std::shared_ptr<ImageItem_Tiled>>
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) {
Expand All @@ -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<ImageItem_Tild>(ctx, tild_id);
heif_item_id tild_id = ctx->get_heif_file()->add_new_image(fourcc("tili"));
auto tild_image = std::make_shared<ImageItem_Tiled>(ctx, tild_id);
ctx->insert_new_image(tild_id, tild_image);

// Create tilC box
Expand Down Expand Up @@ -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

Expand All @@ -576,7 +576,7 @@ void ImageItem_Tild::process_before_write()


Result<std::shared_ptr<HeifPixelImage>>
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) {
Expand All @@ -589,12 +589,12 @@ ImageItem_Tild::decode_compressed_image(const struct heif_decoding_options& opti
}


Error ImageItem_Tild::append_compressed_tile_data(std::vector<uint8_t>& data, uint32_t tx, uint32_t ty) const
Error ImageItem_Tiled::append_compressed_tile_data(std::vector<uint8_t>& 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<ImageItem_Tild*>(this)->load_tile_offset_entry(idx);
Error err = const_cast<ImageItem_Tiled*>(this)->load_tile_offset_entry(idx);
if (err) {
return err;
}
Expand All @@ -613,7 +613,7 @@ Error ImageItem_Tild::append_compressed_tile_data(std::vector<uint8_t>& data, ui


Result<std::shared_ptr<HeifPixelImage>>
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);
Expand Down Expand Up @@ -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<uint32_t, uint32_t> range = m_tild_header.get_tile_offset_table_range_to_read(idx, nEntries);
Expand All @@ -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{};

Expand All @@ -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) {
Expand All @@ -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
Expand All @@ -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
Expand Down
Loading

0 comments on commit 859d364

Please sign in to comment.