-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write the MA1B brand correctly #2515
Open
wantehchang
wants to merge
2
commits into
AOMediaCodec:main
Choose a base branch
from
wantehchang:write-MA1B-brand-correctly
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) { | ||
|
@@ -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; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -3226,24 +3232,25 @@ avifResult avifEncoderFinish(avifEncoder * encoder, avifRWData * output) | |
|
||
avifBoxMarker ftyp; | ||
AVIF_CHECKRES(avifRWStreamWriteBox(&s, "ftyp", AVIF_BOX_SIZE_TBD, &ftyp)); | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, majorBrand, 4)); // unsigned int(32) major_brand; | ||
AVIF_CHECKRES(avifRWStreamWriteU32(&s, minorVersion)); // unsigned int(32) minor_version; | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "avif", 4)); // unsigned int(32) compatible_brands[]; | ||
if (useAvioBrand) { // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "avio", 4)); // ... compatible_brands[] | ||
} // | ||
if (isSequence) { // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "avis", 4)); // ... compatible_brands[] | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "msf1", 4)); // ... compatible_brands[] | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "iso8", 4)); // ... compatible_brands[] | ||
} // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "mif1", 4)); // ... compatible_brands[] | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "miaf", 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) { // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1A", 4)); // ... compatible_brands[] | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, majorBrand, 4)); // unsigned int(32) major_brand; | ||
AVIF_CHECKRES(avifRWStreamWriteU32(&s, minorVersion)); // unsigned int(32) minor_version; | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "avif", 4)); // unsigned int(32) compatible_brands[]; | ||
if (useAvioBrand) { // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "avio", 4)); // ... compatible_brands[] | ||
} // | ||
if (isSequence) { // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "avis", 4)); // ... compatible_brands[] | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "msf1", 4)); // ... compatible_brands[] | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "iso8", 4)); // ... compatible_brands[] | ||
} // | ||
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_YUV444) { // | ||
AVIF_CHECKRES(avifRWStreamWriteChars(&s, "MA1A", 4)); // ... compatible_brands[] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the constraints listed in https://aomediacodec.github.io/av1-avif/v1.1.0.html#advanced-profile always true here? |
||
} | ||
} | ||
#if defined(AVIF_ENABLE_EXPERIMENTAL_GAIN_MAP) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yannis: I am not that familiar with this code. It is important that this for loop (which starts at line 3138) is executed for both image items and image sequences, and that we enter the
if (item->encodeOutput->samples.count > 0)
block (which starts at line 3140) at least once. Otherwise we will incorrectly report thatisMA1B
is true (the initial value). Please check this. Thanks!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is my understanding:
avifEncoder
only if the corresponding item is present too, likely with the first frame of the sequence being used as the image item data.Assuming this is correct, the for loop and the
MA1B
check look good.