Skip to content
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

Support DisplayP3 and BT.2020 + PQ #96

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

hannes-vernooij
Copy link
Contributor

⚠️ Depends on #94
This PR adds support for storing Display P3 and Rec.2020 + PQ aside from sRGB. Functionality to specify which color space to use has also been added to cavif-rs. Be mindful that exported HDR images are not well supported on the web.

Isolated changes: c4e20dc

In the current implementation, 10-bit signals can be stored, but they are derived from 8-bit signals, offering no visual improvement. All incoming data has been assumed to be 8-bit sRGB. This PR takes the first step in removing these assumptions by enabling the storage of signals with higher bit depth. It lays the groundwork for full support of writing HDR images.
.value_name("sRGB/displayP3/rec2020Pq")
.value_parser(parse_color_space)
.required(true)
.help("The color space passed values are in [possible values: sRGB, displayP3, rec2020Pq] "))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.help("The color space passed values are in [possible values: sRGB, displayP3, rec2020Pq] "))
.help("The color space passed values are in [possible values: sRGB, displayP3, rec2020Pq]"))

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that your parse_color_space() ignores casing, perhaps this should be written without any, too.

(Though personally I favour sticking to case-sensitive cmdline arguments...)

match s.to_lowercase().as_str() {
"srgb" => Ok(ColorSpace::Srgb),
"displayp3" => Ok(ColorSpace::DisplayP3),
"rec2020Pq" => Ok(ColorSpace::Rec2020Pq),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise to_lowercase() can't ever match:

Suggested change
"rec2020Pq" => Ok(ColorSpace::Rec2020Pq),
"rec2020pq" => Ok(ColorSpace::Rec2020Pq),

Comment on lines +83 to +85
// Since there's no matrix for Display P3 implemented, the one of BT709 is used.
// Although this isn't perfectly accurate, it should be acceptable as long as the decoder uses the same approach.
ColorSpace::DisplayP3 => MatrixCoefficients::BT709,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we should use the BT709 matrix coefficients for DisplayP3 inside rgb_to_ycbcr() in this case?

(at which point you can maybe create a fn color_matrix(self) -> [3; f32] on MatrixCoefficients?)

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