Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
VideoFrame buffer constructor doesn't respect codedWidth if visibleRe…
…ct is present https://bugs.webkit.org/show_bug.cgi?id=256848 rdar://109724698 Reviewed by Eric Carlson. Use codedWidth and codedHeight instead of parsedRect. This is coherent with the rest of the algorithm like checking the array size and is consistent with what Chrome does. I filed w3c/webcodecs#702 to update the spec. * LayoutTests/http/wpt/webcodecs/videoFrame-with-stride-expected.txt: Added. * LayoutTests/http/wpt/webcodecs/videoFrame-with-stride.html: Added. * Source/WebCore/Modules/webcodecs/WebCodecsVideoFrame.cpp: (WebCore::WebCodecsVideoFrame::create): Canonical link: https://commits.webkit.org/265844@main
- Loading branch information
Showing
3 changed files
with
67 additions
and
1 deletion.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
LayoutTests/http/wpt/webcodecs/videoFrame-with-stride-expected.txt
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,3 @@ | ||
|
||
PASS Creating video frames Creating video frames Creating video frames with codedWidth differing from visibleWidthh | ||
|
63 changes: 63 additions & 0 deletions
63
LayoutTests/http/wpt/webcodecs/videoFrame-with-stride.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> | ||
<script src='/resources/testharness.js'></script> | ||
<script src='/resources/testharnessreport.js'></script> | ||
<script src='/webcodecs/videoFrame-utils.js'></script> | ||
</head> | ||
<body> | ||
<canvas id=canvas width=100px hwight=100px></canvas> | ||
<script> | ||
function createVideoFrame(stride) | ||
{ | ||
const width = 16; | ||
const height = 16; | ||
const size = stride * height; | ||
const buf = new ArrayBuffer(size * 1.5); | ||
const bytesY = new Uint8Array(buf, 0, size * 1.0); | ||
const bytesU = new Uint8Array(buf, size * 1.0, size * 0.25); | ||
const bytesV = new Uint8Array(buf, size * 1.25, size * 0.25); | ||
for (let y = 0; y < height; y++) { | ||
for (let x = 0; x < width; x++) | ||
bytesY[y * stride + x] = (y << 4) | x; | ||
} | ||
bytesU.fill(128); | ||
bytesV.fill(128); | ||
|
||
return new VideoFrame(buf, { | ||
format: "I420", | ||
codedWidth: stride, | ||
codedHeight: height, | ||
timestamp: 0, | ||
visibleRect: { | ||
x: 0, | ||
y: 0, | ||
width: width, | ||
height: height | ||
}, | ||
colorSpace: { | ||
primaries: 'bt709', | ||
transfer: 'bt709', | ||
matrix: 'bt709', | ||
fullRange: true, | ||
} | ||
}); | ||
} | ||
|
||
test(t => { | ||
const frame1 = createVideoFrame(16); | ||
t.add_cleanup(() => frame1.close()); | ||
const frame2 = createVideoFrame(32); | ||
t.add_cleanup(() => frame2.close()); | ||
|
||
canvas.getContext('2d').drawImage(frame1, 0, 0); | ||
const data1 = canvas.getContext('2d').getImageData(0, 0, 4, 2).data; | ||
|
||
canvas.getContext('2d').drawImage(frame2, 0, 0); | ||
const data2 = canvas.getContext('2d').getImageData(0, 0, 4, 2).data; | ||
|
||
assert_array_equals(data1, data2); | ||
}, 'Creating video frames Creating video frames Creating video frames with codedWidth differing from visibleWidthh'); | ||
</script> | ||
</body> | ||
</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