Consider cropping VideoFrame if visible size <= buffer size < codedSize
Categories
(Core :: Audio/Video: Web Codecs, enhancement, P5)
Tracking
()
People
(Reporter: chunmin, Unassigned)
References
(Blocks 1 open bug)
Details
When constructing VideoFrame from the buffer, the buffer size (a.k.a. data.byteLength) must be bigger than or equal to the allocationSize of result of Compute Layout and Allocation Size, in step 11. However, if the (codedWidth, codedHeight) is (3, 3) and visibleRect’s (x, y, width, height) is (0, 0, 1, 1), giving a buffer with 2 x 2 x 4 size that contains 2-pixel width, 2-pixel height data in RGBA format can pass that check.
According to issue 516, the implementer can decide what to do. One possible approach is to construct a 1-pixel width, 1-pixel height RGBA VideoFrame whose (codedWidth, codedHeight) is (1, 1).
FYI, at the time when this is posted, Chromium refuses to construct a VideoFrame in this case:
Uncaught TypeError: Failed to construct 'VideoFrame': data is not large enough.
// test case
let data = new Uint8Array([
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
]);
let frame = new VideoFrame(data, {
timestamp: 10,
codedWidth: 3,
codedHeight: 3,
visibleRect: { x: 0, y: 0, width: 1, height: 1 },
format: "RGBA",
});
| Reporter | ||
Updated•2 years ago
|
Description
•