AOMediaCodec / av1-isobmff

Official specification of the AOM group for the carriage of AV1 in ISOBMFF
https://AOMediaCodec.github.io/av1-isobmff
64 stars 16 forks source link

Use of colr box is not clear when color_description_present_flag is 0 #126

Closed cconcolato closed 1 year ago

cconcolato commented 2 years ago

The current spec says:

The sample entry SHOULD contain a colr box with a colour_type set to nclx. If present, the values of colour_primaries, transfer_characteristics, and matrix_coefficients SHALL match the values given in the Sequence Header OBU (in the configOBUs field or in the associated samples) if the color_description_present_flag is set to 1. Similarly, the full_range_flag in the colr box shall match the color_range flag in the Sequence Header OBU. When configOBUs does not contain a Sequence Header OBU, this box with colour_type set to nclx SHALL be present.

It's unclear what values should be used when color_description_present_flag is 0. Should the nclx box declare values 2/2/2/0? Is it allowed to declare values other than 2/2/2, like 1/13/6, to override at the container-level the unknown color space from the elementary stream? That seems in line with the spirit of ISOBMFF which says:

If colour information is supplied in both this box, and also in the video bitstream, this box takes precedence, and over-rides the information in the bitstream.

What about the color range? Can it be overriden?

cconcolato commented 2 years ago

Yes, color_range is always defined in an AV1 bitstream, either coded or with a default value of 1. The colr box definition is:

class ColourInformationBox extends Box('colr'){
    unsigned int(32) colour_type;
    if (colour_type == 'nclx') /* on-screen colours */
    {
        unsigned int(16) colour_primaries;
        unsigned int(16) transfer_characteristics;
        unsigned int(16) matrix_coefficients;
        unsigned int(1) full_range_flag;
        unsigned int(7) reserved = 0;
    }
    else if (colour_type == 'rICC')
    {
        ICC_profile; // restricted ICC profile
    }
    else if (colour_type == 'prof')
    {
        ICC_profile; // unrestricted ICC profile
    }
}

So yes, there is a value for full_range_flag. I don't think it makes sense for it to have a different value than the one in the bitstream.

cconcolato commented 2 years ago

The group discussed this issue and proposes to add a note indicating that it is fine not to have color information in the bitstream but in that case the colr box shall be present and should not have values 2/2/2

wantehchang commented 2 years ago

I found a technical complication. The color_config() part of the AV1 sequence header OBU is defined as follows:

color_config( ) {                                       Type
...
    color_description_present_flag                      f(1)
    if ( color_description_present_flag ) {
        color_primaries                                 f(8)
        transfer_characteristics                        f(8)
        matrix_coefficients                             f(8)
    } else {
        color_primaries = CP_UNSPECIFIED
        transfer_characteristics = TC_UNSPECIFIED
        matrix_coefficients = MC_UNSPECIFIED
    }

Note that CP_UNSPECIFIED, TC_UNSPECIFIED, and MC_UNSPECIFIED are all equal to 2.

The subject of this issue is to deal with the color_description_present_flag == 0 case. One can see that the color_description_present_flag == 1 && color_primaries/transfer_characteristics/matrix_coefficients == 2/2/2 case is essentially the same as the color_description_present_flag == 0 case. Therefore, the spec probably should also address the case when color_description_present_flag is equal to 1 but color_primaries, transfer_characteristics, or matrix_coefficients is equal to 2 (unspecified).

cconcolato commented 1 year ago

FYI https://github.com/MPEGGroup/CMAF/issues/43