diff --git a/webcodecs/video-frame-serialization.any.js b/webcodecs/video-frame-serialization.any.js index 83b5ad060a09b1..bec6dfe726f699 100644 --- a/webcodecs/video-frame-serialization.any.js +++ b/webcodecs/video-frame-serialization.any.js @@ -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(); diff --git a/webcodecs/video-frame.any.js b/webcodecs/video-frame.any.js index a3768a56677f21..540023d5594d2f 100644 --- a/webcodecs/video-frame.any.js +++ b/webcodecs/video-frame.any.js @@ -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({ diff --git a/webcodecs/videoDecoder-codec-specific.any.js b/webcodecs/videoDecoder-codec-specific.any.js index 55d8310050994d..c4466bd8e50b19 100644 --- a/webcodecs/videoDecoder-codec-specific.any.js +++ b/webcodecs/videoDecoder-codec-specific.any.js @@ -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, }, diff --git a/webcodecs/videoFrame-readInto.any.js b/webcodecs/videoFrame-copyTo.any.js similarity index 70% rename from webcodecs/videoFrame-readInto.any.js rename to webcodecs/videoFrame-copyTo.any.js index c94252c87eeacf..e7a29acff6370e 100644 --- a/webcodecs/videoFrame-readInto.any.js +++ b/webcodecs/videoFrame-copyTo.any.js @@ -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.');