Skip to content

Commit

Permalink
Write the MA1B brand correctly
Browse files Browse the repository at this point in the history
A partial fix for #2514.
  • Loading branch information
wantehchang committed Dec 2, 2024
1 parent c7c4019 commit 984b8ae
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/write.c
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,7 @@ avifResult avifEncoderFinish(avifEncoder * encoder, avifRWData * output)
// -----------------------------------------------------------------------
// Harvest configuration properties from sequence headers

avifBool isMA1B = AVIF_TRUE;
for (uint32_t itemIndex = 0; itemIndex < encoder->data->items.count; ++itemIndex) {
avifEncoderItem * item = &encoder->data->items.item[itemIndex];
if (item->encodeOutput->samples.count > 0) {
Expand All @@ -3142,6 +3143,11 @@ avifResult avifEncoderFinish(avifEncoder * encoder, avifRWData * output)
AVIF_CHECKERR(avifSequenceHeaderParse(&sequenceHeader, (const avifROData *)&firstSample->data, codecType),
avifGetErrorForItemCategory(item->itemCategory));
item->av1C = sequenceHeader.av1C;
// The MA1B brand: The AV1 profile shall be the Main Profile and
// the level shall be 5.1 or lower.
if (item->av1C.seqProfile != 0 || item->av1C.seqLevelIdx0 > 13) {
isMA1B = AVIF_FALSE;
}
}
}

Expand Down Expand Up @@ -3239,10 +3245,11 @@ avifResult avifEncoderFinish(avifEncoder * encoder, avifRWData * output)
} //
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "mif1", 4)); // ... compatible_brands[]
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "miaf", 4)); // ... compatible_brands[]
if (isMA1B) { //
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1B", 4)); // ... compatible_brands[]
} //
if ((imageMetadata->depth == 8) || (imageMetadata->depth == 10)) { //
if (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV420) { //
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1B", 4)); // ... compatible_brands[]
} else if (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV444) { //
if (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV444) { //
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1A", 4)); // ... compatible_brands[]
}
}
Expand Down

0 comments on commit 984b8ae

Please sign in to comment.