This function is used in two codepaths: writing color *item* properties writing color *track* properties Item properties must have property associations with them and can be deduplicated (by reusing these associations), so this function leverages the ipma and dedup arguments to do this. Track properties, however, are implicitly associated by the track in which they are contained, so there is no
| 651 | // property. In this case, the ipma and dedup properties should/will be set to NULL, and this |
| 652 | // function will avoid using them. |
| 653 | static avifResult avifEncoderWriteColorProperties(avifRWStream * outputStream, |
| 654 | const avifImage * imageMetadata, |
| 655 | avifItemPropertyAssociationArray * associations, |
| 656 | avifItemPropertyDedup * dedup) |
| 657 | { |
| 658 | // outputStream is the final bitstream that will be output by the libavif encoder API. |
| 659 | // dedupStream is either equal to outputStream or to &dedup->s which is a temporary stream used |
| 660 | // to store parts of the final bitstream; these parts may be discarded if they are a duplicate |
| 661 | // of an already stored property. |
| 662 | avifRWStream * dedupStream = outputStream; |
| 663 | if (dedup) { |
| 664 | AVIF_ASSERT_OR_RETURN(associations); |
| 665 | |
| 666 | // Use the dedup's temporary stream for box writes. |
| 667 | dedupStream = &dedup->s; |
| 668 | } |
| 669 | |
| 670 | if (imageMetadata->icc.size > 0) { |
| 671 | if (dedup) { |
| 672 | avifItemPropertyDedupStart(dedup); |
| 673 | } |
| 674 | avifBoxMarker colr; |
| 675 | AVIF_CHECKRES(avifRWStreamWriteBox(dedupStream, "colr", AVIF_BOX_SIZE_TBD, &colr)); |
| 676 | AVIF_CHECKRES(avifRWStreamWriteChars(dedupStream, "prof", 4)); // unsigned int(32) colour_type; |
| 677 | AVIF_CHECKRES(avifRWStreamWrite(dedupStream, imageMetadata->icc.data, imageMetadata->icc.size)); |
| 678 | AVIF_CHECKRES(avifRWStreamFinishBox(dedupStream, colr)); |
| 679 | if (dedup) { |
| 680 | AVIF_CHECKRES(avifItemPropertyDedupFinish(dedup, outputStream, associations, /*essential=*/AVIF_FALSE)); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | // HEIF 6.5.5.1, from Amendment 3 allows multiple colr boxes: "at most one for a given value of colour type" |
| 685 | // Therefore, *always* writing an nclx box, even if a prof box was already written above. |
| 686 | AVIF_CHECKRES(avifEncoderWriteNclxProperty(dedupStream, outputStream, imageMetadata, associations, dedup)); |
| 687 | |
| 688 | AVIF_CHECKRES(avifEncoderWritePaspProperty(dedupStream, outputStream, imageMetadata, associations, dedup)); |
| 689 | |
| 690 | return AVIF_RESULT_OK; |
| 691 | } |
| 692 | |
| 693 | static avifResult avifEncoderWriteContentLightLevelInformation(avifRWStream * outputStream, |
| 694 | const avifContentLightLevelInformationBox * clli) |
no test coverage detected