Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,7 @@ if(UHDR_BUILD_TESTS)
target_include_directories(ultrahdr_unit_test PRIVATE
${PRIVATE_INCLUDE_DIR}
${GTEST_INCLUDE_DIRS}
"${THIRD_PARTY_DIR}/image_io/includes"
)
if(UHDR_BUILD_FUZZERS)
target_link_options(ultrahdr_unit_test PRIVATE -fsanitize=fuzzer-no-link)
Expand Down
3 changes: 3 additions & 0 deletions lib/include/ultrahdr/jpegr.h
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,11 @@ class JpegR : public UltraHdr {
* \param[in] metadata gainmap metadata descriptor
* \param[in, out] dest output image descriptor to store compressed ultrahdr
* image
* \param[in] pXmp optional primary-image XMP packet to preserve and
* merge when XMP metadata is enabled
*
* \return uhdr_error_info_t #UHDR_CODEC_OK if operation succeeds, uhdr_codec_err_t otherwise.
* An unsupported or unmergeable XMP packet returns #UHDR_CODEC_INVALID_PARAM in XMP mode.
*/
uhdr_error_info_t appendGainMap(uhdr_compressed_image_t* sdr_intent_compressed,
uhdr_compressed_image_t* gainmap_compressed,
Expand Down
5 changes: 4 additions & 1 deletion lib/include/ultrahdr/jpegrutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ std::string generateStandardXmpWithExtendedGuid(const std::string& guid);
* </x:xmpmeta>
*
* @param secondary_image_length length of secondary image
* @return XMP metadata in type of string
* @param user_xmp optional XMP packet from the primary image. Its unrelated XML is preserved while
* the encoder-owned primary-image gain-map description is replaced.
* @return XMP metadata in type of string. An empty string means that a supplied packet could not be
* safely merged.
*/
std::string generateXmpForPrimaryImage(size_t secondary_image_length,
uhdr_gainmap_metadata_ext_t& metadata,
Expand Down
8 changes: 8 additions & 0 deletions lib/src/jpegr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1292,6 +1292,14 @@ uhdr_error_info_t JpegR::appendGainMap(uhdr_compressed_image_t* sdr_intent_compr
uhdr_mem_block_t user_block{const_cast<char*>(user_xmp_str.data()), user_xmp_str.size(),
user_xmp_str.size()};
xmp_primary_str = generateXmpForPrimaryImage(secondary_image_size, *metadata, &user_block);
if (xmp_primary_str.empty()) {
uhdr_error_info_t status;
status.error_code = UHDR_CODEC_INVALID_PARAM;
status.has_detail = 1;
snprintf(status.detail, sizeof status.detail,
"unable to safely merge supplied XMP metadata into the primary image");
return status;
}
} else {
xmp_primary_str = user_xmp_str;
}
Expand Down
Loading
Loading