-
Notifications
You must be signed in to change notification settings - Fork 144
Add AlphaMode to keep/discard alpha channel #274
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
Conversation
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.
Looking at EncodedVideoChunkMetadata
(and recent discussions about extension) makes me wonder whether we shouldn't separate it out better (e.g. put temporalLayerId
into its own dictionary).
editors call:
|
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.
Nice work.
index.src.html
Outdated
@@ -2819,6 +2842,18 @@ | |||
The {{VideoFrame/duration}} getter steps are to return | |||
{{VideoFrame/[[duration]]}}. | |||
|
|||
: <dfn attribute for=VideoFrame>hasAlpha</dfn> | |||
:: Whether or not the {{VideoFrame}} has an alpha channel. If this is `false`, | |||
the frame is considered to be opaque, and must be rendered as such. |
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 expand more on the contrasting false vs true behavior. Something like
When false
- the frame must be treated as fully opaque (for example, by any method which takes a CanvasImageSource)
- for planar formats, an alpha plane must not be present
- for interleaved formats, blocks of samples will contain an 'X' channel where the alpha channel may otherwise have been. The position of the 'X' channel is defined by [[format]]. The values of the 'X' channel are undefined and must be ignored when rendering.
When true
- the frame must be considered transparent for the pixels and degrees indicated by the alpha values.
- for planar formats, the alpha plane must appear as an additional plane following the non-alpha planes defined by [[format]]
- for interleaved formats, the alpha channel will appear at the 'A' position as defined by [[format]]
Just a draft, could probably use additional editing.
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.
... for the pixels and degrees ...
Is pixel sufficient? Degrees = U and V for example?
Done. I did made some small changes, not necessarily improvements.
@aboba wrote
@tguilbert-google could you also tackle this (i.e. metadata.temporalLayerId -> metadata.svc.temporalLayerId)? Could be a follow up. |
I see that the plan has changed from using just RGBA and BGRA to also include RGBX and BGRX. This doesn't seem very consistent to me:
It seems like if we are including 'X' RGB formats, then we should also include 'A' YUV formats. In that case The original plan of not having 'X' formats was also consistent, in the opposite direction. I don't see any reasoning for this change? |
I take your point. I don't love RGBA + hasAlpha=false. To me that seems confusing given precedent that 'A' means alpha is there while 'X' means its ignored. My earlier sense from googling this stuff was that 'X' variants of RGB are perhaps more prevalent than 'A' variants of YUV formats. But maybe that's not the case? Seems at least Ffmpeg and Gpac have both. Chrome has both I420 and I420A. I'm open to pursue 'A' and 'X'. Would this then remove the need for frame.hasAlpha entirely? |
I don't know how confusing it is. "Opaque" RGBA is quite common while RGBX is not something you are likely to see outside of media. A lot of code is able to handle them identically. Encoding this information in the format doubles the number of formats, but it also makes the formats more precise. I don't have a strong preference myself. Chrome's current internal support for I420A but not NV12A does suggest that these are indeed closely-related properties.
Likely a similar situation to
Yes. It's still a useful convenience, but we would also want other convenience metadata about formats and it's probably not |
Yes I can. I will make this a separate PR. |
This latest iteration of the spec gets rid of the the If we got rid of In that case, it would be important to specify which formats map to which with |
I also don't have a strong preference. Considering these points, it seems that this is slightly simplifying for users who don't care about the distinction. They don't need list 'x' variants in switch statements on pixel format. For planar formats, I can also imagine common code (e.g. if you do copyTo and just assume the returned layout has 3 planes, you're probably fine). Maybe that's enough reason to go with just hasAlpha, no 'x', no i420a, etc? |
@@ -2515,6 +2558,7 @@ | |||
dictionary VideoFrameInit { | |||
unsigned long long duration; // microseconds | |||
long long timestamp; // microseconds | |||
AlphaOption alpha = "keep"; | |||
}; | |||
|
|||
dictionary VideoFramePlaneInit { |
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.
If the outcome of pending discussion is that we keep hasAlpha, we should probably add hasAlpha to this structure as well as a signal for how to interpret the data (e.g. you now have an extra plane for planar formats)
(Editors call) Question: If we do it via boolean, do we then allow for alpha combined with all pixel formats. Is that always sane? Does it create need for more elaborate error handling? Related questions:
@padenot having closer look. @sandersdan, thoughts on the above |
The |
Discussed this with @sandersdan. He concludes that it is technically sane for any format to have "alpha", but this does create the mentioned headaches around UA support and error handling. This means @padenot LMK if this sounds good and we'll update the PR accordingly. |
I agree with this assessment. Would we expose all permutations at first, or would we only list what is going to be used in practice ? Is everything going to be used? I've never heard of |
I would only expose the useful permutations with the implication being that implementers must support whatever we expose. List you've added in #288 looks good for now. I don't think we want to expose the full set of formats in ffmpeg, but that small list should cover most common cases and is probably already supported in every UA. |
For sure. I was just using |
Removes VideoFrame.hasAlpha Adds a definition for "equivalent opaque format"
Editors call: @aboba no concerns. I'll take other pass today, but probably LGTM |
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.
Nice!
Nit: re-title to something like "Add AlphaMode to keep/discard alpha channel" |
SHA: 9a6e94b Reason: push, by @chcunningham Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: 9a6e94b Reason: push, by @chcunningham Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
SHA: 9a6e94b Reason: push, by @chcunningham Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This PR adds the hasAlpha attribute to VideoFrame, and the AlphaOption to keep/discard alpha data when initializing or encoding VideoFrames.
Fixes #207
💥 Error: 500 Internal Server Error 💥
PR Preview failed to build. (Last tried on Jul 26, 2021, 9:29 PM UTC).
More
PR Preview relies on a number of web services to run. There seems to be an issue with the following one:
🚨 CSS Spec Preprocessor - CSS Spec Preprocessor is the web service used to build Bikeshed specs.
🔗 Related URL
If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.