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

fix: Fix cast support for HLG HDR #7632

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = {
'no-empty': ['error', {'allowEmptyCatch': true}],
'no-misleading-character-class': 'error',
'no-template-curly-in-string': 'error',
'no-fallthrough': ['error', {'allowEmptyCase': true}],
// TODO: Try to re-enable this if possible. Right now, it produces way too
// many false-positives with eslint 7. It worked well enough in eslint 5.
// 'require-atomic-updates': 'error',
Expand Down
41 changes: 36 additions & 5 deletions lib/polyfill/media_capabilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,12 +333,43 @@ shaka.polyfill.MediaCapabilities = class {
if (videoConfig.framerate) {
displayType += `; framerate=${videoConfig.framerate}`;
}
if (videoConfig.transferFunction === 'pq') {
// A "PQ" transfer function indicates this is an HDR-capable stream;
// "smpte2084" is the published standard. We need to inform the platform
// this query is specifically for HDR.
displayType += '; eotf=smpte2084';

// Don't trust Closure types here. Although transferFunction is string or
// undefined, we don't want to count on the input type. A switch statement
// will, however, differentiate between null and undefined. So we default
// to a blank string.
const transferFunction = videoConfig.transferFunction || '';

// Based on internal sources. Googlers, see go/cast-hdr-queries for source.
theodab marked this conversation as resolved.
Show resolved Hide resolved
switch (transferFunction) {
// The empty case falls through to SDR.
case '':
// These are the only 3 values defined by MCap as of November 2024.
case 'srgb':
// https://en.wikipedia.org/wiki/Standard-dynamic-range_video
// https://en.wikipedia.org/wiki/SRGB
// https://en.wikipedia.org/wiki/Rec._709
// This is SDR, standardized in BT 709.
// The platform recognizes "eotf=bt709", but we can also omit it.
break;

case 'pq':
// https://en.wikipedia.org/wiki/Perceptual_quantizer
// This HDR transfer function is standardized as SMPTE ST 2084.
displayType += '; eotf=smpte2084';
break;

case 'hlg':
// https://en.wikipedia.org/wiki/Hybrid_log%E2%80%93gamma
// This HDR transfer function is standardized as ARIB STD-B67.
displayType += '; eotf=arib-std-b67';
break;

default:
// An unrecognized transfer function. Reject this query.
return false;
}

let result = false;
if (displayType in shaka.polyfill.MediaCapabilities
.memoizedCanDisplayTypeRequests_) {
Expand Down
Loading
Loading