feat(DASH): Add video transfer characteristics. (#1210)

This PR is related to https://github.com/shaka-project/shaka-packager/issues/1035
This commit is contained in:
sr90 2023-09-08 14:41:41 -07:00 committed by GitHub
parent b7660590a6
commit 8465f5f020
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 0 deletions

View File

@ -3,6 +3,7 @@
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT6.022683143615723S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="60000/1001" subsegmentAlignment="true" par="16:9">
<SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:TransferCharacteristics" value="16"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>

View File

@ -3,6 +3,7 @@
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT6.022683143615723S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="60000/1001" subsegmentAlignment="true" par="16:9">
<SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:TransferCharacteristics" value="16"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>
@ -15,6 +16,7 @@
</Representation>
</AdaptationSet>
<AdaptationSet id="1" contentType="video" width="640" height="360" frameRate="60000/1001" subsegmentAlignment="true" par="16:9">
<SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:TransferCharacteristics" value="16"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>

View File

@ -3,6 +3,7 @@
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd" xmlns:cenc="urn:mpeg:cenc:2013" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT2S" type="static" mediaPresentationDuration="PT2.802799940109253S">
<Period id="0">
<AdaptationSet id="0" contentType="video" width="640" height="360" frameRate="30000/1001" subsegmentAlignment="true" par="16:9">
<SupplementalProperty schemeIdUri="urn:mpeg:mpegB:cicp:TransferCharacteristics" value="16"/>
<ContentProtection value="cenc" schemeIdUri="urn:mpeg:dash:mp4protection:2011" cenc:default_KID="31323334-3536-3738-3930-313233343536"/>
<ContentProtection schemeIdUri="urn:uuid:1077efec-c0b2-4d02-ace3-3c1e52e2fb4b">
<cenc:pssh>AAAANHBzc2gBAAAAEHfv7MCyTQKs4zweUuL7SwAAAAExMjM0NTY3ODkwMTIzNDU2AAAAAA==</cenc:pssh>

View File

@ -290,6 +290,14 @@ base::Optional<xml::XmlNode> AdaptationSet::GetXml() {
}
}
// https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf - 4.2.5.1
if (IsVideo() && transfer_characteristics_ > 0 &&
!adaptation_set.AddSupplementalProperty(
"urn:mpeg:mpegB:cicp:TransferCharacteristics",
std::to_string(transfer_characteristics_))) {
return base::nullopt;
}
// Note: must be checked before checking segments_aligned_ (below). So that
// segments_aligned_ is set before checking below.
if (mpd_options_.mpd_type == MpdType::kStatic) {

View File

@ -180,6 +180,17 @@ class AdaptationSet {
/// @param codec is the new codec to be set.
void set_codec(const std::string& codec) { codec_ = codec; };
/// @return transfer_characteristics.
const uint32_t transfer_characteristics() const {
return transfer_characteristics_;
}
/// Set AdaptationSet's video transfer characteristics.
/// @param transfer_characteristics is the video transfer characteristics.
void set_transfer_characteristics(const uint32_t& transfer_characteristics) {
transfer_characteristics_ = transfer_characteristics;
};
protected:
/// @param language is the language of this AdaptationSet. Mainly relevant for
/// audio.
@ -314,6 +325,9 @@ class AdaptationSet {
// and HD videos in different AdaptationSets can share the same trick play
// stream.
std::vector<const AdaptationSet*> trick_play_references_;
// Transfer characteristics.
uint32_t transfer_characteristics_ = 0;
};
} // namespace shaka

View File

@ -162,6 +162,17 @@ std::string GetAdaptationSetKey(const MediaInfo& media_info,
if (!ignore_codec) {
key.append(":");
key.append(GetBaseCodec(media_info));
if (GetBaseCodec(media_info).find("dvh") == 0) {
// Transfer characteristics for Dolby Vision (dvh1 or dvhe) must be PQ
// irrespective of value present in SPS VUI.
key.append(":");
key.append(std::to_string(kTransferFunctionPQ));
} else if (media_info.video_info().has_transfer_characteristics()) {
key.append(":");
key.append(
std::to_string(media_info.video_info().transfer_characteristics()));
}
}
key.append(":");
key.append(GetLanguage(media_info));

View File

@ -25,6 +25,7 @@ struct SegmentInfo;
const char kEncryptedMp4Scheme[] = "urn:mpeg:dash:mp4protection:2011";
const char kPsshElementName[] = "cenc:pssh";
const char kMsproElementName[] = "mspr:pro";
const uint32_t kTransferFunctionPQ = 16;
bool HasVODOnlyFields(const MediaInfo& media_info);

View File

@ -269,6 +269,22 @@ bool Period::SetNewAdaptationSetAttributes(
}
}
// Set transfer characteristics.
// https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf - 4.2.5.1
// ISO/IEC 23001-8 MPEG systems technologies — Part 8: Coding-independent
// code points. https://en.wikipedia.org/wiki/Coding-independent_code_points
// - Common CCIP values.
// Dolby vision:
// https://professionalsupport.dolby.com/s/article/How-to-signal-Dolby-Vision-in-MPEG-DASH
// Transfer characteristics for Dolby Vision (dvh1 or dvhe) must be PQ
// irrespective of value present in SPS VUI.
if (new_adaptation_set->codec().find("dvh") == 0) {
new_adaptation_set->set_transfer_characteristics(kTransferFunctionPQ);
} else if (media_info.video_info().has_transfer_characteristics()) {
new_adaptation_set->set_transfer_characteristics(
media_info.video_info().transfer_characteristics());
}
} else if (media_info.has_text_info()) {
// IOP requires all AdaptationSets to have (sub)segmentAlignment set to
// true, so carelessly set it to true.