fix(xmp): handle near-limit XMP spill to Extended XMP, add fuzzer and fixture coverage - #494
Merged
DichenZhang1 merged 1 commit intoOct 2, 2026
Conversation
… fixture coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up polish on top of
feat/preserve-xmp-metadata(09a3936) covering the near-limit Standard XMP spill boundary, duplicate#ifdefcleanup, fuzzer coverage, and real-world Apple gain-map fixture tests.Changes
Near-Limit Standard XMP (
~64.9 KB – 65,503 B) Spill to Extended XMP (lib/src/jpegr.cpp,lib/src/ultrahdr_api.cpp):JpegR::appendGainMap, whenkWriteXmpMetadata(-DUHDR_WRITE_XMP=ON) is active and merging the Ultra HDRContainer:Directoryinto a standard-sized user XMP packet (<= 65,503bytes) pushesxmp_primary_stroverkMaxStandardXmpPayload(65,503bytes), revertxmp_primary_strto the unmergeduser_xmp_strand spill it cleanly into Extended XMP chunks while writing only the Ultra HDR primary XMP +xmpNote:HasExtendedXMPGUID into the Standard XMP segment (preventing duplicateContainer:Directoryentries in Extended XMP).xmpAllowanceinuhdr_encode(kJpegAppSegmentTotalMaxBytes + xmp_sz + num_chunks * 79) so near-limit standard XMP packets that spill into Extended XMP never overflow the output buffer.Header Include Cleanup (
lib/src/ultrahdr_api.cpp):#ifdef UHDR_ENABLE_HEIF#includeblock.Fuzzer Coverage (
fuzzer/ultrahdr_dec_fuzzer.cpp,fuzzer/ultrahdr_enc_fuzzer.cpp):uhdr_strip_gain_map(two-pass size query + strip) anduhdr_dec_get_xmpin both fuzzers without changingFuzzedDataProviderconsumption order.Unit Tests (
tests/ultrahdr_api_test.cpp):UltraHdrApiTest.StripGainMapOnAppleGainMapFixtures: Verifiesuhdr_strip_gain_maponapple_gainmap_new.jpgandapple_gainmap_old.jpg(includingDRIandRST0..RST7markers in the primary scan).UltraHdrApiTest.NearLimitStandardXmpSpillsCleanlyToExtendedXmp: Verifies a65,200-byte user XMP packet spills cleanly to Extended XMP in-DUHDR_WRITE_XMP=ONmode and round-trips throughuhdr_dec_get_xmpanduhdr_strip_gain_map.Test Plan
ultrahdr_unit_testin both-DUHDR_WRITE_XMP=ON -DUHDR_WRITE_ISO=ON(26/26UltraHdrApiTest, 34/34JpegRTest, 17/17JpegDecoderHelperTest) and-DUHDR_WRITE_XMP=OFF -DUHDR_WRITE_ISO=ON(21/21UltraHdrApiTest).