videoFrame-createImageBitmap.any.js (1004B)
1 // META: global=window,dedicatedworker 2 // META: script=/webcodecs/utils.js 3 4 promise_test(() => { 5 return testImageBitmapToAndFromVideoFrame(48, 36, kSRGBPixel); 6 }, 'ImageBitmap<->VideoFrame with canvas(48x36 srgb uint8).'); 7 8 promise_test(() => { 9 return testImageBitmapToAndFromVideoFrame(480, 360, kSRGBPixel); 10 }, 'ImageBitmap<->VideoFrame with canvas(480x360 srgb uint8).'); 11 12 promise_test(async () => { 13 const width = 128; 14 const height = 128; 15 let vfInit = {format: 'RGBA', timestamp: 0, 16 codedWidth: width, codedHeight: height, 17 displayWidth: width / 2, displayHeight: height / 2}; 18 let data = new Uint32Array(vfInit.codedWidth * vfInit.codedHeight); 19 data.fill(0xFF966432); // 'rgb(50, 100, 150)'; 20 let frame = new VideoFrame(data, vfInit); 21 22 let bitmap = await createImageBitmap(frame); 23 frame.close(); 24 25 assert_equals(bitmap.width, width / 2); 26 assert_equals(bitmap.height, height / 2); 27 bitmap.close(); 28 }, 'createImageBitmap uses frame display size');