Skip to content

Define video color space interfaces and members #306

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

Merged
merged 11 commits into from
Aug 11, 2021
Merged

Conversation

chcunningham
Copy link
Collaborator

@chcunningham chcunningham commented Jul 16, 2021

Fixes #47

:)


Preview | Diff

@chcunningham chcunningham requested review from padenot and aboba July 16, 2021 08:23
@chcunningham chcunningham changed the title Basic IDL for color space interfaces/members Define video color space interfaces and members Jul 16, 2021
@chcunningham
Copy link
Collaborator Author

For now it's just the basic IDL. Out of time tonight, but wanted to get this out for discussion tomorrow. The enums are just a start - more to come there (probably in a follow up) aligning with H.273.

@sandersdan FYI

@chcunningham
Copy link
Collaborator Author

@sandersdan - looking at VideoColorSpace.toJSON() - can you remind me what the precedent was for this?

For changing color space (getting dict version of the interface), @padenot mentioned the pattern in WebRTC has been to use Object.assign(), for example
image

@sandersdan
Copy link
Contributor

Object.assign() is very similar to [Default] toJSON(), but it doesn't work as (may be) intended if the interface includes properties that shouldn't be turned into fields. For VideoColorSpace this could come up if we add H.273 getters, for example.

toJSON() also allows JSON.stringify() to work.

index.src.html Outdated
@@ -2685,6 +2695,9 @@
// Default display dimensions match visibleRect.
[EnforceRange] unsigned long displayWidth;
[EnforceRange] unsigned long displayHeight;

// Defaults to Rec709 or SRGB for planar and interleaved formats respectively.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For YUV and RGB formats respectively.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deleted this comment now, but see how I've implemented the "Pick Color Space" algo (choose sRGB if it's an RGB format, otherwise choose rec709).

Copy link
Collaborator Author

@chcunningham chcunningham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly done. Just needs definitions for the enums. @sandersdan a few questions for you in here.

index.src.html Outdated
@@ -2685,6 +2695,9 @@
// Default display dimensions match visibleRect.
[EnforceRange] unsigned long displayWidth;
[EnforceRange] unsigned long displayHeight;

// Defaults to Rec709 or SRGB for planar and interleaved formats respectively.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've deleted this comment now, but see how I've implemented the "Pick Color Space" algo (choose sRGB if it's an RGB format, otherwise choose rec709).

index.src.html Outdated
1. If {{VideoEncoder/[[active color space]]}} is `null`:
1. If |frame|.{{VideoFrame/colorSpace}} is not `null`, assign it's value
to {{VideoEncoder/[[active color space]]}}.
2. ISSUE: what here? 709? Can we trust that frame.colorSpace is not null?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandersdan thoughts? I we discussed it being null in some cases, like if you were creating from an internal videoframe that had some non-compatible representation? I wasn't able to quickly find cases in our impl where this actually occurs.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, an implementation could produce a VideoFrame with no JS-exposed color space. In Chrome that can happen easily with the current implementation because the WebCodecs implementation only supports a subset of color spaces (BT. 601, BT. 709, and sRGB), but if/when it's expanded to all of H.273 it would only happen for frames that are in a non-H.273 color space (currently not possible in Chrome).

Base automatically changed from single_buffer_videoframe_ctor to main July 27, 2021 15:08
@sandersdan
Copy link
Contributor

Merge conflicts resolved, minor fixes applied.

@padenot PTAL.

@chcunningham
Copy link
Collaborator Author

Review note: We could make this non-nullable and use a VideoColorSpace instance with null values instead.

I think I prefer the parent nullable, as-is, but I'm flexible.

Sorry, ran out time here. @sandersdan, here's an outline of todos:

  1. Define the attribute getter steps (and associated slots) for the VideoColorSpace interface. Should be similar in size to https://w3c.github.io/webcodecs/#imagetrack

  2. For "Initialize Frame With Resource and Size (with init, frame, resource, width and height)", delete step 12, instead write: Otherwise, assign null to [[color space]]. Per our convo that not every image source can be represented. Also, delete the Issue: block following this step

  3. Fill out "Rendering Color" section under VideoColorSpace, replacing the placeholder Issue: block. The idea here is just to describe in english (not rigid numbered steps) the behavior of WebGL and createImageBitmap() wrt VideoFrame.

  4. Add brief definitions for VideoColorSpace enum values, referencing table entries in h.273 (let h.273 do the heavy lifting here).

@sandersdan
Copy link
Contributor

Sorry, ran out time here. @sandersdan, here's an outline of todos:

TODOs fixed, PTAL.

Copy link
Collaborator Author

@chcunningham chcunningham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOs fixed, PTAL.

Thank you! LGTM.

I added a small note to address the comment from earlier.

@padenot @aboba let us know if this looks good.

@chcunningham
Copy link
Collaborator Author

EC: @aboba defers to Paul. LGTM

@chcunningham chcunningham merged commit df0a9ce into main Aug 11, 2021
@chcunningham chcunningham deleted the color_space branch August 11, 2021 17:10
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
github-actions bot added a commit that referenced this pull request Aug 11, 2021
SHA: df0a9ce
Reason: push, by @chcunningham

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Negotiating colorspaces
3 participants