summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js')
-rw-r--r--testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js b/testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js
new file mode 100644
index 0000000000..da9754077f
--- /dev/null
+++ b/testing/web-platform/tests/webcodecs/videoFrame-odd-size.any.js
@@ -0,0 +1,50 @@
+// META: global=window,dedicatedworker
+// META: script=/webcodecs/videoFrame-utils.js
+
+test(t => {
+ let fmt = 'I420';
+ let vfInit = {
+ format: fmt,
+ timestamp: 1234,
+ codedWidth: 3,
+ codedHeight: 3,
+ visibleRect: {x: 0, y: 0, width: 3, height: 3},
+ };
+ let data = new Uint8Array([
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, // y
+ 1, 2, 3, 4, // u
+ 1, 2, 3, 4, // v
+ ]);
+ let frame = new VideoFrame(data, vfInit);
+ assert_equals(frame.format, fmt, 'format');
+ assert_equals(frame.visibleRect.x, 0, 'visibleRect.x');
+ assert_equals(frame.visibleRect.y, 0, 'visibleRect.y');
+ assert_equals(frame.visibleRect.width, 3, 'visibleRect.width');
+ assert_equals(frame.visibleRect.height, 3, 'visibleRect.height');
+ frame.close();
+}, 'Test I420 VideoFrame construction with odd coded size');
+
+promise_test(async t => {
+ const init = {
+ format: 'I420',
+ timestamp: 0,
+ codedWidth: 3,
+ codedHeight: 3,
+ };
+ const buf = new Uint8Array([
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, // y
+ 10, 11, 12, 13, // u
+ 14, 15, 16, 17, // v
+ ]);
+ const expectedLayout = [
+ {offset: 0, stride: 3},
+ {offset: 9, stride: 2},
+ {offset: 13, stride: 2},
+ ];
+ const frame = new VideoFrame(buf, init);
+ assert_equals(frame.allocationSize(), buf.length, 'allocationSize()');
+ const data = new Uint8Array(buf.length);
+ const layout = await frame.copyTo(data);
+ assert_layout_equals(layout, expectedLayout);
+ assert_buffer_equals(data, buf);
+}, 'Test I420 copyTo with odd coded size.');