Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/strukturag/libheif into t…
Browse files Browse the repository at this point in the history
…imestamp_boxes
  • Loading branch information
dukesook committed Nov 2, 2023
2 parents 42395cd + c469dcb commit d23cca4
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 35 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.16.3) # Oldest Ubuntu LTS (20.04 currently)

project(libheif LANGUAGES C CXX VERSION 1.17.1)
project(libheif LANGUAGES C CXX VERSION 1.17.2)

# compatibility_version is never allowed to be decreased for any specific SONAME.
# Libtool in the libheif-1.15.1 release had set it to 17.0.0, so we have to use this for the v1.x.y versions.
Expand Down
2 changes: 2 additions & 0 deletions examples/decoder_png.cc
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ InputImage loadPNG(const char* filename, int output_bit_depth)

// --- read XMP data

#ifdef PNG_iTXt_SUPPORTED
png_textp textPtr = nullptr;
const png_uint_32 nTextChunks = png_get_text(png_ptr, info_ptr, &textPtr, nullptr);
for (png_uint_32 i = 0; i < nTextChunks; i++, textPtr++) {
Expand All @@ -231,6 +232,7 @@ InputImage loadPNG(const char* filename, int output_bit_depth)
}
}
}
#endif

int band = png_get_channels(png_ptr, info_ptr);

Expand Down
2 changes: 2 additions & 0 deletions examples/encoder_png.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ bool PngEncoder::Encode(const struct heif_image_handle* handle,

// --- write XMP metadata

#ifdef PNG_iTXt_SUPPORTED
// spec: https://raw.githubusercontent.com/adobe/xmp-docs/master/XMPSpecifications/XMPSpecificationPart3.pdf
std::vector<uint8_t> xmp = get_xmp_metadata(handle);
if (!xmp.empty()) {
Expand All @@ -156,6 +157,7 @@ bool PngEncoder::Encode(const struct heif_image_handle* handle,
xmp_text.itxt_length = text_length;
png_set_text(png_ptr, info_ptr, &xmp_text, 1);
}
#endif

png_write_info(png_ptr, info_ptr);

Expand Down
2 changes: 0 additions & 2 deletions libheif/box.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,6 @@ class Box_infe : public FullBox

Error write(StreamWriter& writer) const override;

void set_item_uri_type(const std::string& type) { m_item_uri_type = type; }

const std::string& get_item_uri_type() const { return m_item_uri_type; }

protected:
Expand Down
9 changes: 3 additions & 6 deletions libheif/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3324,19 +3324,19 @@ Error HeifContext::add_exif_metadata(const std::shared_ptr<Image>& master_image,

return add_generic_metadata(master_image,
data_array.data(), (int) data_array.size(),
"Exif", nullptr, nullptr, heif_metadata_compression_off);
"Exif", nullptr, heif_metadata_compression_off);
}


Error HeifContext::add_XMP_metadata(const std::shared_ptr<Image>& master_image, const void* data, int size,
heif_metadata_compression compression)
{
return add_generic_metadata(master_image, data, size, "mime", "application/rdf+xml", nullptr, compression);
return add_generic_metadata(master_image, data, size, "mime", "application/rdf+xml", compression);
}


Error HeifContext::add_generic_metadata(const std::shared_ptr<Image>& master_image, const void* data, int size,
const char* item_type, const char* content_type, const char* item_uri_type, heif_metadata_compression compression)
const char* item_type, const char* content_type, heif_metadata_compression compression)
{
// create an infe box describing what kind of data we are storing (this also creates a new ID)

Expand All @@ -3345,9 +3345,6 @@ Error HeifContext::add_generic_metadata(const std::shared_ptr<Image>& master_ima
if (content_type != nullptr) {
metadata_infe_box->set_content_type(content_type);
}
if (item_uri_type != nullptr) {
metadata_infe_box->set_item_uri_type(item_uri_type);
}

heif_item_id metadata_id = metadata_infe_box->get_item_ID();

Expand Down
2 changes: 1 addition & 1 deletion libheif/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class HeifContext : public ErrorBuffer
Error add_XMP_metadata(const std::shared_ptr<Image>& master_image, const void* data, int size, heif_metadata_compression compression);

Error add_generic_metadata(const std::shared_ptr<Image>& master_image, const void* data, int size,
const char* item_type, const char* content_type, const char* item_uri_type,
const char* item_type, const char* content_type,
heif_metadata_compression compression);

heif_property_id add_property(heif_item_id targetItem, std::shared_ptr<Box> property, bool essential);
Expand Down
18 changes: 1 addition & 17 deletions libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2829,23 +2829,7 @@ struct heif_error heif_context_add_generic_metadata(struct heif_context* ctx,
const char* item_type, const char* content_type)
{
Error error = ctx->context->add_generic_metadata(image_handle->image, data, size,
item_type, content_type, nullptr, heif_metadata_compression_off);
if (error != Error::Ok) {
return error.error_struct(ctx->context.get());
}
else {
return heif_error_success;
}
}


struct heif_error heif_context_add_generic_uri_metadata(struct heif_context* ctx,
const struct heif_image_handle* image_handle,
const void* data, int size,
const char* item_uri_type)
{
Error error = ctx->context->add_generic_metadata(image_handle->image, data, size,
"uri ", nullptr, item_uri_type, heif_metadata_compression_off);
item_type, content_type, heif_metadata_compression_off);
if (error != Error::Ok) {
return error.error_struct(ctx->context.get());
}
Expand Down
8 changes: 0 additions & 8 deletions libheif/heif.h
Original file line number Diff line number Diff line change
Expand Up @@ -2088,14 +2088,6 @@ struct heif_error heif_context_add_generic_metadata(struct heif_context* ctx,
const void* data, int size,
const char* item_type, const char* content_type);

// Add generic metadata with item_type "uri ". Items with this type do not have a content_type, but
// an item_uri_type and they have no content_encoding (they are always stored uncompressed).
LIBHEIF_API
struct heif_error heif_context_add_generic_uri_metadata(struct heif_context* ctx,
const struct heif_image_handle* image_handle,
const void* data, int size,
const char* item_uri_type);

// --- heif_image allocation

// Create a new image of the specified resolution and colorspace.
Expand Down

0 comments on commit d23cca4

Please sign in to comment.