Skip to content

Commit

Permalink
parse supplemental codecs for AV1 with DV profile 10
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin committed May 7, 2024
1 parent 35b557b commit d801d8d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions packager/media/base/fourccs.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ enum FourCC : uint32_t {
FOURCC_dac3 = 0x64616333,
FOURCC_dac4 = 0x64616334,
FOURCC_dash = 0x64617368,
FOURCC_dav1 = 0x64617631,
FOURCC_db1p = 0x64623170,
FOURCC_db2g = 0x64623267,
FOURCC_db4g = 0x64623467,
Expand Down
10 changes: 10 additions & 0 deletions packager/media/formats/mp4/box_definitions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,16 @@ bool VideoSampleEntry::ReadWriteInternal(BoxBuffer* buffer) {
extra_codec_configs.push_back(std::move(dv_box));
}
}
const bool is_av1 = actual_format == FOURCC_av01;
if (is_av1) {
for (FourCC fourcc : {FOURCC_dvvC}) {
CodecConfiguration dv_box;
dv_box.box_type = fourcc;
RCHECK(buffer->TryReadWriteChild(&dv_box));
if (!dv_box.data.empty())
extra_codec_configs.push_back(std::move(dv_box));
}
}
} else {
for (CodecConfiguration& extra_codec_config : extra_codec_configs)
RCHECK(buffer->ReadWriteChild(&extra_codec_config));
Expand Down
25 changes: 25 additions & 0 deletions packager/media/formats/mp4/mp4_media_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ bool UpdateCodecStringForDolbyVision(
// See above.
*codec_string += ";" + dovi_config.GetCodecString(FOURCC_dvh1);
break;
case FOURCC_av01:
*codec_string += ";" + dovi_config.GetCodecString(FOURCC_dav1);
break;
default:
LOG(ERROR) << "Unsupported format with extra codec "
<< FourCCToString(actual_format);
Expand Down Expand Up @@ -215,6 +218,9 @@ bool UpdateDolbyVisionInfo(
// See above.
*dovi_supplemental_codec_string = dovi_config.GetCodecString(FOURCC_dvh1);
break;
case FOURCC_av01:
*dovi_supplemental_codec_string = dovi_config.GetCodecString(FOURCC_dav1);
break;
default:
LOG(ERROR) << "Unsupported format with extra codec "
<< FourCCToString(actual_format);
Expand Down Expand Up @@ -670,13 +676,32 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
}
// Generate the full codec string if the colr atom is present.
if (entry.colr.color_parameter_type != FOURCC_NULL) {
transfer_characteristics = entry.colr.transfer_characteristics;
codec_string = av1_config.GetCodecString(
entry.colr.color_primaries, entry.colr.transfer_characteristics,
entry.colr.matrix_coefficients,
entry.colr.video_full_range_flag);
} else {
codec_string = av1_config.GetCodecString();
}

if (!entry.extra_codec_configs.empty()) {
// |extra_codec_configs| is present only for Dolby Vision.
if (use_dovi_supplemental) {
if (!UpdateDolbyVisionInfo(
actual_format, entry.extra_codec_configs,
transfer_characteristics, &codec_string,
&dovi_supplemental_codec_string,
&dovi_compatible_brand)) {
return false;
}
} else {
if (!UpdateCodecStringForDolbyVision(
actual_format, entry.extra_codec_configs, &codec_string)) {
return false;
}
}
}
break;
}
case FOURCC_avc1:
Expand Down

0 comments on commit d801d8d

Please sign in to comment.