-
Notifications
You must be signed in to change notification settings - Fork 143
Simplifying and optimizing VideoFrame readback #157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
One of the key aspects of the current I think this API needs to have a Without a |
Clarification: since the proposal @chcunningham posted, we determined that the default implementation of That leaves a gap where some frames can be read synchronously but there is no way to express that without adding new methods. It's not yet clear how important the difference is, but the proposal to close the gap is as described by @dalecurtis above; add a fallible I'll also throw in my own bike shed, I have a preference to call the attribute |
Additional bike shed colors:
|
I opened some design discussion comments in the PR, but I'm resolving those in favor of focusing the discussion here where it's more visible/readable. Three points for discussion:
|
Triage note: marked 'breaking' as, as we are proposing a whole new readback API and discussing removal of old paths. |
Another consideration: naming bikeshed method to get the pixel data
In conclusion, I propose we call it |
I think the difference is subtle enough that if every other interface will have |
I'm also fine with that. |
Access to each plane individually is also needed for WebGPU/WebGL interrop, although we don't really know the preferred API shape.
|
Fixed by #208 |
(Full credit to @sandersdan for the following analysis and design. I'm just turning his doc into a bug.)
The
VideoFrame.planes
API allows reading back individual planes, but it has drawbacks:This issue proposes a simpler API for copying all planes at once.
Concepts
Region
A region is a
{top, left, width, height}
dictionary.VideoFrame
should be updated to use this structure:codedRegion
, which is always{top: 0, left: 0, width: codedWidth, height: codedHeight}
.codedWidth
andcodedHeight
, but this only seems to complicate constructingVideoFrames
.visibleRegion
, replacing thecrop
parameters.The default region is
visibleRegion
.elementSize
The number of bytes in a sample. Each
Plane
has anelementSize
attribute.Stride
The number of bytes from the start of one row to the start of the next row, must be at least
elementSize * region.width
.The default stride is exactly
elementSize * region.width
.Layout
A
layout
is a list of{offset, stride}
dictionaries, one for each plane.offset
is the location in a buffer that a plane starts.The default
offset
is tightly packed (each plane immediately follows the previous), and either all offsets should be provided or none should be.API
Changes to the planes API
Plane
PlaneInit
Examples
Copy visibleRegion to a new buffer (packed)
Copy codedRegion to a WASM frame pool
The text was updated successfully, but these errors were encountered: