-
-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
set NCLX defaults to match sRGB and change handling of unspecified NCLX values #1017
Conversation
libheif/nclx.cc
Outdated
m_colour_primaries = heif_color_primaries_ITU_R_BT_709_5; | ||
} | ||
|
||
if (m_transfer_characteristics == heif_color_primaries_unspecified) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (m_transfer_characteristics == heif_color_primaries_unspecified) { | |
if (m_transfer_characteristics == heif_transfer_characteristic_unspecified) { |
c428e08
to
136cf01
Compare
examples/heif_enc.cc
Outdated
uint16_t nclx_matrix_coefficients = 6; | ||
uint16_t nclx_colour_primaries = 2; | ||
uint16_t nclx_transfer_characteristic = 2; | ||
uint16_t nclx_matrix_coefficients = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 5 for sRGB
libheif/nclx.cc
Outdated
m_matrix_coefficients = 6; | ||
m_colour_primaries = 1; | ||
m_transfer_characteristics = 13; | ||
m_matrix_coefficients = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 for sRGB
libheif/nclx.cc
Outdated
void color_profile_nclx::replace_undefined_values_with_defaults() | ||
{ | ||
if (m_matrix_coefficients == heif_matrix_coefficients_unspecified) { | ||
m_matrix_coefficients = heif_matrix_coefficients_ITU_R_BT_709_5; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heif_matrix_coefficients_ITU_R_BT_470_6_System_B_G
(i.e. 5) for sRGB
Are there any references what the values should be for sRGB? I found this random piece of code: https://observablehq.com/@eeeps/color-space-determiner that also seems to favor 1,13,1. |
Plain wrong. See https://www.itu.int/rec/T-REC-H.273 for IEC 61966-2-1 (sRGB/sYCC) legal values. |
Accoding to H273, color_primaries=1. I think we agree here. |
I found these two comments: Which says that |
IEC 61966-2-1 mentions sYCC representation that specifically uses matrix coeffs 5 (601). However, note that the same wikipedia page also mentions sRGB conversion to XYZ using the 709 coeffs earlier... Also note that the JPEG/JFIF specification uses 601 matrix coeffs. |
Ok, that makes sense. Then we'll go for |
Yes. But since matrix_coefficients 5 and 6 are exactly the same, this does not matter. |
Yeah, IIRC this was because either Chrome or Safari originally only implemented parsing that combo and not (IMHO more canonical) |
Thanks, @kleisauke , @kmilos |
This is an alternative implementation of #1015.