forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1774300 - Implement VideoColorSpace r=padenot,jgilbert
This patch implements the VideoColorSpace created in D144771. Depends on D144772 Differential Revision: https://phabricator.services.mozilla.com/D145395
- Loading branch information
1 parent
aa78f11
commit c608970
Showing
6 changed files
with
116 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[DEFAULT] | ||
subsuite = media | ||
tags = webcodecs | ||
prefs = | ||
dom.media.webcodecs.enabled=true | ||
|
||
[test_videoColorSpace.html] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
<head> | ||
<title></title> | ||
<script src="/tests/SimpleTest/SimpleTest.js"></script> | ||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> | ||
</head> | ||
<body> | ||
<script> | ||
let defaultVideoColorSpaceInit = { | ||
primaries: "bt709", | ||
transfer: "bt709", | ||
matrix: "bt709", | ||
fullRange: true, | ||
}; | ||
let VCSIs = generateAllCombinations(defaultVideoColorSpaceInit); | ||
for (let VCSI of VCSIs) { | ||
check(VCSI); | ||
} | ||
|
||
function generateAllCombinations(obj) { | ||
let keySets = getAllSubsets(Object.keys(obj)); | ||
let combinations = []; | ||
for (let set of keySets) { | ||
let element = {}; | ||
for (let key of set) { | ||
element[key] = obj[key]; | ||
} | ||
combinations.push(element); | ||
} | ||
return combinations; | ||
} | ||
|
||
function getAllSubsets(set) { | ||
let sebsets = []; | ||
let upperbound = 1 << set.length; | ||
for (let bitmask = 0; bitmask < upperbound; ++bitmask) { | ||
let subset = []; | ||
for (let i = 0; i < set.length; ++i) { | ||
if (bitmask & (1 << i)) { | ||
subset.push(set[i]); | ||
} | ||
} | ||
sebsets.push(subset); | ||
} | ||
return sebsets; | ||
} | ||
|
||
function check(VCSI) { | ||
let vcs = new VideoColorSpace(VCSI); | ||
let json = vcs.toJSON(); | ||
const VCSIKeys = Object.keys(VCSI); | ||
for (const k of Object.keys(json)) { | ||
is( | ||
json[k], | ||
VCSIKeys.includes(k) ? VCSI[k] : null, | ||
"VideoColorSpace.ToJSON()'s property should match the given VideoColorSpaceInit's one" | ||
); | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |