Skip to content

Commit

Permalink
fix more clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Aug 10, 2024
1 parent 3be2363 commit 8840cc4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
9 changes: 7 additions & 2 deletions libheif/api/libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -953,12 +953,16 @@ struct heif_error heif_image_handle_decode_image_tile(const struct heif_image_ha
return {heif_error_Usage_error, heif_suberror_Invalid_parameter_value, "z0 must be 0 for 2D images"};
}

if (x0 > 0xFFFFFFFF || y0 > 0xFFFFFFFF) {
return {heif_error_Usage_error, heif_suberror_Invalid_parameter_value, "x0/y0 currently must be 32 bit"};
}

heif_item_id first_tile_id = handle->image->get_grid_tiles()[0];
auto tile = handle->context->get_image(first_tile_id);

const ImageGrid& gridspec = handle->image->get_grid_spec();
uint32_t tile_x = x0 / tile->get_width();
uint32_t tile_y = y0 / tile->get_height();
uint32_t tile_x = static_cast<uint32_t>(x0) / tile->get_width();
uint32_t tile_y = static_cast<uint32_t>(y0) / tile->get_height();

heif_item_id tile_id = handle->image->get_grid_tiles()[tile_y * gridspec.get_columns() + tile_x];
heif_image_handle* tile_handle;
Expand All @@ -974,6 +978,7 @@ struct heif_error heif_image_handle_decode_image_tile(const struct heif_image_ha
heif_context_free(ctx);
err = heif_decode_image(tile_handle, out_img, colorspace, chroma, options);
if (err.code) {
heif_image_handle_release(tile_handle);
err.message = nullptr; // have to delete the text pointer because the text may be deleted with the context (TODO)
return err;
}
Expand Down
2 changes: 1 addition & 1 deletion libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class Box_iloc : public FullBox
public:
Box_iloc();

~Box_iloc();
~Box_iloc() override;

void set_use_tmp_file(bool flag);

Expand Down
14 changes: 11 additions & 3 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1416,7 +1416,7 @@ Error HeifContext::get_id_of_non_virtual_child_image(heif_item_id id, heif_item_
}


int HeifContext::Image::get_ispe_width() const
uint32_t HeifContext::Image::get_ispe_width() const
{
auto ispe = m_heif_context->m_heif_file->get_property<Box_ispe>(m_id);
if (!ispe) {
Expand All @@ -1428,7 +1428,7 @@ int HeifContext::Image::get_ispe_width() const
}


int HeifContext::Image::get_ispe_height() const
uint32_t HeifContext::Image::get_ispe_height() const
{
auto ispe = m_heif_context->m_heif_file->get_property<Box_ispe>(m_id);
if (!ispe) {
Expand Down Expand Up @@ -2854,8 +2854,16 @@ Result<std::shared_ptr<HeifContext::Image>> HeifContext::add_tild_item(const hei
const int construction_method = 0; // 0=mdat 1=idat
m_heif_file->append_iloc_data(tild_id, header_data, construction_method);


if (parameters->image_width > 0xFFFFFFFF || parameters->image_height > 0xFFFFFFFF) {
return {Error(heif_error_Usage_error, heif_suberror_Invalid_image_size,
"'ispe' only supports image size up to 4294967295 pixels per dimension")};
}

// Add ISPE property
m_heif_file->add_ispe_property(tild_id, parameters->image_width, parameters->image_height);
m_heif_file->add_ispe_property(tild_id,
static_cast<uint32_t>(parameters->image_width),
static_cast<uint32_t>(parameters->image_height));

#if 0
// TODO
Expand Down
9 changes: 5 additions & 4 deletions libheif/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,14 @@ class HeifContext : public ErrorBuffer

//void set_id(heif_item_id id) { m_id=id; } (already set in constructor)

int get_width() const { return m_width; }
// 32bit limitation from `ispe`
uint32_t get_width() const { return m_width; }

int get_height() const { return m_height; }
uint32_t get_height() const { return m_height; }

int get_ispe_width() const;
uint32_t get_ispe_width() const;

int get_ispe_height() const;
uint32_t get_ispe_height() const;

int get_luma_bits_per_pixel() const;

Expand Down

0 comments on commit 8840cc4

Please sign in to comment.