Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 14, 2024
1 parent b370e22 commit 4bd63f3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
4 changes: 2 additions & 2 deletions libheif/api/libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3776,9 +3776,9 @@ struct heif_error heif_context_add_generic_uri_metadata(struct heif_context* ctx
}


void heif_context_set_maximum_image_size_limit(struct heif_context* ctx, int maximum_width)
void heif_context_set_maximum_image_size_limit(struct heif_context* ctx, int maximum_pixels)
{
ctx->context->set_maximum_image_size_limit(maximum_width);
ctx->context->get_security_limits()->max_image_size_pixels = maximum_pixels;
}


Expand Down
2 changes: 1 addition & 1 deletion libheif/api/libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ void heif_context_debug_dump_boxes_to_file(struct heif_context* ctx, int fd);


LIBHEIF_API
void heif_context_set_maximum_image_size_limit(struct heif_context* ctx, int maximum_width);
void heif_context_set_maximum_image_size_limit(struct heif_context* ctx, int maximum_pixels);

// If the maximum threads number is set to 0, the image tiles are decoded in the main thread.
// This is different from setting it to 1, which will generate a single background thread to decode the tiles.
Expand Down
6 changes: 0 additions & 6 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,6 @@ HeifContext::~HeifContext()
}


void HeifContext::set_maximum_image_size_limit(uint32_t maximum_size)
{
m_limits.max_image_size_pixels = maximum_size;
}


static void copy_security_limits(heif_security_limits* dst, const heif_security_limits* src)
{
dst->version = 1;
Expand Down
22 changes: 8 additions & 14 deletions libheif/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,6 @@ class HeifContext : public ErrorBuffer

[[nodiscard]] const heif_security_limits* get_security_limits() const { return &m_limits; }

// Sets the maximum size of both width and height of an image. The total limit
// of the image size (width * height) will be "maximum_size * maximum_size".
void set_maximum_image_size_limit(uint32_t maximum_size);

uint64_t get_maximum_image_size_limit() const
{
return get_security_limits()->max_image_size_pixels;
}

Error read(const std::shared_ptr<StreamReader>& reader);

Error read_from_file(const char* input_filename);
Expand All @@ -85,9 +76,12 @@ class HeifContext : public ErrorBuffer

std::shared_ptr<HeifFile> get_heif_file() const { return m_heif_file; }


// === image items ===

std::vector<std::shared_ptr<ImageItem>> get_top_level_images(bool return_error_images);

void insert_image_item(heif_item_id id, std::shared_ptr<ImageItem> img) {
void insert_image_item(heif_item_id id, const std::shared_ptr<ImageItem>& img) {
m_all_images.insert(std::make_pair(id, img));
}

Expand All @@ -110,11 +104,15 @@ class HeifContext : public ErrorBuffer
const struct heif_decoding_options& options,
bool decode_only_tile, uint32_t tx, uint32_t ty) const;

Error get_id_of_non_virtual_child_image(heif_item_id in, heif_item_id& out) const;

std::string debug_dump_boxes() const;


// === writing ===

void write(StreamWriter& writer);

// Create all boxes necessary for an empty HEIF file.
// Note that this is no valid HEIF file, since some boxes (e.g. pitm) are generated, but
// contain no valid data yet.
Expand Down Expand Up @@ -172,10 +170,6 @@ class HeifContext : public ErrorBuffer

void add_region_referenced_mask_ref(heif_item_id region_item_id, heif_item_id mask_item_id);

void write(StreamWriter& writer);

Error get_id_of_non_virtual_child_image(heif_item_id in, heif_item_id& out) const;

private:
std::map<heif_item_id, std::shared_ptr<ImageItem>> m_all_images;

Expand Down
1 change: 1 addition & 0 deletions libheif/security_limits.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "security_limits.h"
#include <limits>


struct heif_security_limits global_security_limits {
Expand Down

0 comments on commit 4bd63f3

Please sign in to comment.