Skip to content

Commit 984b8ae

Browse files
committed
Write the MA1B brand correctly
A partial fix for #2514.
1 parent c7c4019 commit 984b8ae

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/write.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3134,6 +3134,7 @@ avifResult avifEncoderFinish(avifEncoder * encoder, avifRWData * output)
31343134
// -----------------------------------------------------------------------
31353135
// Harvest configuration properties from sequence headers
31363136

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

@@ -3239,10 +3245,11 @@ avifResult avifEncoderFinish(avifEncoder * encoder, avifRWData * output)
32393245
} //
32403246
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "mif1", 4)); // ... compatible_brands[]
32413247
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "miaf", 4)); // ... compatible_brands[]
3248+
if (isMA1B) { //
3249+
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1B", 4)); // ... compatible_brands[]
3250+
} //
32423251
if ((imageMetadata->depth == 8) || (imageMetadata->depth == 10)) { //
3243-
if (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV420) { //
3244-
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1B", 4)); // ... compatible_brands[]
3245-
} else if (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV444) { //
3252+
if (imageMetadata->yuvFormat == AVIF_PIXEL_FORMAT_YUV444) { //
32463253
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1A", 4)); // ... compatible_brands[]
32473254
}
32483255
}

0 commit comments

Comments
 (0)