Skip to content

Multiple standard XMP segments error when converting JPG #2919

@jacksonzche

Description

@jacksonzche

When using libultrahdr library and the ultrahdr_app. Specifically in API-4 mode where the SDR and gainmap are both normal JPGs. Attempting to convert those files with libavif will produce error:

XMP extraction failed: invalid multiple standard XMP segments

Generating a test UHDR image with the jpeg_image.jpeg from libultrahdr:
ultrahdr_app -m 0 -i jpeg_image.jpg -g jpeg_image.jpg -f metadata.cfg

I inserted some debug code in avifjpeg.c, it seems the for loop:

for (jpeg_saved_marker_ptr marker = cinfo.marker_list; marker != NULL; marker = marker->next) {
            if ((marker->marker == (JPEG_APP0 + 1)) && (marker->data_length > AVIF_JPEG_STANDARD_XMP_TAG_LENGTH) &&
                !memcmp(marker->data, AVIF_JPEG_STANDARD_XMP_TAG, AVIF_JPEG_STANDARD_XMP_TAG_LENGTH)) {
...}

Will find two AVIF_JPEG_STANDARD_XMP_TAG: "http://ns.adobe.com/xap/1.0/" in the sdr rendition, and two more in the stored gainmap.

As long as the lines below only run once per loop, the conversion is otherwise successful:

standardXMPData = marker->data + AVIF_JPEG_STANDARD_XMP_TAG_LENGTH;
standardXMPSize = (uint32_t)(marker->data_length - AVIF_JPEG_STANDARD_XMP_TAG_LENGTH);

The loop picks up double tags inside the paris_exif_xmp_gainmap_xxx.jpg files as well.

I can't see where the second tag is using "exiv2 -pS".

Is this check actually needed, or can the loop just break once the first marker is found?

if (standardXMPData) {
                    fprintf(stderr, "XMP extraction failed: invalid multiple standard XMP segments\n");
                    goto cleanup;
                }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions