Skip to content

Accept BT.601 HEVC colour in bounded decoding - #31

Merged
laurenspriem merged 1 commit into
ente:mainfrom
laurens-pilot:fix/bounded-bt601-vui-color
Nov 3, 2026
Merged

laurenspriem merged 1 commit into
ente:mainfrom
laurens-pilot:fix/bounded-bt601-vui-color

Conversation

@laurens-pilot

Copy link
Copy Markdown

Samsung HEICs have no colr box and signal BT.601 colour (primaries 5, transfer 6, matrix 5, full range) only in the HEVC stream. The full decoder returns these as untagged RGB, but decode_bounded rejected them with Unsupported("unprofiled HEVC color"). It now treats stream-signalled BT.601 primaries (5 and 6) like sRGB, as it already did for 1 and 2. Images whose stream signals a wide gamut (BT.2020, P3) with no colr box are still rejected.

On a Galaxy S22 motion-photo HEIC (3000×4000), decode_bounded now matches decode_bytes_to_rgb8 exactly. Apple's ImageIO also reports this file as sRGB. Converting the BT.601 primaries to sRGB instead would have moved the output away from both: it differs from the full decoder by up to 14 levels, and agreement with ImageIO within ±1 drops from 97.3% to 90.2% of samples.

Source fork PR: laurens-pilot#20

@laurenspriem

Samsung HEICs carry no colr box and signal BT.601 primaries in the HEVC
VUI. The full decoder renders these as untagged sRGB, but the bounded
path rejected them as unprofiled colour. Treat VUI primaries 5 and 6 like
1 and 2 so bounded output matches the full decoder; wide-gamut VUI-only
colour is still rejected.
@laurenspriem
laurenspriem merged commit beabb02 into ente:main Nov 3, 2026
3 checks passed
@laurens-pilot
laurens-pilot deleted the fix/bounded-bt601-vui-color branch November 3, 2026 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants