Skip to content

Commit f4351ba

Browse files
Djuffinchromium-wpt-export-bot
authored andcommitted
webcodecs: Implementation of VideoEncoder.isConfigSupported()
Bug: 1176442 Change-Id: I2463090994eb946284eeee1e62ed53ebd7c9584c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2823770 Commit-Queue: Eugene Zemtsov <[email protected]> Reviewed-by: Dan Sanders <[email protected]> Cr-Commit-Position: refs/heads/master@{#872626}
1 parent 1c760ed commit f4351ba

File tree

1 file changed

+133
-4
lines changed

1 file changed

+133
-4
lines changed

webcodecs/video-encoder-config.any.js

+133-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,145 @@
44
const invalidConfigs = [
55
{
66
comment: 'Emtpy codec',
7-
config: {codec: ''},
7+
config: {
8+
codec: '',
9+
width: 640,
10+
height: 480,
11+
},
812
},
913
{
1014
comment: 'Unrecognized codec',
11-
config: {codec: 'bogus'},
15+
config: {
16+
codec: 'bogus',
17+
width: 640,
18+
height: 480,
19+
},
1220
},
21+
{
22+
comment: 'Width is too large',
23+
config: {
24+
codec: 'vp8',
25+
width: 1000000,
26+
height: 480,
27+
},
28+
},
29+
{
30+
comment: 'Height is too large',
31+
config: {
32+
codec: 'vp8',
33+
width: 640,
34+
height: 1000000,
35+
},
36+
},
37+
{
38+
comment: 'Invalid scalability mode',
39+
config: {
40+
codec: 'vp8',
41+
width: 640,
42+
height: 480,
43+
scalabilityMode: "ABC"
44+
}
45+
},
46+
{
47+
comment: 'AVC not supported by VP8',
48+
config: {
49+
codec: 'vp8',
50+
width: 640,
51+
height: 480,
52+
avc: {
53+
format: "annexb"
54+
}
55+
}
56+
}
1357
];
1458

1559
invalidConfigs.forEach(entry => {
1660
promise_test(t => {
1761
return promise_rejects_js(t, TypeError, VideoEncoder.isConfigSupported(entry.config));
18-
}, 'Test that AudioDecoder.isConfigSupported() rejects invalid config:' + entry.comment);
19-
});
62+
}, 'Test that VideoEncoder.isConfigSupported() rejects invalid config:' + entry.comment);
63+
});
64+
65+
66+
const validButUnsupportedConfigs = [
67+
{
68+
comment: 'Too strenuous accelerated encoding parameters',
69+
config: {
70+
codec: "vp8",
71+
hardwareAcceleration: "require",
72+
width: 7000,
73+
height: 7000,
74+
bitrate: 1,
75+
framerate: 240,
76+
}
77+
},
78+
];
79+
80+
validButUnsupportedConfigs.forEach(entry => {
81+
let config = entry.config;
82+
promise_test(async t => {
83+
let support = await VideoEncoder.isConfigSupported(config);
84+
assert_false(support.supported);
85+
86+
let new_config = support.config;
87+
assert_equals(new_config.codec, config.codec);
88+
assert_equals(new_config.width, config.width);
89+
assert_equals(new_config.height, config.height);
90+
if (config.bitrate)
91+
assert_equals(new_config.bitrate, config.bitrate);
92+
if (config.framerate)
93+
assert_equals(new_config.framerate, config.framerate);
94+
}, "VideoEncoder.isConfigSupported() doesn't support config:" + entry.comment);
95+
});
96+
97+
const validConfigs = [
98+
{
99+
codec: "avc1.42001E",
100+
hardwareAcceleration: "allow",
101+
width: 640,
102+
height: 480,
103+
bitrate: 5000000,
104+
framerate: 24,
105+
avc: {
106+
format: "annexb"
107+
},
108+
futureConfigFeature: 'foo',
109+
},
110+
{
111+
codec: "vp8",
112+
hardwareAcceleration: "allow",
113+
width: 800,
114+
height: 600,
115+
bitrate: 7000000,
116+
framerate: 60,
117+
scalabilityMode: "L1T2",
118+
futureConfigFeature: 'foo',
119+
},
120+
{
121+
codec: "vp09.00.10.08",
122+
hardwareAcceleration: "allow",
123+
width: 1280,
124+
height: 720,
125+
bitrate: 7000000,
126+
framerate: 25,
127+
futureConfigFeature: 'foo',
128+
}
129+
];
130+
131+
validConfigs.forEach(config => {
132+
promise_test(async t => {
133+
let support = await VideoEncoder.isConfigSupported(config);
134+
assert_true(support.supported);
135+
136+
let new_config = support.config;
137+
assert_false(new_config.hasOwnProperty('futureConfigFeature'));
138+
assert_equals(new_config.codec, config.codec);
139+
assert_equals(new_config.width, config.width);
140+
assert_equals(new_config.height, config.height);
141+
if (config.bitrate)
142+
assert_equals(new_config.bitrate, config.bitrate);
143+
if (config.framerate)
144+
assert_equals(new_config.framerate, config.framerate);
145+
}, "VideoEncoder.isConfigSupported() supports:" + JSON.stringify(config));
146+
});
147+
148+

0 commit comments

Comments
 (0)