Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmin committed May 7, 2024
1 parent b2fa0ef commit f645e4f
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 44 deletions.
8 changes: 6 additions & 2 deletions packager/app/test/packager_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,9 @@ def testDolbyVisionProfile8UsingSupplementalCodecs(self):
streams = [
self._GetStream('video', test_file='sparks_dovi_8.mp4')
]
flags = self._GetFlags(output_dash=True, output_hls=True, use_dovi_supplemental_codecs=True)
flags = self._GetFlags(output_dash=True,
output_hls=True,
use_dovi_supplemental_codecs=True)

self.assertPackageSuccess(streams, flags)
self._CheckTestResults('dolby-vision-profile-8-supplemental-codecs')
Expand All @@ -1473,7 +1475,9 @@ def testDolbyVisionProfile10UsingSupplementalCodecs(self):
streams = [
self._GetStream('video', test_file='sparks_dovi_10.mp4')
]
flags = self._GetFlags(output_dash=True, output_hls=True, use_dovi_supplemental_codecs=True)
flags = self._GetFlags(output_dash=True,
output_hls=True,
use_dovi_supplemental_codecs=True)

self.assertPackageSuccess(streams, flags)
self._CheckTestResults('dolby-vision-profile-10-supplemental-codecs')
Expand Down
4 changes: 2 additions & 2 deletions packager/hls/base/master_playlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ void BuildStreamInfTag(const MediaPlaylist& playlist,
variant.text_codecs.end());
tag.AddQuotedString("CODECS", absl::StrJoin(all_codecs, ","));

if (playlist.supplemental_codec() != ""
&& playlist.compatible_brand() != media::FOURCC_NULL) {
if (playlist.supplemental_codec() != "" &&
playlist.compatible_brand() != media::FOURCC_NULL) {
std::vector<std::string> supplemental_codecs;
supplemental_codecs.push_back(playlist.supplemental_codec());
supplemental_codecs.push_back(FourCCToString(playlist.compatible_brand()));
Expand Down
11 changes: 6 additions & 5 deletions packager/hls/base/media_playlist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ bool MediaPlaylist::SetMediaInfo(const MediaInfo& media_info) {
if (media_info.has_video_info()) {
stream_type_ = MediaPlaylistStreamType::kVideo;
codec_ = AdjustVideoCodec(media_info.video_info().codec());
if (media_info.video_info().has_supplemental_codec()
&& media_info.video_info().has_compatible_brand()) {
supplemental_codec_ = AdjustVideoCodec(
media_info.video_info().supplemental_codec());
if (media_info.video_info().has_supplemental_codec() &&
media_info.video_info().has_compatible_brand()) {
supplemental_codec_ =
AdjustVideoCodec(media_info.video_info().supplemental_codec());
compatible_brand_ = static_cast<media::FourCC>(
media_info.video_info().compatible_brand());
}
Expand Down Expand Up @@ -589,7 +589,8 @@ std::string MediaPlaylist::GetVideoRange() const {
// Dolby Vision profile 8.4 may have a transfer_characteristics 14, the
// actual value refers to preferred_transfer_characteristic value in SEI
// message, using compatible brand as a workaround
if (!supplemental_codec_.empty() && compatible_brand_ == media::FOURCC_db4g)
if (!supplemental_codec_.empty() &&
compatible_brand_ == media::FOURCC_db4g)
return "HLG";
else
return "SDR";
Expand Down
6 changes: 3 additions & 3 deletions packager/media/codecs/dovi_decoder_configuration_record.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ bool DOVIDecoderConfigurationRecord::Parse(const std::vector<uint8_t>& data) {
RCHECK(reader.ReadBits(8, &major_version) && major_version == 1 &&
reader.ReadBits(8, &minor_version) && minor_version == 0 &&
reader.ReadBits(7, &profile_) && reader.ReadBits(6, &level_) &&
reader.SkipBits(3) && reader.ReadBits(4, &bl_signal_compatibility_id_));
reader.SkipBits(3) &&
reader.ReadBits(4, &bl_signal_compatibility_id_));
return true;
}

Expand All @@ -47,8 +48,7 @@ FourCC DOVIDecoderConfigurationRecord::GetDoViCompatibleBrand(
case 4:
if (transfer_characteristics == 14) {
return FOURCC_db4g;
}
else if (transfer_characteristics == 18) {
} else if (transfer_characteristics == 18) {
return FOURCC_db4h;
}
default:
Expand Down
3 changes: 2 additions & 1 deletion packager/media/codecs/dovi_decoder_configuration_record.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class DOVIDecoderConfigurationRecord {
/// DASH and HLS manifests.
std::string GetCodecString(FourCC codec_fourcc) const;

/// @return The compatiable brand in the format defined by https://mp4ra.org/#/brands.
/// @return The compatiable brand in the format defined by
/// https://mp4ra.org/#/brands.
FourCC GetDoViCompatibleBrand(const uint8_t transfer_characteristics) const;

private:
Expand Down
31 changes: 16 additions & 15 deletions packager/media/formats/mp4/mp4_media_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ std::vector<uint8_t> GetDOVIDecoderConfig(
return std::vector<uint8_t>();
}


bool UpdateCodecStringForDolbyVision(
FourCC actual_format,
const std::vector<CodecConfiguration>& configs,
Expand Down Expand Up @@ -188,14 +187,12 @@ bool UpdateCodecStringForDolbyVision(
return true;
}


bool UpdateDolbyVisionInfo(
FourCC actual_format,
const std::vector<CodecConfiguration>& configs,
uint8_t transfer_characteristics,
std::string* codec_string,
std::string* dovi_supplemental_codec_string,
FourCC* dovi_compatible_brand) {
bool UpdateDolbyVisionInfo(FourCC actual_format,
const std::vector<CodecConfiguration>& configs,
uint8_t transfer_characteristics,
std::string* codec_string,
std::string* dovi_supplemental_codec_string,
FourCC* dovi_compatible_brand) {
DOVIDecoderConfigurationRecord dovi_config;
if (!dovi_config.Parse(GetDOVIDecoderConfig(configs))) {
LOG(ERROR) << "Failed to parse Dolby Vision decoder "
Expand Down Expand Up @@ -445,7 +442,8 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {

std::vector<std::shared_ptr<StreamInfo>> streams;

bool use_dovi_supplemental = absl::GetFlag(FLAGS_use_dovi_supplemental_codecs);
bool use_dovi_supplemental =
absl::GetFlag(FLAGS_use_dovi_supplemental_codecs);

for (std::vector<Track>::const_iterator track = moov_->tracks.begin();
track != moov_->tracks.end(); ++track) {
Expand Down Expand Up @@ -696,8 +694,9 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
return false;
}
} else {
if (!UpdateCodecStringForDolbyVision(
actual_format, entry.extra_codec_configs, &codec_string)) {
if (!UpdateCodecStringForDolbyVision(actual_format,
entry.extra_codec_configs,
&codec_string)) {
return false;
}
}
Expand Down Expand Up @@ -774,8 +773,9 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
return false;
}
} else {
if (!UpdateCodecStringForDolbyVision(
actual_format, entry.extra_codec_configs, &codec_string)) {
if (!UpdateCodecStringForDolbyVision(actual_format,
entry.extra_codec_configs,
&codec_string)) {
return false;
}
}
Expand Down Expand Up @@ -826,7 +826,8 @@ bool MP4MediaParser::ParseMoov(BoxReader* reader) {
nalu_length_size, track->media.header.language.code, is_encrypted));

if (use_dovi_supplemental) {
video_stream_info->set_supplemental_codec(dovi_supplemental_codec_string);
video_stream_info->set_supplemental_codec(
dovi_supplemental_codec_string);
video_stream_info->set_compatible_brand(dovi_compatible_brand);
}
video_stream_info->set_extra_config(entry.ExtraCodecConfigsAsVector());
Expand Down
3 changes: 1 addition & 2 deletions packager/media/formats/mp4/mp4_media_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include <memory>
#include <vector>

#include <absl/flags/flag.h>
#include <absl/flags/declare.h>
#include <absl/flags/flag.h>

#include <packager/macros/classes.h>
#include <packager/media/base/decryptor_source.h>
Expand All @@ -22,7 +22,6 @@

ABSL_DECLARE_FLAG(bool, use_dovi_supplemental_codecs);


namespace shaka {
namespace media {
namespace mp4 {
Expand Down
6 changes: 4 additions & 2 deletions packager/media/formats/mp4/mp4_muxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,11 @@ Status MP4Muxer::DelayInitializeMuxer() {

// https://professional.dolby.com/siteassets/content-creation/dolby-vision-for-content-creators/dolby_vision_bitstreams_within_the_iso_base_media_file_format_dec2017.pdf
std::string codec_string =
static_cast<const VideoStreamInfo*>(streams()[0].get())->codec_string();
static_cast<const VideoStreamInfo*>(streams()[0].get())
->codec_string();
std::string supplemental_codec_string =
static_cast<const VideoStreamInfo*>(streams()[0].get())->supplemental_codec();
static_cast<const VideoStreamInfo*>(streams()[0].get())
->supplemental_codec();
if (codec_string.find("dvh") != std::string::npos ||
supplemental_codec_string.find("dvh") != std::string::npos)
ftyp->compatible_brands.push_back(FOURCC_dby1);
Expand Down
7 changes: 2 additions & 5 deletions packager/mpd/base/mpd_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,9 @@ bool AddMpdNameSpaceInfo(XmlNode* mpd) {
static const char kMsprNamespace[] = "urn:microsoft:playready";
static const char kScte214Namespace[] = "scte214";


const std::map<std::string, std::string> uris = {
{"cenc", kCencNamespace},
{"mas", kMarlinNamespace},
{"xlink", kXmlNamespaceXlink},
{"mspr", kMsprNamespace},
{"cenc", kCencNamespace}, {"mas", kMarlinNamespace},
{"xlink", kXmlNamespaceXlink}, {"mspr", kMsprNamespace},
{"scte214", kScte214Namespace},
};

Expand Down
10 changes: 6 additions & 4 deletions packager/mpd/base/mpd_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ std::string GetSupplementalCodecs(const MediaInfo& media_info) {
CHECK(OnlyOneTrue(media_info.has_video_info(), media_info.has_audio_info(),
media_info.has_text_info()));

if (media_info.has_video_info() && media_info.video_info().has_supplemental_codec()) {
if (media_info.has_video_info() &&
media_info.video_info().has_supplemental_codec()) {
return media_info.video_info().supplemental_codec();
}
return "";
Expand All @@ -143,9 +144,10 @@ std::string GetSupplementalProfiles(const MediaInfo& media_info) {
CHECK(OnlyOneTrue(media_info.has_video_info(), media_info.has_audio_info(),
media_info.has_text_info()));

if (media_info.has_video_info() && media_info.video_info().has_compatible_brand()) {
return FourCCToString(static_cast<media::FourCC>(
media_info.video_info().compatible_brand()));
if (media_info.has_video_info() &&
media_info.video_info().has_compatible_brand()) {
return FourCCToString(
static_cast<media::FourCC>(media_info.video_info().compatible_brand()));
}
return "";
}
Expand Down
9 changes: 6 additions & 3 deletions packager/mpd/base/representation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,12 @@ std::optional<xml::XmlNode> Representation::GetXml() {
}

if (!supplemental_codecs_.empty() && !supplemental_profiles_.empty()) {
if (!representation.SetStringAttribute("scte214:supplementalCodecs", supplemental_codecs_) ||
!representation.SetStringAttribute("scte214:supplementalProfiles", supplemental_profiles_)) {
LOG(ERROR) << "Failed to add supplemental codecs/profiles to Representation XML.";
if (!representation.SetStringAttribute("scte214:supplementalCodecs",
supplemental_codecs_) ||
!representation.SetStringAttribute("scte214:supplementalProfiles",
supplemental_profiles_)) {
LOG(ERROR) << "Failed to add supplemental codecs/profiles to "
"Representation XML.";
}
}

Expand Down

0 comments on commit f645e4f

Please sign in to comment.