AOMediaCodec / libavif

libavif - Library for encoding and decoding .avif files
Other
1.58k stars 207 forks source link

CICP color property takes precedence over any color information in the image bitstream. #875

Open ledyba-z opened 2 years ago

ledyba-z commented 2 years ago

Hi!

I'm currently working on making cavif to conform to the latest standards.

I found these statements in ISO - ISO/IEC 23000-22:2019/Amd 2:2021:

All image items, both coded and derived, should be associated with at least one colour information property. The handling of colour information by the system (i.e. colour management) is outside the scope of this document; a renderer takes this information into account when rendering the image(s). If a coded image has no associated CICP colour property, the default property is defined as having colour_type equal to 'nclx' with properties as follows: — colour_primaries equal to 1, — transfer_characteristics equal to 13, — matrix_coefficients equal to 5 or 6 (which are functionally identical), and — full_range_flag equal to 1.

NOTE 1 Any colour information in the bitstream is ignored by the MIAF reader and MIAF renderer processing models. The colour information property whether explicit or default, takes precedence over any colour information in the image bitstream.

If I understand correctly, it says "Do not use color information in OBU Sequence Header any more. Use default values if nclx absent" in AVIF context.

However, it looks libavif tends to use color information from OBU sequence header:

https://github.com/AOMediaCodec/libavif/blob/7a6d13be831da40859c6b61fb513b7a7a654a58b/src/read.c#L3633-L3665

Is it correct?

novomesk commented 2 years ago

This question is related to the discussion in https://github.com/AOMediaCodec/av1-avif/issues/195

It think implementation in libavif give good backward compatibility with existing images, when it was not allowed to have both ICC and NCLX at the same time.

If the authors of the standard really wanted to always ignore info in bitstream, I'd appreciate they confirm/deny that so we remove discrepancy between implementations.