-
Notifications
You must be signed in to change notification settings - Fork 140
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
createImageBitmap(videoFrame) Semantics #159
Comments
I don't feel like I have the ImageBitmap or VideoFrame domain expertise necessary to make strong judgment calls here. (@annevk might?) In such scenarios my preferred working mode is to delegate to the multi-implementer consensus, while doing my best to ensure local consistency at a high level. At a quick glance, your suggestions seem to meet that criteria. So the natural next question is, do you have multi-implementer input on these questions? |
Discussed in editors call. Generally no objections, but @padenot is taking a closer look. |
On colour conversion, I want to point to discussion happening in the Color on the Web CG, which is looking at how to enable HDR support in HTMLCanvasElement. This includes potential changes to |
Yep, we can't expose HDR (except by readback) until Given multiple choices for color spaces within an |
whatwg/html#6562 adds display-p3 support to |
That's correct. We would copy from a buffer that is effectively "owned" by the decoder (they only own a handful) to a buffer that is owned by the ImageBitmap. This copy would be made silently (no throwing). |
FYI, updates for createImageBitmap() are now proposed in whatwg/html#6589 Semantics match the what we proposed above. |
Edit: on second thought, still launch blocking. While we now have other better paths to render VideoFrame (e.g. drawImage()), we still need to define the behavior for createImageBitmap() since this takes a VideoFrame (CanvasImageSource) and changing the semantics may be observable. |
The PR in html has approval from spec folks there and I think we have consensus here as well. Given that, I'm removing the blocking label. I'm leaving this open to track the landing of that PR (blocked on proper inheritance of the [[Detached]] slot for transferable objects - easy to fix as part of #210). |
Triage note: marking 'extension' as we are extending createImageBitmap() and the consensus we've arrived at matches what Chrome's behind-flag implementation (so, not breaking for folks in the origin trial). |
This needs a definition if available in a shipping implementation. |
@padenot, is that sufficiently covered in linked PR? whatwg/html#6589 |
I see three things that are not addressed. |
Working on this now.
Sure!
I'll let them sort that out in the review. Seems easy to just update the other clauses and have everyone post a task to resolve if that's what's needed. |
Queuing a task would probably give the most flexibility to implementations, but if we know it can never be done in parallel, I'm not sure there's a point to it as it would increase latency. |
@domenic to opine. My guess is that the current wording intended that we allow some parts of the API to run async. For example, when we createImageBitmap() from a |
Closed by whatwg/html#6589 |
The plan is to make VideoFrame a CanvasImageSource (#158) and then (quickly) deprecate our videoFrame.createImageBitmap() in favor of window.createImageBitmap(videoFrame). This issue explores how window.createImageBitmap(videoFrame) would be spec'ed (in HTML).
Full credit to @sandersdan for the following. I'm just turning his excellent doc into a bug. I support his proposals. @domenic, are you the right html spec reviewer? Thoughts on the proposals below?
Purpose
There are a variety of things that
createImageBitmap()
forVideoFrame
could optionally do, at a performance cost. This document tries to clarify what those are, whether they should be done, and whether there is or should be a configuration parameter.Background
For a long time, it was assumed that
transferToImageBitmap()
would be the most efficient way to useVideoFrame
, and a lot of focus was put on makingImageBitmap
creation efficient (zero-copy). It’s now clear that other APIs (texImage2D()
,drawImage()
, andWEBGL_webcodecs_video_frame
) will offer better performance, so our assumptions should be re-evaluated.Properties
Lifetime
In some cases we can create an
ImageBitmap
that references theVideoFrame
contents to avoid making a copy. This could require that theImageBitmap
is closed to avoid stalling the decoder, which is atypical for Web APIs.ImageBitmaps
, as they typically already do.Crop
It is unclear whether users only need the visible region or will sometimes want the whole coded region.
Scale
Scaling the frame to its natural size may prevent zero-copy. It’s also unclear whether API users would prefer raw pixels or 1:1 pixels.
ImageBitmapOptions
hasresizeWidth
andresizeHeight
to control this behavior.ImageBitmaps
are specified to be measured in CSS pixels, which implies a 1:1 PAR.Rotation
Rotating the frame to match the requested orientation may prevent zero-copy. Most API users will prefer that orientation is handled for them, unless they are intentionally trying to pass through the raw stream.
ImageBitmapOptions
hasimageOrientation
, but it is for flipY only.Color Conversion
VideoFrames
can be created in a wider variety of color spaces thanImageBitmaps
. Converting to anImageBitmap
color space is likely to be lossy, butImageBitmaps
do not carry their own color space information.ImageBitmapOptions
hascolorSpaceConversion
to disable this behavior.The text was updated successfully, but these errors were encountered: