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

Testing mDCv #359

Open
svgeesus opened this issue Oct 27, 2023 · 2 comments
Open

Testing mDCv #359

svgeesus opened this issue Oct 27, 2023 · 2 comments

Comments

@svgeesus
Copy link
Contributor

svgeesus commented Oct 27, 2023

For browsers and image viewers, there is no normative requirement that can be tested:

The mDCv chunk provides informative static metadata which allows a target (consumer) display to potentially optimize it's tone mapping decisions on a comparison of its inherent capabilities versus the original mastering displays capabilities.

If we are aware of implementations that do something with this, then we could check that they do different things with, say, one image reporting sRGB and then BT.2100 as mastering volume But what they actually do is completely unconstrained.

For a PNG validator or checker, it could report the presence of the chunk, check that the sizes of the data are correct and present the values, but that is about all.

For content creation tools, a list of tools that writes the chunk is helpful to demonstrate implementation.

@svgeesus
Copy link
Contributor Author

svgeesus commented Jan 8, 2024

I hacked mDCv support into my fork of the JavaScript PNG chunk inspector:

image

 ["mDCv", "Mastering Display Color Volume", false, (chunk, earlier) => {
            addErrorIfHasType(earlier, "PLTE", chunk, "Chunk must be before PLTE chunk");
            addErrorIfHasType(earlier, "IDAT", chunk, "Chunk must be before IDAT chunk");
            if (chunk.data.length != 24) {
                chunk.errorNotes.push("Invalid data length");
                return;
            }
            let red_chromaticity_x = chunk.data[0]*256 + chunk.data[1];
            let red_chromaticity_y = chunk.data[2]*256 + chunk.data[3];
            let rx = (red_chromaticity_x * 0.00002).toPrecision(6);
            let ry = (red_chromaticity_y * 0.00002).toPrecision(6);
            chunk.innerNotes.push(`red: x = ${rx}, y = ${ry}`);
            let green_chromaticity_x = chunk.data[4]*256 + chunk.data[5];
            let green_chromaticity_y = chunk.data[6]*256 + chunk.data[7];
            let gx = (green_chromaticity_x * 0.00002).toPrecision(6);
            let gy = (green_chromaticity_y * 0.00002).toPrecision(6);
            chunk.innerNotes.push(`green: x = ${gx}, y = ${gy}`);
            let blue_chromaticity_x = chunk.data[8]*256 + chunk.data[9];
            let blue_chromaticity_y = chunk.data[10]*256 + chunk.data[11];
            let bx = (blue_chromaticity_x * 0.00002).toPrecision(6);
            let by = (blue_chromaticity_y * 0.00002).toPrecision(6);
            chunk.innerNotes.push(`blue: x = ${bx}, y = ${by}`);
            let white_chromaticity_x = chunk.data[12]*256 + chunk.data[13];
            let white_chromaticity_y = chunk.data[14]*256 + chunk.data[15];
            let wx = (white_chromaticity_x * 0.00002).toPrecision(6);
            let wy = (white_chromaticity_y * 0.00002).toPrecision(6);
            chunk.innerNotes.push(`white: x = ${wx}, y = ${wy}`);
            let max_lum = chunk.data[16]*256 + chunk.data[17];
            let min_lum = chunk.data[18]*256 + chunk.data[19];
            let max = (max_lum * 0.0001).toPrecision(4);
            let min = (min_lum * 0.0001).toPrecision(4);
            chunk.innerNotes.push(`Max luminance: ${max} cd/m²`);
            chunk.innerNotes.push(`Min luminance: ${min} cd/m²`);
            }],

@svgeesus svgeesus added this to the 3rd edition milestone Feb 21, 2024
@svgeesus
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant