-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve logic for deciding when to paint the first video frame.
Currently we paint the first frame if !(ts + dur < start_time), this ends up painting frame N-1 if frame N has a timestamp of exactly start_time. Instead only paint if our current timestamp is >= start_time or (ts > start_time < ts + duration). Fixed: 1410446 Change-Id: I288e639964c054625d545763890616fe5d00a56f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4246659 Reviewed-by: Eugene Zemtsov <eugene@chromium.org> Commit-Queue: Dale Curtis <dalecurtis@chromium.org> Cr-Commit-Position: refs/heads/main@{#1105919}
- Loading branch information
1 parent
1f1ef0f
commit 219f4fa
Showing
7 changed files
with
86 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,48 @@ | ||
<!DOCTYPE html> | ||
<title>Test "video" as a source for "canvas".</title> | ||
<script src="../resources/testharness.js"></script> | ||
<script src="../resources/testharnessreport.js"></script> | ||
<video></video> | ||
<video style="display: none"></video> | ||
<canvas width="160" height="120"></canvas> | ||
<script> | ||
async_test(function(t) { | ||
var ctx; | ||
var width; | ||
var height; | ||
var results = { | ||
current: 0, | ||
values: [ | ||
// Different platforms may take different RGB conversion paths or | ||
// have slight rounding differences, so allow multiple values here. | ||
{ time: 0, r: [255], g: [255], b: [0] }, | ||
{ time: 2, r: [0], g: [3], b: [240, 242, 243] }, | ||
{ time: 4, r: [0], g: [31], b: [213, 215, 216] }, | ||
{ time: 6, r: [0], g: [48], b: [182, 183, 184, 185] }, | ||
{ time: 8, r: [0], g: [75, 76], b: [153, 154, 155] }, | ||
{ time: 10, r: [0], g: [96, 97], b: [126, 127, 128] } | ||
] | ||
}; | ||
|
||
var video = document.querySelector("video"); | ||
|
||
video.onloadedmetadata = t.step_func(function() { | ||
width = video.videoWidth / 2; | ||
height = video.videoHeight / 2; | ||
|
||
ctx = document.querySelector("canvas").getContext("2d"); | ||
ctx.fillStyle = "yellow"; | ||
ctx.fillRect(0, 0, width, height); | ||
testFrame(); | ||
}); | ||
|
||
video.onseeked = t.step_func(function() { | ||
ctx.drawImage(video, 0, 0, width, height); | ||
testFrame(); | ||
}); | ||
|
||
function testFrame() { | ||
var expected = results.values[results.current]; | ||
var frame = ctx.getImageData(0, 0, width, height); | ||
var r = frame.data[4 * 2 * width + 16 + 0]; | ||
var g = frame.data[4 * 2 * width + 16 + 1]; | ||
var b = frame.data[4 * 2 * width + 16 + 2]; | ||
|
||
assert_true(expected.r.includes(r), expected.time + " r " + r); | ||
assert_true(expected.g.includes(g), expected.time + " g " + g); | ||
assert_true(expected.b.includes(b), expected.time + " b " + b); | ||
<canvas width="160" height="120"></canvas> | ||
<canvas width="160" height="120"></canvas><br/> | ||
|
||
if (++results.current == results.values.length) | ||
t.done(); | ||
else | ||
video.currentTime = results.values[results.current].time; | ||
<canvas width="160" height="120"></canvas> | ||
<canvas width="160" height="120"></canvas> | ||
<canvas width="160" height="120"></canvas><br/> | ||
<script> | ||
if (window.testRunner) | ||
testRunner.waitUntilDone(); | ||
|
||
window.onload = _ => { | ||
var index = 0; | ||
var canvii = document.querySelectorAll('canvas'); | ||
var testTimes = [0, 2, 4, 6, 8, 10]; | ||
if (testTimes.length != canvii.length) { | ||
testRunner.fail('Unpexected number of canvas or test times.'); | ||
return; | ||
} | ||
|
||
var video = document.querySelector("video"); | ||
video.requestVideoFrameCallback(_ => { | ||
let width = video.videoWidth / 2; | ||
let height = video.videoHeight / 2; | ||
|
||
function drawNext() { | ||
let ctx = canvii[index++].getContext("2d"); | ||
ctx.fillStyle = "yellow"; | ||
ctx.fillRect(0, 0, width, height); | ||
ctx.drawImage(video, 0, 0, width, height); | ||
|
||
if (index < testTimes.length) { | ||
video.requestVideoFrameCallback(drawNext); | ||
video.currentTime = testTimes[index]; | ||
} else if (window.testRunner) { | ||
testRunner.notifyDone(); | ||
} | ||
} | ||
|
||
video.src = "content/counting.webm"; | ||
}); | ||
drawNext(); | ||
}); | ||
|
||
video.src = "content/counting.webm"; | ||
}; | ||
</script> |
Binary file added
BIN
+37.7 KB
third_party/blink/web_tests/platform/linux/media/video-canvas-expected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+37.6 KB
third_party/blink/web_tests/platform/mac/media/video-canvas-expected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+36.8 KB
third_party/blink/web_tests/platform/win/media/video-canvas-expected.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.