Bug 1716447 [wpt PR 29374] - [webcodecs] Rename regions concepts, a=testonly

Automatic update from web-platform-tests
[webcodecs] Rename regions concepts

This CL renames "Region" to "Rect" and readInto() to copyTo().

Bug: 1176464
Change-Id: Ic2c494a54d9755f96272eecddb427ae4324f5099
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2961677
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/heads/master@{#892753}

--

wpt-commits: f93078f2cc56044fcd2ee6047b1afedbc64e67d6
wpt-pr: 29374
This commit is contained in:
Dan Sanders 2021-06-16 09:49:56 +00:00 committed by moz-wptsync-bot
parent 63835bc0a1
commit 457dda5022
4 changed files with 41 additions and 93 deletions

View File

@ -20,10 +20,10 @@ test(t => {
assert_equals(frame.timestamp, clone.timestamp);
assert_equals(frame.duration, clone.duration);
assert_equals(frame.visibleRegion.left, clone.visibleRegion.left);
assert_equals(frame.visibleRegion.top, clone.visibleRegion.top);
assert_equals(frame.visibleRegion.width, clone.visibleRegion.width);
assert_equals(frame.visibleRegion.height, clone.visibleRegion.height);
assert_equals(frame.visibleRect.left, clone.visibleRect.left);
assert_equals(frame.visibleRect.top, clone.visibleRect.top);
assert_equals(frame.visibleRect.width, clone.visibleRect.width);
assert_equals(frame.visibleRect.height, clone.visibleRect.height);
frame.close();
clone.close();

View File

@ -7,8 +7,8 @@ test(t => {
assert_equals(frame.timestamp, 10, 'timestamp');
assert_equals(frame.duration, null, 'duration');
assert_equals(frame.visibleRegion.width, 32, 'visibleRegion.width');
assert_equals(frame.visibleRegion.height, 16, 'visibleRegion.height');
assert_equals(frame.visibleRect.width, 32, 'visibleRect.width');
assert_equals(frame.visibleRect.height, 16, 'visibleRect.height');
assert_equals(frame.displayWidth, 32, 'displayWidth');
assert_equals(frame.displayHeight, 16, 'displayHeight');
@ -26,8 +26,8 @@ test(t => {
let image = makeImageBitmap(1, 1);
let frame = new VideoFrame(image, {timestamp: 10});
assert_equals(frame.visibleRegion.width, 1, 'visibleRegion.width');
assert_equals(frame.visibleRegion.height, 1, 'visibleRegion.height');
assert_equals(frame.visibleRect.width, 1, 'visibleRect.width');
assert_equals(frame.visibleRect.height, 1, 'visibleRect.height');
assert_equals(frame.displayWidth, 1, 'displayWidth');
assert_equals(frame.displayHeight, 1, 'displayHeight');
@ -145,31 +145,31 @@ test(t => {
timestamp: 1234,
codedWidth: 4,
codedHeight: 2,
visibleRegion: {left: 100, top: 100, width: 1,
height: 1}
visibleRect: {left: 100, top: 100, width: 1,
height: 1}
})},
'invalid visible left/right');
assert_throws_dom(
'ConstraintError',
() => {constructFrame(
{timestamp: 1234, codedWidth: 4, codedHeight: 2,
visibleRegion: {left: 0, top: 0, width: 0, height: 2}})},
visibleRect: {left: 0, top: 0, width: 0, height: 2}})},
'invalid visible width');
assert_throws_dom(
'ConstraintError',
() => {constructFrame(
{timestamp: 1234, codedWidth: 4, codedHeight: 2,
visibleRegion: {left: 0, top: 0, width: 2, height: 0}})},
visibleRect: {left: 0, top: 0, width: 2, height: 0}})},
'invalid visible height');
assert_throws_js(
TypeError,
() => constructFrame({timestamp: 1234,
codedWidth: 4,
codedHeight: 2,
visibleRegion: {left: 0,
top: 0,
width: -100,
height: -100}}),
visibleRect: {left: 0,
top: 0,
width: -100,
height: -100}}),
'invalid negative visible size');
assert_throws_js(
TypeError, () => {constructFrame({

View File

@ -11,7 +11,7 @@ const AV1_DATA = {
codec: 'av01.0.04M.08',
codedWidth: 320,
codedHeight: 240,
visibleRegion: {left: 0, top: 0, width: 320, height: 240},
visibleRect: {left: 0, top: 0, width: 320, height: 240},
displayWidth: 320,
displayHeight: 240,
},
@ -30,7 +30,7 @@ const VP8_DATA = {
codec: 'vp8',
codedWidth: 320,
codedHeight: 240,
visibleRegion: {left: 0, top: 0, width: 320, height: 240},
visibleRect: {left: 0, top: 0, width: 320, height: 240},
displayWidth: 320,
displayHeight: 240,
},

View File

@ -76,7 +76,7 @@ promise_test(async t => {
]);
assert_equals(frame.allocationSize(), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data);
const layout = await frame.copyTo(data);
assert_layout_equals(layout, expectedLayout);
assert_buffer_equals(data, expectedData);
}, 'Test I420 frame.');
@ -92,7 +92,7 @@ promise_test(async t => {
]);
assert_equals(frame.allocationSize(), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data);
const layout = await frame.copyTo(data);
assert_layout_equals(layout, expectedLayout);
assert_buffer_equals(data, expectedData);
}, 'Test RGBA frame.');
@ -100,40 +100,17 @@ promise_test(async t => {
promise_test(async t => {
const frame = makeI420_4x2();
const data = new Uint8Array(11);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data));
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data));
}, 'Test undersized buffer.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
layout: [{}, {}, {}],
};
const expectedLayout = [
{offset: 0, stride: 4},
{offset: 8, stride: 2},
{offset: 10, stride: 2},
];
const expectedData = new Uint8Array([
1, 2, 3, 4, // y
5, 6, 7, 8,
9, 10, // u
11, 12 // v
]);
assert_equals(frame.allocationSize(options), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data, options);
assert_layout_equals(layout, expectedLayout);
assert_buffer_equals(data, expectedData);
}, 'Test layout can be empty.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
layout: [{}],
layout: [{offset: 0, stride: 4}],
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data, options));
}, 'Test incorrect plane count.');
promise_test(async t => {
@ -153,7 +130,7 @@ promise_test(async t => {
]);
assert_equals(frame.allocationSize(options), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data, options);
const layout = await frame.copyTo(data, options);
assert_layout_equals(layout, options.layout);
assert_buffer_equals(data, expectedData);
}, 'Test stride and offset work.');
@ -178,7 +155,7 @@ promise_test(async t => {
]);
assert_equals(frame.allocationSize(options), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data, options);
const layout = await frame.copyTo(data, options);
assert_layout_equals(layout, options.layout);
assert_buffer_equals(data, expectedData);
}, 'Test stride and offset with padding.');
@ -194,38 +171,9 @@ promise_test(async t => {
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data, options));
}, 'Test invalid stride.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
layout: [
{offset: 0, stride: 4},
{offset: 8, stride: 2},
{offset: 10},
],
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
}, 'Test missing stride.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
layout: [
{offset: 0, stride: 4},
{offset: 8, stride: 2},
{stride: 2},
],
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
}, 'Test missing offset.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
@ -237,13 +185,13 @@ promise_test(async t => {
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data, options));
}, 'Test address overflow.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
region: frame.codedRegion,
rect: frame.codedRect,
};
const expectedLayout = [
{offset: 0, stride: 4},
@ -257,35 +205,35 @@ promise_test(async t => {
]);
assert_equals(frame.allocationSize(options), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data, options);
const layout = await frame.copyTo(data, options);
assert_layout_equals(layout, expectedLayout);
assert_buffer_equals(data, expectedData);
}, 'Test codedRegion.');
}, 'Test codedRect.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
region: {left: 0, top: 0, width: 4, height: 0},
rect: {left: 0, top: 0, width: 4, height: 0},
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
}, 'Test empty region.');
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data, options));
}, 'Test empty rect.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
region: {left: 0, top: 0, width: 4, height: 1},
rect: {left: 0, top: 0, width: 4, height: 1},
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
}, 'Test unaligned region.');
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data, options));
}, 'Test unaligned rect.');
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
region: {left: 2, top: 0, width: 2, height: 2},
rect: {left: 2, top: 0, width: 2, height: 2},
};
const expectedLayout = [
{offset: 0, stride: 2},
@ -300,7 +248,7 @@ promise_test(async t => {
]);
assert_equals(frame.allocationSize(options), expectedData.length, 'allocationSize()');
const data = new Uint8Array(expectedData.length);
const layout = await frame.readInto(data, options);
const layout = await frame.copyTo(data, options);
assert_layout_equals(layout, expectedLayout);
assert_buffer_equals(data, expectedData);
}, 'Test left crop.');
@ -308,9 +256,9 @@ promise_test(async t => {
promise_test(async t => {
const frame = makeI420_4x2();
const options = {
region: {left: 0, top: 0, width: 4, height: 4},
rect: {left: 0, top: 0, width: 4, height: 4},
};
assert_throws_dom('ConstraintError', () => frame.allocationSize(options));
const data = new Uint8Array(12);
await promise_rejects_dom(t, 'ConstraintError', frame.readInto(data, options));
}, 'Test invalid region.');
await promise_rejects_dom(t, 'ConstraintError', frame.copyTo(data, options));
}, 'Test invalid rect.');