From ea518da3a839c59f88ffc6c4020920c944251fd2 Mon Sep 17 00:00:00 2001 From: Ram Mohan M Date: Fri, 20 Dec 2024 17:29:33 +0530 Subject: [PATCH] fix secondary image size compute in dual encoding when iso and xmp are enabled together, the size of secondary image does not include the jpeg app2 marker size. fixes #342 Test: ./ultrahdr_app --- lib/src/jpegr.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/src/jpegr.cpp b/lib/src/jpegr.cpp index ce4d6e0..8ce700f 100644 --- a/lib/src/jpegr.cpp +++ b/lib/src/jpegr.cpp @@ -1160,12 +1160,12 @@ uhdr_error_info_t JpegR::appendGainMap(uhdr_compressed_image_t* sdr_intent_compr iso_secondary_length = 2 + isoNameSpaceLength + iso_secondary_data.size(); } - size_t secondary_image_size = 2 /* 2 bytes length of APP1 sign */ + gainmap_compressed->data_sz; + size_t secondary_image_size = gainmap_compressed->data_sz; if (kWriteXmpMetadata) { - secondary_image_size += xmp_secondary_length; + secondary_image_size += 2 /* 2 bytes length of APP1 sign */ + xmp_secondary_length; } if (kWriteIso21496_1Metadata) { - secondary_image_size += iso_secondary_length; + secondary_image_size += 2 /* 2 bytes length of APP2 sign */ + iso_secondary_length; } // Check if EXIF package presents in the JPEG input.