Implementation of section 2.3.3 of AV1 Codec ISO Media File Format Binding specification v1.2.0. See https://aomediacodec.github.io/av1-isobmff/v1.2.0.html#av1codecconfigurationbox-syntax.
| 3870 | // Implementation of section 2.3.3 of AV1 Codec ISO Media File Format Binding specification v1.2.0. |
| 3871 | // See https://aomediacodec.github.io/av1-isobmff/v1.2.0.html#av1codecconfigurationbox-syntax. |
| 3872 | static avifResult writeCodecConfig(avifRWStream * s, const avifCodecConfigurationBox * cfg) |
| 3873 | { |
| 3874 | const size_t av1COffset = s->offset; |
| 3875 | |
| 3876 | AVIF_CHECKRES(avifRWStreamWriteBits(s, 1, /*bitCount=*/1)); // unsigned int (1) marker = 1; |
| 3877 | AVIF_CHECKRES(avifRWStreamWriteBits(s, 1, /*bitCount=*/7)); // unsigned int (7) version = 1; |
| 3878 | |
| 3879 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->seqProfile, /*bitCount=*/3)); // unsigned int (3) seq_profile; |
| 3880 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->seqLevelIdx0, /*bitCount=*/5)); // unsigned int (5) seq_level_idx_0; |
| 3881 | |
| 3882 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->seqTier0, /*bitCount=*/1)); // unsigned int (1) seq_tier_0; |
| 3883 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->highBitdepth, /*bitCount=*/1)); // unsigned int (1) high_bitdepth; |
| 3884 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->twelveBit, /*bitCount=*/1)); // unsigned int (1) twelve_bit; |
| 3885 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->monochrome, /*bitCount=*/1)); // unsigned int (1) monochrome; |
| 3886 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->chromaSubsamplingX, /*bitCount=*/1)); // unsigned int (1) chroma_subsampling_x; |
| 3887 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->chromaSubsamplingY, /*bitCount=*/1)); // unsigned int (1) chroma_subsampling_y; |
| 3888 | AVIF_CHECKRES(avifRWStreamWriteBits(s, cfg->chromaSamplePosition, /*bitCount=*/2)); // unsigned int (2) chroma_sample_position; |
| 3889 | |
| 3890 | AVIF_CHECKRES(avifRWStreamWriteBits(s, 0, /*bitCount=*/3)); // unsigned int (3) reserved = 0; |
| 3891 | AVIF_CHECKRES(avifRWStreamWriteBits(s, 0, /*bitCount=*/1)); // unsigned int (1) initial_presentation_delay_present; |
| 3892 | AVIF_CHECKRES(avifRWStreamWriteBits(s, 0, /*bitCount=*/4)); // unsigned int (4) reserved = 0; |
| 3893 | |
| 3894 | // According to section 2.2.1 of AV1 Image File Format specification v1.1.0, |
| 3895 | // there is no need to write any OBU here. |
| 3896 | // See https://aomediacodec.github.io/av1-avif/v1.1.0.html#av1-configuration-item-property. |
| 3897 | // unsigned int (8) configOBUs[]; |
| 3898 | |
| 3899 | AVIF_ASSERT_OR_RETURN(s->offset - av1COffset == 4); // Make sure writeCodecConfig() writes exactly 4 bytes. |
| 3900 | return AVIF_RESULT_OK; |
| 3901 | } |
| 3902 | |
| 3903 | static avifResult writeConfigBox(avifRWStream * s, const avifCodecConfigurationBox * cfg, const char * configPropName) |
| 3904 | { |
no test coverage detected