diff --git a/apps/shared/avifjpeg.c b/apps/shared/avifjpeg.c index 4d15a6cb3c..e1201ed9d3 100644 --- a/apps/shared/avifjpeg.c +++ b/apps/shared/avifjpeg.c @@ -1146,6 +1146,13 @@ static avifBool avifJPEGReadInternal(FILE * f, gainMap->altDepth = 8; gainMap->altPlaneCount = (avif->yuvFormat == AVIF_PIXEL_FORMAT_YUV400 && gainMap->image->yuvFormat == AVIF_PIXEL_FORMAT_YUV400) ? 1 : 3; + if (avif->icc.size > 0) { + // The base image's ICC should also apply to the alternage image. + if (avifRWDataSet(&gainMap->altICC, avif->icc.data, avif->icc.size) != AVIF_RESULT_OK) { + fprintf(stderr, "Setting gain map ICC profile failed: out of memory\n"); + goto cleanup; + } + } avif->gainMap = gainMap; } else { avifGainMapDestroy(gainMap); diff --git a/apps/shared/avifutil.c b/apps/shared/avifutil.c index 7186c511e7..743845bcdb 100644 --- a/apps/shared/avifutil.c +++ b/apps/shared/avifutil.c @@ -146,6 +146,11 @@ static void avifImageDumpInternal(const avifImage * avif, printf(" * Color Primaries: %u\n", avif->gainMap->altColorPrimaries); printf(" * Transfer Char. : %u\n", avif->gainMap->altTransferCharacteristics); printf(" * Matrix Coeffs. : %u\n", avif->gainMap->altMatrixCoefficients); + if (avif->gainMap->altICC.size != 0) { + printf(" * ICC Profile : Present (%" AVIF_FMT_ZU " bytes)\n", avif->gainMap->altICC.size); + } else { + printf(" * ICC Profile : Absent\n"); + } if (avif->gainMap->altDepth) { printf(" * Bit Depth : %u\n", avif->gainMap->altDepth); } diff --git a/tests/data/README.md b/tests/data/README.md index 0b23b67173..12e9057966 100644 --- a/tests/data/README.md +++ b/tests/data/README.md @@ -429,6 +429,20 @@ a hex editor to make the MPF metadata big endian, as signaled by the four bytes | 33507 | 0xffe1 APP1 | 571 | `http://ns.adobe.com/xap/1.0/. p3.icc +exiftool "-icc_profile<=p3.icc" paris_exif_xmp_icc_gainmap_bigendian.jpg +``` ### File [color_grid_gainmap_different_grid.avif](color_grid_gainmap_different_grid.avif) diff --git a/tests/data/goldens/paris_exif_xmp_icc_gainmap_bigendian.jpg.avif.xml b/tests/data/goldens/paris_exif_xmp_icc_gainmap_bigendian.jpg.avif.xml new file mode 100644 index 0000000000..0113a2ef73 --- /dev/null +++ b/tests/data/goldens/paris_exif_xmp_icc_gainmap_bigendian.jpg.avif.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/paris_exif_xmp_icc_gainmap_bigendian.jpg b/tests/data/paris_exif_xmp_icc_gainmap_bigendian.jpg new file mode 100644 index 0000000000..52d160d1f0 Binary files /dev/null and b/tests/data/paris_exif_xmp_icc_gainmap_bigendian.jpg differ diff --git a/tests/test_cmd_enc_gainmap_boxes_golden.sh b/tests/test_cmd_enc_gainmap_boxes_golden.sh index 32de9c1a1e..fcd8041805 100644 --- a/tests/test_cmd_enc_gainmap_boxes_golden.sh +++ b/tests/test_cmd_enc_gainmap_boxes_golden.sh @@ -20,7 +20,9 @@ # All .avif files created here will become test cases. encode_test_files() { # Image with a gain map. - for f in "paris_exif_xmp_gainmap_bigendian.jpg" "paris_exif_xmp_gainmap_littleendian.jpg"; do + for f in "paris_exif_xmp_gainmap_bigendian.jpg" \ + "paris_exif_xmp_icc_gainmap_bigendian.jpg" \ + "paris_exif_xmp_gainmap_littleendian.jpg"; do "${AVIFENC}" -s 9 "${TESTDATA_DIR}/$f" -o "$f.avif" done