Bug 459117 - Linear gamma ICC profiles return an "Undefined" transfer characteristic
Summary: Linear gamma ICC profiles return an "Undefined" transfer characteristic
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: Color models (show other bugs)
Version: git master (please specify the git hash!)
Platform: Compiled Sources Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2022-09-14 17:16 UTC by amyspark
Modified: 2022-12-05 14:11 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description amyspark 2022-09-14 17:16:01 UTC
SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***

Linear gamma ICC profiles, such as Elle's Rec.2020 profile, return TRC_UNDEFINED when KoColorProfile::getTransferCharacteristics() is called. This is incorrect, as KoColorProfile::isLinear() will happily say yes and getEstimatedTRC() will also return (1, 1, 1).

STEPS TO REPRODUCE
1. Instantiate a copy of  the following profile: `KoColorSpaceRegistry::instance()->profileFor({}, PRIMARIES_ITU_R_BT_2020_2_AND_2100_0, TRC_LINEAR);`
2.  Query getTransferCharacteristics().

OBSERVED RESULT

It returns TRC_UNDEFINED.

EXPECTED RESULT

It returns TRC_LINEAR.


SOFTWARE/OS VERSIONS
Windows: 10 21H2
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 5.64
Qt Version: 5.12.12

ADDITIONAL INFORMATION
Commit f662063cf0
Comment 1 Kampidh 2022-11-27 13:53:26 UTC
I observed this as well, not only on linear, but on any profiles (be it sRGB, rec709, g22, etc). Always returned as TRC_UNDEFINED.

The only one that returns a correct value is when Krita creating a synthetic profile (that has a name "Krita [primaries] [trc]"). Noticed this while working on jxl impex.

It seems deep in the color registry that transfer characteristics is not set?
Comment 2 amyspark 2022-11-27 14:00:22 UTC
Correct, the synthetic profiles are build per-piece (and so the code had access to the transfer curve's characteristics). The ICC ones are treated as binary blobs, and we never tried to actually parse them...
Comment 3 amyspark 2022-11-29 17:09:55 UTC
Also see https://invent.kde.org/graphics/krita/-/commit/f2335c36dc85621e0284ecf688621a66f55e67b2 for the 5.1 cherry-pick.
Comment 4 Kampidh 2022-11-29 17:28:25 UTC
(In reply to amyspark from comment #3)
> Also see
> https://invent.kde.org/graphics/krita/-/commit/
> f2335c36dc85621e0284ecf688621a66f55e67b2 for the 5.1 cherry-pick.

Ah yes that was me. Sorry I used different name and email, idk why I can't log with same gmail here >< probably had to do with old krita/kde forum..?

Anyway I digress, that MR didn't fix the TRC though.. only the rgb primaries and whitepoint. TRC parsing is a bit tricky for non-gamma values.. (or complex parametric curve like ICC v4 did).
Comment 5 amyspark 2022-11-29 17:44:16 UTC
Oh, apologies, reopening then.
Comment 6 amyspark 2022-12-05 14:09:29 UTC
Git commit cf28aa85149ff5f8a07ae7ea3587fd4137bdfa58 by L. E. Segovia, on behalf of Rasyuqa A. H.
Committed on 05/12/2022 at 14:06.
Pushed by merge-service into branch 'master'.

Parse transfer characteristics from ICC profiles
Part-of: <https://invent.kde.org/graphics/krita/-/merge_requests/1667>

M  +50   -0    libs/pigment/KoColorProfile.cpp
M  +6    -0    libs/pigment/KoColorProfile.h
M  +2    -1    libs/pigment/KoColorProfileConstants.h
M  +5    -0    libs/pigment/colorprofiles/KoDummyColorProfile.cpp
M  +1    -0    libs/pigment/colorprofiles/KoDummyColorProfile.h
M  +8    -0    plugins/color/lcms2engine/colorprofiles/IccColorProfile.cpp
M  +2    -0    plugins/color/lcms2engine/colorprofiles/IccColorProfile.h
M  +40   -4    plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.cpp
M  +2    -0    plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.h

https://invent.kde.org/graphics/krita/commit/cf28aa85149ff5f8a07ae7ea3587fd4137bdfa58
Comment 7 amyspark 2022-12-05 14:11:51 UTC
Git commit a8e7dc17424a62041f76a3833eedfe77f8848c44 by L. E. Segovia, on behalf of Rasyuqa A. H.
Committed on 05/12/2022 at 14:11.
Pushed by lsegovia into branch 'krita/5.1'.

Parse transfer characteristics from ICC profiles
Part-of: <https://invent.kde.org/graphics/krita/-/merge_requests/1667>
(cherry picked from commit cf28aa85149ff5f8a07ae7ea3587fd4137bdfa58)

M  +50   -0    libs/pigment/KoColorProfile.cpp
M  +6    -0    libs/pigment/KoColorProfile.h
M  +2    -1    libs/pigment/KoColorProfileConstants.h
M  +5    -0    libs/pigment/colorprofiles/KoDummyColorProfile.cpp
M  +1    -0    libs/pigment/colorprofiles/KoDummyColorProfile.h
M  +8    -0    plugins/color/lcms2engine/colorprofiles/IccColorProfile.cpp
M  +2    -0    plugins/color/lcms2engine/colorprofiles/IccColorProfile.h
M  +40   -4    plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.cpp
M  +2    -0    plugins/color/lcms2engine/colorprofiles/LcmsColorProfileContainer.h

https://invent.kde.org/graphics/krita/commit/a8e7dc17424a62041f76a3833eedfe77f8848c44