Conversation
Changed behavior: PNG input, and ICO input of PNG-encoded icons, with an
mDCV chunk now report ten mdcv_* integer attributes; before, the chunk
was ignored. PNG output and PNG-encoded ICO output, which used to ignore
mdcv_* attributes, now write an mDCV chunk when they form a complete,
valid record and a cICP chunk is written too. Otherwise (an incomplete,
invalid or unsupported record, or no cICP) the attributes are still left
out of the file, now with an "OpenImageIO WARNING:" debug message
explaining why. Input does not apply the output limits, so copying a
file whose record is out of range still drops the chunk, now with that
message. No write that used to succeed fails because of them, unless
libpng itself rejects a record that passed these checks. PNG input now
answers supports("mdcv") from the linked libpng, and PNG output does
when that libpng also supports cICP; ICO does not report it. All of
this needs libPNG 1.6.46 or newer, which added the mDCV chunk, or 1.6.48
or newer if libpng was built without its fixed-point API. Builds against
an older libpng write the same files as before; the only difference is
that debug message when the output is given mdcv_* attributes.
PNG Third Edition carries the mastering display's primaries, white point
and luminance range in an mDCV chunk. OIIO drops it, so a PNG read and
rewrite loses the record and callers cannot author one.
Read mDCV into ten integer ImageSpec attributes, mdcv_red_x through
mdcv_min_luminance, in PNG wire units, and write them back when a
complete, valid record accompanies a cICP chunk. The omission reason is
shown when OPENIMAGEIO_DEBUG is set or in debug builds. Pixels and color
space identification are unchanged.
libpng added the mDCV chunk in 1.6.46 and fixed its floating-point mDCV
setter in 1.6.48, so a libpng built without the fixed-point API needs
that later release. A single OIIO_PNG_MDCV_SUPPORTED gate, defined
beside the existing OIIO_LIBPNG_VERSION macro, enforces both floors for
the reader, the writer and both supports() answers, so the code accepts
exactly the libpng versions the documentation names.
Document the attributes and those versions beside the existing libPNG
1.6.45 note for CICP, and the new "mdcv" query beside "cicp" in the
supports() lists.
The test covers exact read and write bytes, copy-through, each omission
reason including negative and oversized chromaticities and the luminance
range and ordering checks, the inclusive range limits, unsigned integer
attributes, the copy of an out-of-range input record, a record that
libpng itself rejects, supports("mdcv") on input and output, and the
PNG-encoded ICO read and write path. It reads the record back through
--info rather than --echo, which errors on an absent attribute, so the
test also runs against a libpng without mDCV support.
Assisted-by: OpenAI Codex (GPT-6 Astra, GPT-5.6 Sol)
Assisted-by: Claude Code / Claude Opus 5
Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
lgritz
left a comment
There was a problem hiding this comment.
Beyond my expertise, but I take your word that this is needed, and it probably can't break anything because it passes all the test.
|
Well, more of a "nice to have" than a "need", but it's data that would be nice to view and edit and, in an upcoming PR, approximately compute. Just to explain real quick: Anyway, the relationship between an OCIO View Transforms / Views and OCIO Displays is similar to the relationship between MDCV and an output device's capabilities, insofar as it's reasonable to let MDCV data survive color space transformations, since it represents historical provenance that we intend to carry forward... |
|
Now I'm not quite sure why my fingers typed "needed"... I think I meant more like "correct"? |
Signed-off-by: Larry Gritz <lg@larrygritz.com>
…eFoundation#5512) OpenImageIO currently drops PNG Third Edition mastering-display metadata during a read and rewrite. This preserves the ten wire values as integer ImageSpec attributes and writes mDCV only when the record is complete, valid, and accompanied by cICP. ## Breaking and changed behavior - PNG and PNG-encoded ICO input report ten `mdcv_*` attributes when supported by the linked libpng. - PNG and PNG-encoded ICO output write a valid complete record with cICP. - Invalid, incomplete, unsupported, or cICP-less records are omitted with a debug warning; the image write otherwise continues. - libpng older than 1.6.46 keeps its previous file output, except that supplied mDCV attributes now produce the debug warning. A build without libpng's fixed-point API requires 1.6.48. ## Motivation A read and rewrite currently loses the mastering-display record, and callers cannot author one through ImageSpec metadata. ## What this PR does - Reads and writes the ten wire-unit integer fields. - Validates completeness, chromaticity and luminance bounds, and luminance ordering. - Adds input/output capability queries with the same version gates. - Covers PNG and the PNG-encoded ICO path. ## What this PR deliberately does not do - Convert the integers to a new public structure. - Write mDCV without cICP. - Turn an omitted metadata record into a write failure. ## Testing The PNG test checks exact bytes, copy-through, all omission reasons, inclusive bounds, unsigned attributes, capability reporting, and ICO read/write paths. ## Validation - macOS arm64, AppleClang, Release, warnings as errors, libpng 1.6.58: focused 5/5 normal and debug; full CTest 220/220 normal and 220/220 debug. - Two mutation checks covering input capability reporting and luminance ordering were killed. - Documentation warnings match the base. - No libpng at the 1.6.46/1.6.48 boundary was available. The floating-point-only branch was not linked or run. - CI passed on my fork, including the Linux gcc, Windows, sanitizer and ABI jobs: https://github.com/zachlewis/OpenImageIO/actions/runs/36108523146 ## Documentation `stdmetadata.md` defines the ten attributes. `builtinplugins.md` documents the read/write conditions, capability query, and libpng floors. Assisted-by: OpenAI Codex (GPT-6 Astra, GPT-5.6 Sol) Assisted-by: Claude Code / Claude Opus 5 Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
…eFoundation#5512) OpenImageIO currently drops PNG Third Edition mastering-display metadata during a read and rewrite. This preserves the ten wire values as integer ImageSpec attributes and writes mDCV only when the record is complete, valid, and accompanied by cICP. ## Breaking and changed behavior - PNG and PNG-encoded ICO input report ten `mdcv_*` attributes when supported by the linked libpng. - PNG and PNG-encoded ICO output write a valid complete record with cICP. - Invalid, incomplete, unsupported, or cICP-less records are omitted with a debug warning; the image write otherwise continues. - libpng older than 1.6.46 keeps its previous file output, except that supplied mDCV attributes now produce the debug warning. A build without libpng's fixed-point API requires 1.6.48. ## Motivation A read and rewrite currently loses the mastering-display record, and callers cannot author one through ImageSpec metadata. ## What this PR does - Reads and writes the ten wire-unit integer fields. - Validates completeness, chromaticity and luminance bounds, and luminance ordering. - Adds input/output capability queries with the same version gates. - Covers PNG and the PNG-encoded ICO path. ## What this PR deliberately does not do - Convert the integers to a new public structure. - Write mDCV without cICP. - Turn an omitted metadata record into a write failure. ## Testing The PNG test checks exact bytes, copy-through, all omission reasons, inclusive bounds, unsigned attributes, capability reporting, and ICO read/write paths. ## Validation - macOS arm64, AppleClang, Release, warnings as errors, libpng 1.6.58: focused 5/5 normal and debug; full CTest 220/220 normal and 220/220 debug. - Two mutation checks covering input capability reporting and luminance ordering were killed. - Documentation warnings match the base. - No libpng at the 1.6.46/1.6.48 boundary was available. The floating-point-only branch was not linked or run. - CI passed on my fork, including the Linux gcc, Windows, sanitizer and ABI jobs: https://github.com/zachlewis/OpenImageIO/actions/runs/36108523146 ## Documentation `stdmetadata.md` defines the ten attributes. `builtinplugins.md` documents the read/write conditions, capability query, and libpng floors. Assisted-by: OpenAI Codex (GPT-6 Astra, GPT-5.6 Sol) Assisted-by: Claude Code / Claude Opus 5 Signed-off-by: Zach Lewis <zachcanbereached@gmail.com>
OpenImageIO currently drops PNG Third Edition mastering-display metadata during
a read and rewrite. This preserves the ten wire values as integer ImageSpec
attributes and writes mDCV only when the record is complete, valid, and
accompanied by cICP.
Breaking and changed behavior
mdcv_*attributes when supportedby the linked libpng.
debug warning; the image write otherwise continues.
mDCV attributes now produce the debug warning. A build without libpng's
fixed-point API requires 1.6.48.
Motivation
A read and rewrite currently loses the mastering-display record, and callers
cannot author one through ImageSpec metadata.
What this PR does
ordering.
What this PR deliberately does not do
Testing
The PNG test checks exact bytes, copy-through, all omission reasons, inclusive
bounds, unsigned attributes, capability reporting, and ICO read/write paths.
Validation
5/5 normal and debug; full CTest 220/220 normal and 220/220 debug.
ordering were killed.
floating-point-only branch was not linked or run.
jobs: https://github.com/zachlewis/OpenImageIO/actions/runs/36108523146
Documentation
stdmetadata.mddefines the ten attributes.builtinplugins.mddocuments theread/write conditions, capability query, and libpng floors.
Assisted-by: OpenAI Codex (GPT-6 Astra, GPT-5.6 Sol)
Assisted-by: Claude Code / Claude Opus 5