Add sparse ICC v4 mAB/mBA LUT support for ICC conversion#3070
Merged
JimBobSquarePants merged 2 commits intomainfrom Mar 6, 2026
Merged
Add sparse ICC v4 mAB/mBA LUT support for ICC conversion#3070JimBobSquarePants merged 2 commits intomainfrom
JimBobSquarePants merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for sparse ICC v4 mAB/mBA LUT pipelines (eg. A -> CLUT -> Matrix) during ICC-based color conversion to fix decode failures for certain embedded profiles (Issue #3064 / Display P3 PQ).
Changes:
- Update
LutAToB/LutBToAtag validation to derive channel counts from stage continuity (supports sparse stage combinations). - Update
LutABCalculatorto execute only the stages present, in ICC specification order formAB/mBA. - Add a regression test image + reference output for Issue #3064.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Images/Input/Jpg/icc-profiles/issue-3064.jpg | Adds regression JPEG containing the problematic embedded ICC profile (LFS). |
| tests/Images/External/ReferenceOutput/JpegDecoderTests/Decode_RGB_ICC_Jpeg_Issue3064_Rgba32_issue-3064.png | Adds expected decode output for regression comparison (LFS). |
| tests/ImageSharp.Tests/TestImages.cs | Registers the new ICC regression test image path. |
| tests/ImageSharp.Tests/Formats/Jpg/JpegDecoderTests.cs | Adds a decoder test that exercises ICC conversion for Issue #3064. |
| src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs | Reworks LUT stage validation to support sparse mBA pipelines and derive channel counts. |
| src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs | Reworks LUT stage validation to support sparse mAB pipelines and derive channel counts. |
| src/ImageSharp/Metadata/Profiles/ICC/IccProfile.cs | Minor refactor to use range-based slicing when restoring hash inputs. |
| src/ImageSharp/Metadata/Profiles/ICC/DataReader/IccDataReader.TagDataEntry.cs | Refactors tag entry dispatch to a switch expression; makes a local helper static. |
| src/ImageSharp/ColorProfiles/Icc/IccConverterbase.Conversions.cs | Improves Invalid ICC entry exception message by including the tag. |
| src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs | Applies only present LUT stages in ICC order; removes legacy “fixed combinations” logic. |
| src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.CalculationType.cs | Simplifies calculation type enum to direction-only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutAToBTagDataEntry.cs
Show resolved
Hide resolved
src/ImageSharp/Metadata/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
Show resolved
Hide resolved
src/ImageSharp/ColorProfiles/Icc/Calculators/LutABCalculator.cs
Outdated
Show resolved
Hide resolved
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.
Prerequisites
Description
Fixes #3064
Adds support for valid sparse ICC v4 mAB/mBA pipelines, including transforms such as A -> CLUT -> Matrix.
Updates LUT tag validation to derive channel counts from stage continuity, updates LutABCalculator to execute only the stages present in ICC order, and adds documentation for the new behavior.
This fixes decode failures for embedded ICC profiles like Display P3 PQ profiles.