-
Notifications
You must be signed in to change notification settings - Fork 137
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
Simplify VideoFrame Readback #208
Conversation
(I've contacted them). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some additional comments for design discussion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some additional comments for design discussion.
On second thought, lets move the design discussion to #157 for better visibility/readability. Please see this recent comment.
@padenot generally looks good, going to loop in graphics folks shortly
(I've contacted them).
Thanks. Standing by. Please give this issue priority. Of all our v1 launch blockers, this one has the most open questions.
I'm relaying the comments I've received, paraphrasing to add a bit more context:
|
Thanks @padenot
The main thing we disliked about DOMRect was that it's values are floating point. There are media APIs that handle the crop as floating point values, but this only makes sense for rendering, not for copying raw bytes. We definitely aren't attached to the name "Region". VideoFrameRect or similar would be fine. We also slightly prefer the top/left naming to DOMRect's x/y, but that's not too important.
The current shape is flexible: each plane can use the same buffer or a different buffer. The offset refers to whatever they give (should default to zero). But, we agree that using the same buffer will be more common. We're open to taking that path if you prefer. If so, we propose the following single-buffer constructor And we would add a new
Awesome. |
- s/crop/visbile/ - s/region/rect/ - s/readInto/copyTo/
@padenot I still need to define some spec steps to tie everything together, but this should now at least be at a point where the definitions are all there and crop stuff is fully removed. I'll finish it up Thursday afternoon. |
... and VideoFrame codedRect and visibleRect attributes. Still TODO: define steps for copyTo and allocationSize. Probably a *big* TODO.
The latest commit does everything except impl steps for vf.allocationSize() and vf.copyTo(). Listing those steps is so far looking like a large amount of work. Still pondering the approach. Re: #165, I think we at least want each VF pixel format to specify
Maybe more than that, but those were the dfns I found myself wanting so far. Chat tomorrow. |
@padenot @aboba this is now completely specified and ready for review. @sandersdan you might double check the new VF algos. @padenot, above I wrote:
Having now written the algorithms, I would add to that list
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, a few questions though.
3. Increment |row| by `1`. | ||
|
||
4. Let |resourceCodedWidth| be the coded width of |resource|. | ||
5. Let |resourceCodedHeight| be the coded height of |resource|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link those two.
|resource|. | ||
8. Let |resourceCropTop| be the top offset of the crop origin of | ||
7. Let |resourceVisibleTop| be the top offset for the visible rectangle of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link as well.
2. Assign {{VideoFrame/[[coded width]]}} and | ||
{{VideoFrame/[[coded height]]}} to {{VideoFrameRect/width}} and | ||
{{VideoFrameRect/height}} respectively. | ||
2. Return |rect|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note that (0,0) is top left and that this matches canvas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one is pretty clear since we called our attributes "top" and "left", but I'm happy to add a note if you still like.
3. Otherwise (|resource| does not use a recognized {{PixelFormat}}): | ||
1. Assign `""` to {{VideoFrame/format}}. | ||
2. Assign `null` to {{VideoFrame/planes}}. | ||
2. If |resource| uses a recognized {{PixelFormat}}, assign the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll link this after my PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
|
||
1. Let |plane| be the Plane identified by |planeIndex| as defined by | ||
{{VideoFrame/[[format]]}}. | ||
2. Let |sampleWidth| be the horizontal pixel size of each subsample |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll link this as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
Editors call: good to merge % comments |
VideoFrame(BufferSource buffer, sequence layout, VFPlaneInit init) but this drops ability to add alpha without a copy. options to extend (if needed): VideoFrame((BufferSource or sequence) buffer, sequence layout, VFPlaneInit init) or We could add it to VFPlaneInit |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing! I left the link comments unresolved so it would be easy to find them later. A few minor comments also still open w/ reply questions, but I'll send a quick follow up patch for those if needed.
3. Otherwise (|resource| does not use a recognized {{PixelFormat}}): | ||
1. Assign `""` to {{VideoFrame/format}}. | ||
2. Assign `null` to {{VideoFrame/planes}}. | ||
2. If |resource| uses a recognized {{PixelFormat}}, assign the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
|
||
1. Let |plane| be the Plane identified by |planeIndex| as defined by | ||
{{VideoFrame/[[format]]}}. | ||
2. Let |sampleWidth| be the horizontal pixel size of each subsample |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
6. If |displayAspectWidth| and |displayAspectHeight| are provided, | ||
1. Let |frame| be a new {{VideoFrame}}, constructed as follows: | ||
1. Assign `false` to {{VideoFrame/[[detached]]}}. | ||
2. Let |resource| be the [=media resource=] described by |output|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say it as "resource ownership is shared by all the frames that reference the resource. it may additionally be shared by a codec that is using/emitting the resource"
But I worry I maybe misunderstand your intent? We document the sharing in the Memory Model section. We also have this note in decode():
NOTE: Authors should call close() on output VideoFrames immediately when frames are no longer needed. The underlying media resources are owned by the VideoDecoder and failing to release them (or waiting for garbage collection) may cause decoding to stall.
LMK if more is needed, will send a quick follow up.
2. Assign {{VideoFrame/[[coded width]]}} and | ||
{{VideoFrame/[[coded height]]}} to {{VideoFrameRect/width}} and | ||
{{VideoFrameRect/height}} respectively. | ||
2. Return |rect|. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this one is pretty clear since we called our attributes "top" and "left", but I'm happy to add a note if you still like.
SHA: a96a6d7 Reason: push, by @chcunningham Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: a96a6d7 Reason: push, by @chcunningham Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: a96a6d7 Reason: push, by @chcunningham Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: a96a6d7 Reason: push, by @tguilbert-google Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: a96a6d7 Reason: push, by @tguilbert-google Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: a96a6d7 Reason: push, by @tguilbert-google Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Define new concepts of Regions and Layout as described in #157.
Preview | Diff