mirror of
https://github.com/servo/servo.git
synced 2025-09-12 07:58:20 +01:00
tests: Vendor blink perf tests (#38654)
Vendors the [blink perf tests](https://chromium.googlesource.com/chromium/src/+/HEAD/third_party/blink/perf_tests/). These perf tests are useful to evaluate the performance of servo. The license that governs the perf tests is included in the folder. Running benchmark cases automatically is left to future work. The update.py script is taken from mozjs and slightly adapted, so we can easily filter (and patch if this should be necessary in the future. Testing: This PR just adds the perf_tests, but does not use or modify them in any way. --------- Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
parent
7621332824
commit
ee781b71b4
648 changed files with 359694 additions and 0 deletions
1
tests/blink_perf_tests/perf_tests/webcodecs/OWNERS
Normal file
1
tests/blink_perf_tests/perf_tests/webcodecs/OWNERS
Normal file
|
@ -0,0 +1 @@
|
|||
file://third_party/blink/renderer/modules/webcodecs/OWNERS
|
82
tests/blink_perf_tests/perf_tests/webcodecs/copyTo-test.js
Normal file
82
tests/blink_perf_tests/perf_tests/webcodecs/copyTo-test.js
Normal file
|
@ -0,0 +1,82 @@
|
|||
function makeSharedBuffer(size) {
|
||||
// SharedArrayBuffer constructor is hidden in some origins, but it's still
|
||||
// available via WebAssembly.Memory.
|
||||
const kPageSize = 65536;
|
||||
const sizeInPages = Math.floor((size + kPageSize - 1) / kPageSize);
|
||||
const memory = new WebAssembly.Memory(
|
||||
{initial: sizeInPages, maximum: sizeInPages, shared: true});
|
||||
return memory.buffer;
|
||||
}
|
||||
|
||||
function runCopyToTest(frame, desc) {
|
||||
let isDone = false;
|
||||
let size = frame.allocationSize();
|
||||
let buf = new makeSharedBuffer(size);
|
||||
|
||||
function runTest() {
|
||||
let startTime = PerfTestRunner.now();
|
||||
PerfTestRunner.addRunTestStartMarker();
|
||||
frame.copyTo(buf)
|
||||
.then(layout => {
|
||||
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
|
||||
PerfTestRunner.addRunTestEndMarker();
|
||||
if (!isDone)
|
||||
runTest();
|
||||
})
|
||||
.catch(e => {
|
||||
PerfTestRunner.logFatalError('Test error: ' + e);
|
||||
})
|
||||
}
|
||||
|
||||
PerfTestRunner.startMeasureValuesAsync({
|
||||
description: desc,
|
||||
unit: 'ms',
|
||||
done: _ => {
|
||||
isDone = true;
|
||||
frame.close();
|
||||
},
|
||||
run: _ => {
|
||||
runTest();
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function runBatchCopyToTest(frames, desc) {
|
||||
let isDone = false;
|
||||
let frames_and_buffers = frames.map(frame => {
|
||||
let size = frame.allocationSize();
|
||||
let buf = new makeSharedBuffer(size);
|
||||
return [frame, buf];
|
||||
});
|
||||
|
||||
function runTest() {
|
||||
let startTime = PerfTestRunner.now();
|
||||
PerfTestRunner.addRunTestStartMarker();
|
||||
let readback_promises = frames_and_buffers.map(([frame, buf]) => {
|
||||
return frame.copyTo(buf);
|
||||
});
|
||||
Promise.all(readback_promises)
|
||||
.then(layouts => {
|
||||
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
|
||||
PerfTestRunner.addRunTestEndMarker();
|
||||
if (!isDone)
|
||||
runTest();
|
||||
})
|
||||
.catch(e => {
|
||||
PerfTestRunner.logFatalError('Test error: ' + e);
|
||||
})
|
||||
}
|
||||
|
||||
PerfTestRunner.startMeasureValuesAsync({
|
||||
description: desc,
|
||||
unit: 'ms',
|
||||
done: _ => {
|
||||
isDone = true;
|
||||
for (let frame of frames)
|
||||
frame.close();
|
||||
},
|
||||
run: _ => {
|
||||
runTest();
|
||||
},
|
||||
});
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
function runCreateImageBitmapTest(frame, desc) {
|
||||
let isDone = false;
|
||||
|
||||
function runTest() {
|
||||
let startTime = PerfTestRunner.now();
|
||||
PerfTestRunner.addRunTestStartMarker();
|
||||
window.createImageBitmap(frame)
|
||||
.then(bitmap => {
|
||||
PerfTestRunner.measureValueAsync(PerfTestRunner.now() - startTime);
|
||||
PerfTestRunner.addRunTestEndMarker();
|
||||
if (!isDone)
|
||||
runTest();
|
||||
})
|
||||
.catch(e => {
|
||||
PerfTestRunner.logFatalError('Test error: ' + e);
|
||||
})
|
||||
}
|
||||
|
||||
PerfTestRunner.startMeasureValuesAsync({
|
||||
description: desc,
|
||||
unit: 'ms',
|
||||
done: _ => {
|
||||
isDone = true;
|
||||
frame.close();
|
||||
},
|
||||
run: _ => {
|
||||
runTest();
|
||||
},
|
||||
});
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test VideoEncoder performance</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="video-encoding.js"></script>
|
||||
<script>
|
||||
testEncodingConfiguration("Time for hardware encoding", 1280, 720, 100, 'prefer-hardware');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
BIN
tests/blink_perf_tests/perf_tests/webcodecs/resources/720p.h264
Normal file
BIN
tests/blink_perf_tests/perf_tests/webcodecs/resources/720p.h264
Normal file
Binary file not shown.
|
@ -0,0 +1,14 @@
|
|||
# WebCodecs Test Files
|
||||
|
||||
[TOC]
|
||||
|
||||
## Instructions
|
||||
|
||||
To add, update, or remove a test file, please update the list below.
|
||||
|
||||
## List of Test Files
|
||||
|
||||
### 720p.h264
|
||||
```
|
||||
ffmpeg -f lavfi -i testsrc=size=1280x720:rate=1:duration=1 -pix_fmt yuv420p -vcodec h264 -tune zerolatency -f h264 720p.h264
|
||||
```
|
|
@ -0,0 +1,14 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test VideoEncoder performance</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="video-encoding.js"></script>
|
||||
<script>
|
||||
testEncodingConfiguration("Time for software encoding", 1280, 720, 100, 'prefer-software');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,93 @@
|
|||
function prepareFrames(width, height, count) {
|
||||
const canvas = new OffscreenCanvas(width, height);
|
||||
const ctx = canvas.getContext('2d');
|
||||
const duration = 1_000_000 / 30; // 1/30 s
|
||||
let timestamp = 0;
|
||||
const frames = [];
|
||||
for (let i = 0; i < count; i++) {
|
||||
fourColorsFrame(ctx, width, height, timestamp.toString());
|
||||
let frame = new VideoFrame(canvas, {timestamp: timestamp});
|
||||
frames.push(frame);
|
||||
timestamp += duration;
|
||||
}
|
||||
return frames;
|
||||
}
|
||||
|
||||
async function testEncodingConfiguration(name, width, height, count, acc) {
|
||||
const encoder_config = {
|
||||
codec: "avc1.42001F",
|
||||
hardwareAcceleration: acc,
|
||||
width: width,
|
||||
height: height,
|
||||
bitrate: 2000000,
|
||||
framerate: 30
|
||||
};
|
||||
|
||||
let support = await VideoEncoder.isConfigSupported(encoder_config);
|
||||
if (!support.supported) {
|
||||
PerfTestRunner.log("Skipping test. Unsupported encoder config" +
|
||||
JSON.stringify(encoder_config));
|
||||
return;
|
||||
}
|
||||
|
||||
const warm_up_frames = 5;
|
||||
let frames = prepareFrames(width, height, count + warm_up_frames);
|
||||
let is_done = false;
|
||||
|
||||
const init = {
|
||||
output(chunk, metadata) {},
|
||||
error(e) {
|
||||
PerfTestRunner.logFatalError("Encoding error: " + e);
|
||||
}
|
||||
};
|
||||
|
||||
async function runTest() {
|
||||
const encoder = new VideoEncoder(init);
|
||||
encoder.configure(encoder_config);
|
||||
|
||||
PerfTestRunner.addRunTestStartMarker();
|
||||
|
||||
// Encode first several frames without timing it, this will given the
|
||||
// encoder chance to finish initialization.
|
||||
for (let i = 0; i < warm_up_frames; i++) {
|
||||
encoder.encode(frames[i], {keyFrame: false});
|
||||
}
|
||||
|
||||
await encoder.flush().catch(e => {
|
||||
PerfTestRunner.logFatalError("Test error: " + e);
|
||||
});
|
||||
|
||||
let start_time = PerfTestRunner.now();
|
||||
for (let frame of frames.slice(warm_up_frames)) {
|
||||
encoder.encode(frame, { keyFrame: false });
|
||||
}
|
||||
|
||||
encoder.flush().then(
|
||||
_ => {
|
||||
let run_time = PerfTestRunner.now() - start_time;
|
||||
PerfTestRunner.measureValueAsync(run_time);
|
||||
PerfTestRunner.addRunTestEndMarker();
|
||||
encoder.close();
|
||||
if (!is_done)
|
||||
runTest();
|
||||
},
|
||||
e => {
|
||||
PerfTestRunner.logFatalError("Test error: " + e);
|
||||
});
|
||||
}
|
||||
|
||||
PerfTestRunner.startMeasureValuesAsync({
|
||||
unit: 'ms',
|
||||
done: function () {
|
||||
is_done = true;
|
||||
for (let frame of frames)
|
||||
frame.close();
|
||||
},
|
||||
run: function() {
|
||||
runTest();
|
||||
},
|
||||
warmUpCount: 0,
|
||||
iterationCount: 3,
|
||||
description: name,
|
||||
});
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test batch copyTo() performance with VideoFrame from canvas</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="copyTo-test.js"></script>
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script>
|
||||
(async function() {
|
||||
const canvas = document.querySelector('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
let frames = [];
|
||||
// Sufficient number of frames to exercise parallelism as much as possible
|
||||
// without making the test too slow.
|
||||
const number_of_frames_to_copy = 20;
|
||||
for (let i = 0; i < number_of_frames_to_copy; i++) {
|
||||
await waitForNextFrame();
|
||||
fourColorsFrame(ctx, canvas.width, canvas.height, i.toString(2));
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
let frame = new VideoFrame(canvas, {timestamp: i});
|
||||
frames.push(frame);
|
||||
}
|
||||
|
||||
runBatchCopyToTest(
|
||||
frames, "CPU time for batch copyTo() w/ VideoFrames from canvas");
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test copyTo() performance with VideoFrame from canvas</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="copyTo-test.js"></script>
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
const canvas = document.querySelector('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
fourColorsFrame(ctx, canvas.width, canvas.height, 0x4C.toString(2));
|
||||
|
||||
let frame = new VideoFrame(canvas, {timestamp: 0});
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
runCopyToTest(
|
||||
frame, "CPU time for copyTo() w/ VideoFrame from canvas");
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test copyTo() performance with VideoFrame from VideoDecoder</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="copyTo-test.js"></script>
|
||||
|
||||
<script>
|
||||
(async function() {
|
||||
let frame = await createDecodedFrame();
|
||||
if (frame == null) {
|
||||
PerfTestRunner.logFatalError("No frame decoded");
|
||||
return;
|
||||
}
|
||||
|
||||
runCopyToTest(
|
||||
frame, "CPU time for copyTo() w/ VideoFrame from VideoDecoder");
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,20 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test createImageBitmap() performance with VideoFrame from canvas</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="createImageBitmap-test.js"></script>
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
const canvas = document.querySelector('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
fourColorsFrame(ctx, canvas.width, canvas.height, 0x4C.toString(2));
|
||||
|
||||
let frame = new VideoFrame(canvas, {timestamp: 0});
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
runCreateImageBitmapTest(
|
||||
frame, "CPU time for createImageBitmap w/ VideoFrame from canvas");
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test createImageBitmap() performance with VideoFrame from ImageDecoder</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="createImageBitmap-test.js"></script>
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
const canvas = document.querySelector('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
fourColorsFrame(ctx, canvas.width, canvas.height, 0x4C.toString(2));
|
||||
|
||||
const mime_type = "image/png";
|
||||
canvas.toBlob(blob => {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
let decoder = new ImageDecoder({data: blob.stream(), type: mime_type});
|
||||
decoder.decode().then(result => {
|
||||
runCreateImageBitmapTest(
|
||||
result.image,
|
||||
"CPU time for createImageBitmap w/ VideoFrame from ImageDecoder");
|
||||
}).catch(e => {
|
||||
PerfTestRunner.logFatalError("Test error: " + e);
|
||||
});
|
||||
}, mime_type, 1);
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,18 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test createImageBitmap() performance with VideoFrame from VideoDecoder</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<script src="createImageBitmap-test.js"></script>
|
||||
|
||||
<script>
|
||||
(async function() {
|
||||
let frame = await createDecodedFrame();
|
||||
if (frame == null) {
|
||||
PerfTestRunner.logFatalError("No frame decoded");
|
||||
return;
|
||||
}
|
||||
|
||||
runCreateImageBitmapTest(
|
||||
frame, "CPU time for createImageBitmap w/ VideoFrame from VideoDecoder");
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test drawImage() performance with VideoFrame from ImageDecoder</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
const canvas = document.querySelector('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
fourColorsFrame(ctx, canvas.width, canvas.height, 0x4C.toString(2));
|
||||
|
||||
const mime_type = "image/png";
|
||||
canvas.toBlob(blob => {
|
||||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
let decoder = new ImageDecoder({data: blob.stream(), type: mime_type});
|
||||
decoder.decode().then(result => {
|
||||
PerfTestRunner.measureInnerRAFTime({
|
||||
description: "CPU time for drawImage() w/ VideoFrame from ImageDecoder",
|
||||
run() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
ctx.drawImage(result.image, 0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}).catch(e => {
|
||||
PerfTestRunner.logFatalError("Test error: " + e);
|
||||
});
|
||||
}, mime_type, 1);
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,28 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test VideoFrame drawImage() performance</title>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script>
|
||||
(async function() {
|
||||
let frame = await createDecodedFrame();
|
||||
if (frame == null) {
|
||||
PerfTestRunner.logFatalError("No frame decoded");
|
||||
return;
|
||||
}
|
||||
|
||||
const canvas = document.getElementById("canvas");
|
||||
const ctx = canvas.getContext("2d");
|
||||
|
||||
PerfTestRunner.measureInnerRAFTime({
|
||||
description: "CPU time for drawImage()",
|
||||
run() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
ctx.drawImage(frame, 0, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
|
@ -0,0 +1,89 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test VideoFrame texImage2D() performance</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="../resources/runner.js"></script>
|
||||
<script src="videoFrame-utils.js"></script>
|
||||
<canvas id="canvas" width="1280" height="720"></canvas>
|
||||
|
||||
<script id="fragment-shader" type="glsl">
|
||||
uniform sampler2D tex;
|
||||
void main(void) {
|
||||
mediump vec2 coord = vec2(gl_FragCoord.x/1280.0, 1.0 - (gl_FragCoord.y/720.0));
|
||||
mediump vec4 sample = texture2D(tex, coord);
|
||||
gl_FragColor = vec4(sample.r, sample.g, sample.b, 1.0);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script id="vertex-shader" type="glsl">
|
||||
attribute vec2 c;
|
||||
void main(void) {
|
||||
gl_Position=vec4(c, 0.0, 1.0);
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
|
||||
(async function() {
|
||||
let frame = await createDecodedFrame();
|
||||
if (frame == null) {
|
||||
PerfTestRunner.logFatalError("No frame decoded");
|
||||
return;
|
||||
}
|
||||
|
||||
const canvas = document.getElementById("canvas");
|
||||
const gl = canvas.getContext('webgl2');
|
||||
const format = gl.RGBA;
|
||||
gl.viewport(0, 0, canvas.width, canvas.height);
|
||||
|
||||
const vs = gl.createShader(gl.VERTEX_SHADER);
|
||||
gl.shaderSource(vs, document.getElementById('vertex-shader').innerText);
|
||||
gl.compileShader(vs);
|
||||
|
||||
const fs = gl.createShader(gl.FRAGMENT_SHADER);
|
||||
gl.shaderSource(fs, document.getElementById('fragment-shader').innerText);
|
||||
gl.compileShader(fs);
|
||||
|
||||
if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) {
|
||||
TEST.log(gl.getShaderInfoLog(fs));
|
||||
}
|
||||
|
||||
const program = gl.createProgram();
|
||||
gl.attachShader(program, vs);
|
||||
gl.attachShader(program, fs);
|
||||
gl.linkProgram(program);
|
||||
gl.useProgram(program);
|
||||
|
||||
const vb = gl.createBuffer();
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, vb);
|
||||
gl.bufferData(
|
||||
gl.ARRAY_BUFFER, new Float32Array([-1, 1, -1, -1, 1, -1, 1, 1]),
|
||||
gl.STATIC_DRAW);
|
||||
|
||||
const coordLoc = gl.getAttribLocation(program, 'c');
|
||||
gl.vertexAttribPointer(coordLoc, 2, gl.FLOAT, false, 0, 0);
|
||||
gl.enableVertexAttribArray(coordLoc);
|
||||
|
||||
gl.clearColor(1, 1, 1, 1);
|
||||
gl.clear(gl.COLOR_BUFFER_BIT);
|
||||
|
||||
const tex = gl.createTexture();
|
||||
gl.bindTexture(gl.TEXTURE_2D, tex);
|
||||
|
||||
PerfTestRunner.measureInnerRAFTime({
|
||||
description: "CPU time for texImage2D()",
|
||||
run() {
|
||||
for (let i = 0; i < 10; i++) {
|
||||
gl.texImage2D(gl.TEXTURE_2D, 0, format, format, gl.UNSIGNED_BYTE, frame);
|
||||
gl.generateMipmap(gl.TEXTURE_2D);
|
||||
|
||||
gl.drawArrays(gl.TRIANGLE_FAN, 0, 4);
|
||||
gl.finish();
|
||||
}
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,53 @@
|
|||
function waitForNextFrame() {
|
||||
return new Promise((resolve, _) => {
|
||||
window.requestAnimationFrame(resolve);
|
||||
});
|
||||
}
|
||||
|
||||
function fourColorsFrame(ctx, width, height, text) {
|
||||
const kYellow = '#FFFF00';
|
||||
const kRed = '#FF0000';
|
||||
const kBlue = '#0000FF';
|
||||
const kGreen = '#00FF00';
|
||||
|
||||
ctx.fillStyle = kYellow;
|
||||
ctx.fillRect(0, 0, width / 2, height / 2);
|
||||
|
||||
ctx.fillStyle = kRed;
|
||||
ctx.fillRect(width / 2, 0, width / 2, height / 2);
|
||||
|
||||
ctx.fillStyle = kBlue;
|
||||
ctx.fillRect(0, height / 2, width / 2, height / 2);
|
||||
|
||||
ctx.fillStyle = kGreen;
|
||||
ctx.fillRect(width / 2, height / 2, width / 2, height / 2);
|
||||
|
||||
ctx.fillStyle = 'white';
|
||||
ctx.font = (height / 10) + 'px sans-serif';
|
||||
ctx.fillText(text, width / 2, height / 2);
|
||||
}
|
||||
|
||||
async function createDecodedFrame() {
|
||||
const config = {codec: 'avc1.64001f', codedWidth: 1280, codedHeight: 720};
|
||||
|
||||
const support = await VideoDecoder.isConfigSupported(config);
|
||||
if (!support.supported) {
|
||||
PerfTestRunner.logFatalError("Skipping test. Unsupported decoder config:" +
|
||||
JSON.stringify(config));
|
||||
return null;
|
||||
}
|
||||
|
||||
const result = await fetch('resources/720p.h264');
|
||||
const buf = await result.arrayBuffer();
|
||||
const chunk = new EncodedVideoChunk({timestamp: 0, type: 'key', data: buf});
|
||||
|
||||
let frame = null;
|
||||
const decoder = new VideoDecoder({
|
||||
output: f => frame = f,
|
||||
error: e => PerfTestRunner.log('Decode error:' + e)
|
||||
});
|
||||
decoder.configure(config);
|
||||
decoder.decode(chunk);
|
||||
await decoder.flush();
|
||||
return frame;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue