☠☠ backed out by dec0a179f851 ☠ ☠ | |
author | Dan Sanders <sandersd@chromium.org> |
Sat, 17 Jul 2021 09:51:42 +0000 | |
changeset 585841 | a95b4f61dabb2260228c9f8620e12eb50db2059c |
parent 585840 | 3ecf9f0828c31d51ab8ff79525036af92883d928 |
child 585842 | 894b083c110ae91c793a64c1beb04d7efc558b95 |
push id | 38620 |
push user | csabou@mozilla.com |
push date | Sun, 18 Jul 2021 09:08:29 +0000 |
treeherder | mozilla-central@cc4e5ea0c986 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | testonly |
bugs | 1719934, 29630, 3017512, 901236 |
milestone | 92.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
testing/web-platform/tests/webcodecs/utils.js | file | annotate | diff | comparison | revisions | |
testing/web-platform/tests/webcodecs/videoFrame.any.js | file | annotate | diff | comparison | revisions |
--- a/testing/web-platform/tests/webcodecs/utils.js +++ b/testing/web-platform/tests/webcodecs/utils.js @@ -145,32 +145,16 @@ function testUnconfiguredCodec(test, cod codec.reset(); assert_equals(codec.state, "unconfigured"); encodeOrDecodeShouldThrow(codec, codecInput); return promise_rejects_dom(test, 'InvalidStateError', codec.flush(), 'flush'); } -// Verifies a PlaneInit structure matches the actual constructed plane. -function verifyPlane(expected, actual) { - assert_less_than_equal(expected.stride, actual.stride, 'plane strides'); - assert_equals(expected.rows, actual.rows, 'plane rows'); - assert_less_than_equal( - expected.stride * expected.rows, actual.length, 'plane size'); - - var testBuffer = new Uint8Array(actual.length); - actual.readInto(testBuffer); - for (var h = 0; h < actual.rows; ++h) { - assert_array_equals( - expected.src.slice(h * expected.stride, expected.stride), - testBuffer.slice(h * actual.stride, expected.stride), 'plane data'); - } -} - // Reference values generated by: // https://fiddle.skia.org/c/f100d4d5f085a9e09896aabcbc463868 const kSRGBPixel = [50, 100, 150, 255]; const kP3Pixel = [62, 99, 146, 255]; const kRec2020Pixel = [87, 106, 151, 255]; const kCanvasOptionsP3Uint8 = {
--- a/testing/web-platform/tests/webcodecs/videoFrame.any.js +++ b/testing/web-platform/tests/webcodecs/videoFrame.any.js @@ -49,77 +49,16 @@ test(t => { assert_equals(frame.displayWidth, 1, 'displayWidth'); assert_equals(frame.displayHeight, 1, 'displayHeight'); frame.close(); }, 'Test we can construct an odd-sized VideoFrame.'); test(t => { let image = makeImageBitmap(32, 16); - let frame = new VideoFrame(image, {timestamp: 0}); - - // TODO(sandersd): This would be more clear as RGBA, but conversion has - // not be specified (or implemented) yet. - if (frame.format !== 'I420') { - return; - } - assert_equals(frame.planes.length, 3, 'number of planes'); - - // Validate Y plane metadata. - let yPlane = frame.planes[0]; - let yStride = yPlane.stride; - let yRows = yPlane.rows; - let yLength = yPlane.length; - - // Required minimums to contain the visible data. - assert_greater_than_equal(yRows, 16, 'Y plane rows'); - assert_greater_than_equal(yStride, 32, 'Y plane stride'); - assert_greater_than_equal(yLength, 32 * 16, 'Y plane length'); - - // Not required by spec, but sets limit at 50% padding per dimension. - assert_less_than_equal(yRows, 32, 'Y plane rows'); - assert_less_than_equal(yStride, 64, 'Y plane stride'); - assert_less_than_equal(yLength, 32 * 64, 'Y plane length'); - - // Validate Y plane data. - let buffer = new ArrayBuffer(yLength); - let view = new Uint8Array(buffer); - frame.planes[0].readInto(view); - - // TODO(sandersd): This probably needs to be fuzzy unless we can make - // guarantees about the color space. - assert_equals(view[0], 94, 'Y value at (0, 0)'); - - frame.close(); -}, 'Test we can read planar data from a VideoFrame.'); - -test(t => { - let image = makeImageBitmap(32, 16); - let frame = new VideoFrame(image, {timestamp: 0}); - - // TODO(sandersd): This would be more clear as RGBA, but conversion has - // not be specified (or implemented) yet. - if (frame.format !== 'I420') { - return; - } - - assert_equals(frame.planes.length, 3, 'number of planes'); - - // Attempt to read Y plane data, but close the frame first. - let yPlane = frame.planes[0]; - let yLength = yPlane.length; - frame.close(); - - let buffer = new ArrayBuffer(yLength); - let view = new Uint8Array(buffer); - assert_throws_dom('InvalidStateError', () => yPlane.readInto(view)); -}, 'Test we cannot read planar data from a closed VideoFrame.'); - -test(t => { - let image = makeImageBitmap(32, 16); image.close(); assert_throws_dom('InvalidStateError', () => { let frame = new VideoFrame(image, {timestamp: 10}); }) }, 'Test constructing VideoFrames from closed ImageBitmap throws.'); @@ -205,36 +144,32 @@ test(t => { TypeError, () => constructFrame({ timestamp: 1234, codedWidth: 4, codedHeight: 2, displayWidth: Math.pow(2, 32) - 1, displayHeight: Math.pow(2, 32) }), 'invalid display height'); -}, 'Test invalid planar constructed VideoFrames'); +}, 'Test invalid buffer constructed VideoFrames'); test(t => { let fmt = 'I420'; let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2}; let data = new Uint8Array([ 1, 2, 3, 4, 5, 6, 7, 8, // y 1, 2, // u 1, 2, // v ]); let frame = new VideoFrame(data, vfInit); - assert_equals(frame.planes.length, 3, 'plane count'); assert_equals(frame.format, fmt, 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'bt709', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'bt709', 'color matrix'); assert_false(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 4, rows: 2, src: data.slice(0, 8)}, frame.planes[0]); - verifyPlane({stride: 2, rows: 1, src: data.slice(8, 10)}, frame.planes[1]); - verifyPlane({stride: 2, rows: 1, src: data.slice(10, 12)}, frame.planes[2]); frame.close(); let y = {offset: 0, stride: 4}; let u = {offset: 8, stride: 2}; let v = {offset: 10, stride: 2}; assert_throws_js(TypeError, () => { let y = {offset: 0, stride: 1}; @@ -246,17 +181,17 @@ test(t => { }, 'u stride too small'); assert_throws_js(TypeError, () => { let v = {offset: 10, stride: 1}; let frame = new VideoFrame(data, {...vfInit, layout: [y, u, v]}); }, 'v stride too small'); assert_throws_js(TypeError, () => { let frame = new VideoFrame(data.slice(0, 8), vfInit); }, 'data too small'); -}, 'Test planar constructed I420 VideoFrame'); +}, 'Test buffer constructed I420 VideoFrame'); test(t => { let fmt = 'I420'; let vfInit = { format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2, @@ -282,126 +217,108 @@ test(t => { let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2}; let data = new Uint8Array([ 1, 2, 3, 4, 5, 6, 7, 8, // y 1, 2, // u 1, 2, // v 8, 7, 6, 5, 4, 3, 2, 1, // a ]); let frame = new VideoFrame(data, vfInit); - assert_equals(frame.planes.length, 4, 'plane count'); assert_equals(frame.format, fmt, 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'bt709', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'bt709', 'color matrix'); assert_false(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 4, rows: 2, src: data.slice(0, 8)}, frame.planes[0]); - verifyPlane({stride: 2, rows: 1, src: data.slice(8, 10)}, frame.planes[1]); - verifyPlane({stride: 2, rows: 1, src: data.slice(10, 12)}, frame.planes[2]); - verifyPlane({stride: 4, rows: 2, src: data.slice(12, 20)}, frame.planes[3]); frame.close(); // Most constraints are tested as part of I420 above. let y = {offset: 0, stride: 4}; let u = {offset: 8, stride: 2}; let v = {offset: 10, stride: 2}; let a = {offset: 12, stride: 4}; assert_throws_js(TypeError, () => { let a = {offset: 12, stride: 1}; let frame = new VideoFrame(data, {...vfInit, layout: [y, u, v, a]}); }, 'a stride too small'); assert_throws_js(TypeError, () => { let frame = new VideoFrame(data.slice(0, 12), vfInit); }, 'data too small'); -}, 'Test planar constructed I420+Alpha VideoFrame'); +}, 'Test buffer constructed I420+Alpha VideoFrame'); test(t => { let fmt = 'NV12'; let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2}; let data = new Uint8Array([ 1, 2, 3, 4, 5, 6, 7, 8, // y 1, 2, 3, 4, // uv ]); let frame = new VideoFrame(data, vfInit); - assert_equals(frame.planes.length, 2, 'plane count'); assert_equals(frame.format, fmt, 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'bt709', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'bt709', 'color matrix'); assert_false(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 4, rows: 2, src: data.slice(0, 8)}, frame.planes[0]); - verifyPlane({stride: 4, rows: 1, src: data.slice(8, 12)}, frame.planes[1]); frame.close(); let y = {offset: 0, stride: 4}; let uv = {offset: 8, stride: 4}; assert_throws_js(TypeError, () => { let y = {offset: 0, stride: 1}; let frame = new VideoFrame(data, {...vfInit, layout: [y, uv]}); }, 'y stride too small'); assert_throws_js(TypeError, () => { let uv = {offset: 8, stride: 1}; let frame = new VideoFrame(data, {...vfInit, layout: [y, uv]}); }, 'uv stride too small'); assert_throws_js(TypeError, () => { let frame = new VideoFrame(data.slice(0, 8), vfInit); }, 'data too small'); -}, 'Test planar constructed NV12 VideoFrame'); +}, 'Test buffer constructed NV12 VideoFrame'); test(t => { let vfInit = {timestamp: 1234, codedWidth: 4, codedHeight: 2}; let data = new Uint8Array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ]); let frame = new VideoFrame(data, {...vfInit, format: 'RGBA'}); - assert_equals(frame.planes.length, 1, 'plane count'); assert_equals(frame.format, 'RGBA', 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix'); assert_true(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 16, rows: 2, src: data}, frame.planes[0]); frame.close(); - // TODO(sandersd): verifyPlane() should not check alpha bytes. frame = new VideoFrame(data, {...vfInit, format: 'RGBX'}); - assert_equals(frame.planes.length, 1, 'plane count'); assert_equals(frame.format, 'RGBX', 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix'); assert_true(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 16, rows: 2, src: data}, frame.planes[0]); frame.close(); frame = new VideoFrame(data, {...vfInit, format: 'BGRA'}); - assert_equals(frame.planes.length, 1, 'plane count'); assert_equals(frame.format, 'BGRA', 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix'); assert_true(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 16, rows: 2, src: data}, frame.planes[0]); frame.close(); - // TODO(sandersd): verifyPlane() should not check alpha bytes. frame = new VideoFrame(data, {...vfInit, format: 'BGRX'}); - assert_equals(frame.planes.length, 1, 'plane count'); assert_equals(frame.format, 'BGRX', 'plane format'); assert_equals(frame.colorSpace.primaries, 'bt709', 'color primaries'); assert_equals(frame.colorSpace.transfer, 'iec61966-2-1', 'color transfer'); assert_equals(frame.colorSpace.matrix, 'rgb', 'color matrix'); assert_true(frame.colorSpace.fullRange, 'color range'); - verifyPlane({stride: 16, rows: 2, src: data}, frame.planes[0]); frame.close(); -}, 'Test planar constructed RGB VideoFrames'); +}, 'Test buffer constructed RGB VideoFrames'); test(t => { let image = makeImageBitmap(32, 16); let frame = new VideoFrame(image, {timestamp: 0}); assert_true(!!frame); frame_copy = new VideoFrame(frame); assert_equals(frame.format, frame_copy.format); @@ -439,54 +356,49 @@ test(t => { let vfInit = {format: fmt, timestamp: 1234, codedWidth: 4, codedHeight: 2}; let data = new Uint8Array([ 1, 2, 3, 4, 5, 6, 7, 8, // y 1, 2, // u 1, 2, // v 8, 7, 6, 5, 4, 3, 2, 1, // a ]); let frame = new VideoFrame(data, vfInit); - assert_equals(frame.planes.length, 4, 'plane count'); assert_equals(frame.format, fmt, 'plane format'); let alpha_frame_copy = new VideoFrame(frame, {alpha: 'keep'}); assert_equals(alpha_frame_copy.format, 'I420A', 'plane format'); - assert_equals(alpha_frame_copy.planes.length, 4, 'plane count'); let opaque_frame_copy = new VideoFrame(frame, {alpha: 'discard'}); assert_equals(opaque_frame_copy.format, 'I420', 'plane format'); - assert_equals(opaque_frame_copy.planes.length, 3, 'plane count'); frame.close(); alpha_frame_copy.close(); opaque_frame_copy.close(); }, 'Test I420A VideoFrame and alpha={keep,discard}'); test(t => { let vfInit = {timestamp: 1234, codedWidth: 4, codedHeight: 2}; let data = new Uint8Array([ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, ]); let frame = new VideoFrame(data, {...vfInit, format: 'RGBA'}); - assert_equals(frame.planes.length, 1, 'plane count'); assert_equals(frame.format, 'RGBA', 'plane format'); let alpha_frame_copy = new VideoFrame(frame, {alpha: 'keep'}); assert_equals(alpha_frame_copy.format, 'RGBA', 'plane format'); let opaque_frame_copy = new VideoFrame(frame, {alpha: 'discard'}); assert_equals(opaque_frame_copy.format, 'RGBX', 'plane format'); alpha_frame_copy.close(); opaque_frame_copy.close(); frame.close(); frame = new VideoFrame(data, {...vfInit, format: 'BGRA'}); - assert_equals(frame.planes.length, 1, 'plane count'); assert_equals(frame.format, 'BGRA', 'plane format'); alpha_frame_copy = new VideoFrame(frame, {alpha: 'keep'}); assert_equals(alpha_frame_copy.format, 'BGRA', 'plane format'); opaque_frame_copy = new VideoFrame(frame, {alpha: 'discard'}); assert_equals(opaque_frame_copy.format, 'BGRX', 'plane format');