AOMediaCodec / av1-avif

AV1 Image File Format Specification - ISO-BMFF/HEIF derivative
https://aomediacodec.github.io/av1-avif/
BSD 2-Clause "Simplified" License
463 stars 40 forks source link

Default matrixCoefficients? (handling "unspecified") #83

Closed joedrago closed 4 years ago

joedrago commented 4 years ago

Hi all --

In having some discussions with @wantehchang, we were curious if there was an official fallback value for the matrixCoefficients enum, when it is unspecified. Should we fallback to BT709 or BT601?

The current libavif falls back to BT709 coefficients (1) if it is unspecified, but I believe traditional video paths (ffmpeg) tend to fallback to BT601 (6). Is there anywhere in the HEIF or AVIF standard we can use that'd guide us here?

cconcolato commented 4 years ago

MIAF Section 7.3.6.4 currently says:

If a coded image has no associated colour property, the default property is defined as having colour_type equal to 'nclx' with properties as follows: – For YCbCr encoding, sYCC should be assumed as indicated by colour_primaries equal to 1, transfer_characteristics equal to 13, matrix_coefficients equal to 1, and full_range_flag equal to 1. – For RGB encoding, sRGB should be assumed as indicated by colour_primaries equal to 1, transfer_characteristics equal to 13, matrix_coefficients equal to 0, and full_range_flag equal to 1.

Following a corrigendum on CICP (sYCC actually uses matrix coefficient = 5), the current consensus in MPEG MIAF is to keep value 1 for YCbCr and remove mention of sYCC. So the MIAF updated text would be:

If a coded image has no associated colour property, the default property is defined as having colour_type equal to 'nclx' with properties as follows:

– For YCbCr encoding, the signal should be assumed to have a colour representation with colour_primaries equal to 1, transfer_characteristics equal to 13, matrix_coefficients equal to 1, and full_range_flag equal to 1.

Editor’s NOTE: The above does not match the values of sYCC as defined in CICP. Discussion are encouraged here http://mpegx.int-evry.fr/software/MPEG/Systems/ApplicationFormat/MIAF/issues/2

– For RGB encoding, the signal should be assumed to have a colour representation with colour_primaries equal to 1, transfer_characteristics equal to 13, matrix_coefficients equal to 0, and full_range_flag equal to 1. If a coded image is not represented using one of the above default configurations, it shall have an explicitly declared colour space via association with a property of this type.

Editor’s NOTE: The current specification requires scanning the media data to determine which default applies (sRGB or not). Perhaps an indication at the container level could be needed. Discussion is encouraged here https://github.com/MPEGGroup/MIAF/issues/2.

If a derived image has no explicitly associated colour information, then the default colour information is defined by the derivation. In particular, when the derivation is the identity derivation, the default colour information of the derived image is the one of the input image.

NOTE The colour information property takes precedence over any colour information in the image bitstream, i.e. if the property is present, colour information in the bitstream is ignored.

joedrago commented 4 years ago

This is exactly what I was looking for. Thank you!

baumanj commented 3 years ago

For any future readers here, it's worth noting that the fallback matrix_coefficients for YCbCr encoding is updated in MIAF DAMD2 from 1 (BT.709) → 6 (BT.601) per https://github.com/AOMediaCodec/av1-avif/issues/77#issuecomment-676526097. See also https://github.com/AOMediaCodec/libavif/wiki/CICP#unspecified.