Skip to content

Commit

Permalink
Implement IAMF v1.0.0 errata changes
Browse files Browse the repository at this point in the history
Updates the IAMF mp4 parsing implementation to support v1.0.0-errata.
Streams configured with the original v1.0.0 spec are no longer
supported.

Changes are pulled from Chromium. Original CL descriptions follow:

Update IAMF mp4 parsing implementation

Updates the IAMF parsing implemenation to parse the IA Configuration Box
defined in the IAMF v1.0.0-errata specification.

https://aomediacodec.github.io/iamf/v1.0.0-errata.html#iaconfigurationbox-section

Bug: b/340618404
Change-Id: I1467e60928ac28e0ead4a9e0f3857b6c5540c7e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5550540
Reviewed-by: Mark Foltz <[email protected]>
Commit-Queue: Austin Osagie <[email protected]>
Reviewed-by: Dale Curtis <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1304144}

Fix iacb atom parsing error

Fixes an error in a previous change that parses the iamf atom instead of
the iacb atom. Now, the iacb atom is properly read.

Bug: b/340618404
Change-Id: I61d8c8c2758c9181b40ff6e99da24c790b202687
  • Loading branch information
osagie98 committed Jun 13, 2024
1 parent 06d7f26 commit 7e91a6f
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
30 changes: 18 additions & 12 deletions third_party/chromium/media/formats/mp4/box_definitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1456,15 +1456,21 @@ IamfSpecificBox::IamfSpecificBox(const IamfSpecificBox& other) = default;
IamfSpecificBox::~IamfSpecificBox() = default;

FourCC IamfSpecificBox::BoxType() const {
return FOURCC_IAMF;
return FOURCC_IACB;
}

bool IamfSpecificBox::Parse(BoxReader* reader) {
const int obu_bitstream_size = reader->box_size() - reader->pos();
uint8_t configuration_version;
RCHECK(reader->Read1(&configuration_version));
RCHECK(configuration_version == 0x01);

uint32_t config_obus_size;
RCHECK(ReadLeb128Value(reader, &config_obus_size));

const uint8_t* buf = reader->buffer() + reader->pos();
ia_descriptors.assign(buf, buf + obu_bitstream_size);
ia_descriptors.assign(buf, buf + config_obus_size);

RCHECK(reader->SkipBytes(obu_bitstream_size));
RCHECK(reader->SkipBytes(config_obus_size));

BufferReader config_reader(ia_descriptors.data(), ia_descriptors.size());

Expand Down Expand Up @@ -1582,14 +1588,6 @@ bool AudioSampleEntry::Parse(BoxReader* reader) {
// Convert from 16.16 fixed point to integer
samplerate >>= 16;

#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
if (format == FOURCC_IAMF) {
RCHECK_MEDIA_LOGGED(iamf.Parse(reader), reader->media_log(),
"Failure parsing IamfSpecificBox (iamf)");
return true;
}
#endif // BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)

RCHECK(reader->ScanChildren());
if (format == FOURCC_ENCA) {
// Continue scanning until a recognized protection scheme is found, or until
Expand All @@ -1612,6 +1610,14 @@ bool AudioSampleEntry::Parse(BoxReader* reader) {
"OpusSpecificBox STREAMINFO channel count");
}

#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
if (format == FOURCC_IAMF) {
RCHECK_MEDIA_LOGGED(reader->ReadChild(&iacb), reader->media_log(),
"Failure parsing IamfSpecificBox (iacb)");
return true;
}
#endif // BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)

// Read the FLACSpecificBox, even if CENC is signalled.
if (format == FOURCC_FLAC ||
(format == FOURCC_ENCA && sinf.format.format == FOURCC_FLAC)) {
Expand Down
2 changes: 1 addition & 1 deletion third_party/chromium/media/formats/mp4/box_definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ struct MEDIA_EXPORT AudioSampleEntry : Box {
FlacSpecificBox dfla;
OpusSpecificBox dops;
#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
IamfSpecificBox iamf;
IamfSpecificBox iacb;
#endif // BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
};

Expand Down
1 change: 1 addition & 0 deletions third_party/chromium/media/formats/mp4/fourccs.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ enum FourCC {
FOURCC_HVCC = 0x68766343,
#endif
#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
FOURCC_IACB = 0x69616362,
FOURCC_IAMF = 0x69616d66,
#endif // BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
FOURCC_ID32 = 0x49443332,
Expand Down
16 changes: 8 additions & 8 deletions third_party/chromium/media/formats/mp4/mp4_stream_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ bool MP4StreamParser::ParseMoov(BoxReader* reader) {
}

codec = AudioCodec::kIAMF;
profile = entry.iamf.profile == 0 ? AudioCodecProfile::kIAMF_SIMPLE
profile = entry.iacb.profile == 0 ? AudioCodecProfile::kIAMF_SIMPLE
: AudioCodecProfile::kIAMF_BASE;
// The correct values for the channel layout and sample rate can
// be parsed from the descriptor bitstream prepended to each sample.
Expand Down Expand Up @@ -755,18 +755,18 @@ bool MP4StreamParser::PrepareAACBuffer(

#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
bool MP4StreamParser::PrependIADescriptors(
const IamfSpecificBox& iamf_box,
const IamfSpecificBox& iacb,
std::vector<uint8_t>* frame_buf,
std::vector<SubsampleEntry>* subsamples) const {
// Prepend the IA Descriptors to every IA Sample.
frame_buf->insert(frame_buf->begin(), iamf_box.ia_descriptors.begin(),
iamf_box.ia_descriptors.end());
frame_buf->insert(frame_buf->begin(), iacb.ia_descriptors.begin(),
iacb.ia_descriptors.end());
size_t descriptors_size = iacb.ia_descriptors.size();
if (subsamples->empty()) {
subsamples->push_back(
SubsampleEntry(iamf_box.ia_descriptors.size(),
frame_buf->size() - iamf_box.ia_descriptors.size()));
SubsampleEntry(descriptors_size, frame_buf->size() - descriptors_size));
} else {
(*subsamples)[0].clear_bytes += iamf_box.ia_descriptors.size();
(*subsamples)[0].clear_bytes += descriptors_size;
}

return true;
Expand Down Expand Up @@ -939,7 +939,7 @@ ParseResult MP4StreamParser::EnqueueSample(BufferQueueMap* buffers) {
} else {
#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
if (runs_->audio_description().format == FOURCC_IAMF) {
if (!PrependIADescriptors(runs_->audio_description().iamf, &frame_buf,
if (!PrependIADescriptors(runs_->audio_description().iacb, &frame_buf,
&subsamples)) {
MEDIA_LOG(ERROR, media_log_)
<< "Failed to prepare IA sample for decode";
Expand Down
2 changes: 1 addition & 1 deletion third_party/chromium/media/formats/mp4/mp4_stream_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MEDIA_EXPORT MP4StreamParser : public StreamParser {
std::vector<SubsampleEntry>* subsamples) const;
#endif
#if BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
bool PrependIADescriptors(const IamfSpecificBox& iamf_box,
bool PrependIADescriptors(const IamfSpecificBox& iacb,
std::vector<uint8_t>* frame_buf,
std::vector<SubsampleEntry>* subsamples) const;
#endif // BUILDFLAG(ENABLE_PLATFORM_IAMF_AUDIO)
Expand Down

0 comments on commit 7e91a6f

Please sign in to comment.