Skip to content
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

Support for HDR, VP9, AV1 #686

Merged
merged 11 commits into from
Dec 6, 2022
10 changes: 10 additions & 0 deletions locale/en_US/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,16 @@
<translation>Support Direct Play of MPEG-2 content (e.g., Live TV). This will prevent transcoding of MPEG-2 content, but uses significantly more bandwidth.</translation>
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<source>AV1 Support</source>
<translation>AV1 Support</translation>
<extracomment>Settings Menu - Title for option</extracomment>
</message>
<message>
<source>** EXPERIMENTAL** Support Direct Play of AV1 content when this Roku device supports it.</source>
neilsb marked this conversation as resolved.
Show resolved Hide resolved
<translation>** EXPERIMENTAL** Support Direct Play of AV1 content when this Roku device supports it.</translation>
neilsb marked this conversation as resolved.
Show resolved Hide resolved
<extracomment>Settings Menu - Description for option</extracomment>
</message>
<message>
<source>Enabled</source>
<translation>Enabled</translation>
Expand Down
7 changes: 7 additions & 0 deletions settings/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
"title": "Playback",
"description": "Settings relating to playback and supported codec and media types.",
"children": [
{
"title": "AV1 Support",
"description": "** EXPERIMENTAL** Support Direct Play of AV1 content when this Roku device supports it.",
neilsb marked this conversation as resolved.
Show resolved Hide resolved
"settingName": "playback.av1",
"type": "bool",
"default": "false"
},
{
"title": "MPEG-2 Support",
"description": "Support Direct Play of MPEG-2 content (e.g., Live TV). This will prevent transcoding of MPEG-2 content, but uses significantly more bandwidth.",
Expand Down
127 changes: 102 additions & 25 deletions source/utils/deviceCapabilities.brs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ end function

function getDeviceProfile() as object
playMpeg2 = get_user_setting("playback.mpeg2") = "true"
playAv1 = get_user_setting("playback.av1") = "true"

'Check if 5.1 Audio Output connected
maxAudioChannels = 2
Expand All @@ -26,14 +27,19 @@ function getDeviceProfile() as object
maxAudioChannels = 6
end if

if playMpeg2 and di.CanDecodeVideo({ Codec: "mpeg2" }).Result = true
tsVideoCodecs = "h264,mpeg2video"
else
tsVideoCodecs = "h264"
addHevcProfile = false
MAIN10 = ""
tsVideoCodecs = "h264"
if di.CanDecodeVideo({ Codec: "hevc" }).Result = true
tsVideoCodecs = "h265,hevc," + tsVideoCodecs
addHevcProfile = true
if di.CanDecodeVideo({ Codec: "hevc", Profile: "main 10" }).Result
MAIN10 = "|main 10"
end if
end if

if di.CanDecodeVideo({ Codec: "hevc" }).Result = true
tsVideoCodecs = tsVideoCodecs + ",h265,hevc"
if playMpeg2 and di.CanDecodeVideo({ Codec: "mpeg2" }).Result = true
tsVideoCodecs = tsVideoCodecs + ",mpeg2video"
end if

if di.CanDecodeAudio({ Codec: "ac3" }).result
Expand All @@ -42,9 +48,42 @@ function getDeviceProfile() as object
tsAudioCodecs = "aac"
end if

addAv1Profile = false
if playAv1 and di.CanDecodeVideo({ Codec: "av1" }).result
tsVideoCodecs = tsVideoCodecs + ",av1"
addAv1Profile = true
end if

addVp9Profile = false
if di.CanDecodeVideo({ Codec: "vp9" }).result
tsVideoCodecs = tsVideoCodecs + ",vp9"
addVp9Profile = true
end if

hevcVideoRangeTypes = "SDR"
vp9VideoRangeTypes = "SDR"
av1VideoRangeTypes = "SDR"

dp = di.GetDisplayProperties()
if dp.Hdr10 ' or dp.Hdr10Plus?
hevcVideoRangeTypes = hevcVideoRangeTypes + "|HDR10"
vp9VideoRangeTypes = vp9VideoRangeTypes + "|HDR10"
av1VideoRangeTypes = av1VideoRangeTypes + "|HDR10"
end if
if dp.HLG
hevcVideoRangeTypes = hevcVideoRangeTypes + "|HLG"
vp9VideoRangeTypes = vp9VideoRangeTypes + "|HLG"
av1VideoRangeTypes = av1VideoRangeTypes + "|HLG"
end if
if dp.DolbyVision
hevcVideoRangeTypes = hevcVideoRangeTypes + "|DOVI"
'vp9VideoRangeTypes = vp9VideoRangeTypes + ",DOVI" no evidence that vp9 can hold DOVI
av1VideoRangeTypes = av1VideoRangeTypes + "|DOVI"
end if

DirectPlayProfile = GetDirectPlayProfiles()

return {
deviceProfile = {
"MaxStreamingBitrate": 120000000,
"MaxStaticBitrate": 100000000,
"MusicStreamingTranscodingBitrate": 192000,
Expand Down Expand Up @@ -133,24 +172,6 @@ function getDeviceProfile() as object
"IsRequired": false
}
]
},
{
"Type": "Video",
"Codec": "hevc",
"Conditions": [
{
"Condition": "EqualsAny",
"Property": "VideoProfile",
"Value": "main",
"IsRequired": false
},
{
"Condition": "LessThanEqual",
"Property": "VideoLevel",
"Value": StrI(120 * 5.1),
"IsRequired": false
}
]
}
],
"SubtitleProfiles": [
Expand All @@ -172,6 +193,62 @@ function getDeviceProfile() as object
}
]
}
if addAv1Profile
deviceProfile.CodecProfiles.push({
"Type": "Video",
"Codec": "av1",
"Conditions": [
{
"Condition": "EqualsAny",
"Property": "VideoRangeType",
"Value": av1VideoRangeTypes,
"IsRequired": false
}
]
})
end if
if addHevcProfile
deviceProfile.CodecProfiles.push({
"Type": "Video",
"Codec": "hevc",
"Conditions": [
{
"Condition": "EqualsAny",
"Property": "VideoProfile",
"Value": "main" + MAIN10,
"IsRequired": false
},
{
"Condition": "EqualsAny",
"Property": "VideoRangeType",
"Value": hevcVideoRangeTypes,
"IsRequired": false
},
{
"Condition": "LessThanEqual",
"Property": "VideoLevel",
"Value": (120 * 5.1).ToStr(),
"IsRequired": false
}
]
})
end if
if addVp9Profile
deviceProfile.CodecProfiles.push({
"Type": "Video",
"Codec": "vp9",
"Conditions": [
{
"Condition": "EqualsAny",
"Property": "VideoRangeType",
"Value": vp9VideoRangeTypes,
"IsRequired": false
}
]
})
end if

return deviceProfile
end function


Expand Down