CICP Refactor (breaking change!)
* Remove most references to "NCLX", as it is mostly an implementation detail, and the values are really from MPEG-CICP
* Eliminate avifProfileFormat: having an ICC profile is not mutually exclusive with signaling CICP
* CICP is now always available in an avifImage, set to unspecified by default
* Added --cicp as an alias for --nclx (semi-deprecated)
* Setting CICP via avifenc no longer overrides ICC profiles, they co-exist
* Simplified avifenc argument parsing / warnings logic
* avifenc/avifdec/avifdump now all display CICP when dumping AVIF information
* nclx colr box contents are guaranteed to override AV1 bitstream CICP (as MIAF standard specifies)
* Added comments explaining various decisions and citing standards
* Removed ICC inspection code regarding chroma-derived mtxCoeffs; this was overdesigned. Now just honor the assoc. colorPrimaries enum
* Reworked all examples in the README to reflect the new state of things, and clean out some cruft
diff --git a/src/write.c b/src/write.c
index 205df62..37f9a9d 100644
--- a/src/write.c
+++ b/src/write.c
@@ -397,22 +397,22 @@
} else {
// Color specific properties
- if (item->image->profileFormat == AVIF_PROFILE_FORMAT_NCLX) {
- avifBoxMarker colr = avifRWStreamWriteBox(&s, "colr", -1, 0);
- avifRWStreamWriteChars(&s, "nclx", 4); // unsigned int(32) colour_type;
- avifRWStreamWriteU16(&s, (uint16_t)item->image->nclx.colourPrimaries); // unsigned int(16) colour_primaries;
- avifRWStreamWriteU16(&s, (uint16_t)item->image->nclx.transferCharacteristics); // unsigned int(16) transfer_characteristics;
- avifRWStreamWriteU16(&s, (uint16_t)item->image->nclx.matrixCoefficients); // unsigned int(16) matrix_coefficients;
- avifRWStreamWriteU8(&s, item->image->nclx.range & 0x80); // unsigned int(1) full_range_flag;
- // unsigned int(7) reserved = 0;
- avifRWStreamFinishBox(&s, colr);
- ipmaPush(&item->ipma, ++itemPropertyIndex, AVIF_FALSE);
- } else if ((item->image->profileFormat == AVIF_PROFILE_FORMAT_ICC) && item->image->icc.data && (item->image->icc.size > 0)) {
+ if (item->image->icc.data && (item->image->icc.size > 0)) {
avifBoxMarker colr = avifRWStreamWriteBox(&s, "colr", -1, 0);
avifRWStreamWriteChars(&s, "prof", 4); // unsigned int(32) colour_type;
avifRWStreamWrite(&s, item->image->icc.data, item->image->icc.size);
avifRWStreamFinishBox(&s, colr);
ipmaPush(&item->ipma, ++itemPropertyIndex, AVIF_FALSE);
+ } else {
+ avifBoxMarker colr = avifRWStreamWriteBox(&s, "colr", -1, 0);
+ avifRWStreamWriteChars(&s, "nclx", 4); // unsigned int(32) colour_type;
+ avifRWStreamWriteU16(&s, (uint16_t)item->image->colorPrimaries); // unsigned int(16) colour_primaries;
+ avifRWStreamWriteU16(&s, (uint16_t)item->image->transferCharacteristics); // unsigned int(16) transfer_characteristics;
+ avifRWStreamWriteU16(&s, (uint16_t)item->image->matrixCoefficients); // unsigned int(16) matrix_coefficients;
+ avifRWStreamWriteU8(&s, item->image->yuvRange & 0x80); // unsigned int(1) full_range_flag;
+ // unsigned int(7) reserved = 0;
+ avifRWStreamFinishBox(&s, colr);
+ ipmaPush(&item->ipma, ++itemPropertyIndex, AVIF_FALSE);
}
// Write (Optional) Transformations