|
30 | 30 |
|
31 | 31 | <pre class=link-defaults> |
32 | 32 | spec:html; type:attribute; text:hidden |
| 33 | +spec:html; type:enum-value; text:srgb |
33 | 34 | spec:infra; type:dfn; text:list |
34 | 35 | spec:infra; type:dfn; text:enqueue |
35 | 36 | </pre> |
|
38 | 39 | spec: html; urlPrefix: https://html.spec.whatwg.org/multipage/; |
39 | 40 | for: ImageBitmap; |
40 | 41 | type: dfn; text: bitmap data; url: imagebitmap-and-animations.html#concept-imagebitmap-bitmap-data |
| 42 | + for: ImageData |
| 43 | + type: dfn; text: canvas pixel data; url: canvas.html#imagedata |
41 | 44 | for: Canvas; |
42 | 45 | type: dfn; text: Check the usability of the image argument; url: canvas.html#check-the-usability-of-the-image-argument |
43 | 46 | type: dfn; text: is not origin-clean; url: canvas.html#the-image-argument-is-not-origin-clean |
|
3745 | 3748 |
|
3746 | 3749 | : <dfn method for=VideoFrame>copyTo(|destination|, |options|)</dfn> |
3747 | 3750 | :: Asynchronously copies the planes of this frame into |destination| according |
3748 | | - to |options|. The format of the data is the same as this {{VideoFrame}}'s |
3749 | | - {{VideoFrame/format}}. |
| 3751 | + to |options|. The format of the data is |options|.{{VideoFrameCopyToOptions/format}}, |
| 3752 | + if it [=map/exists=] or [=this=] {{VideoFrame}}'s {{VideoFrame/format}} otherwise. |
3750 | 3753 |
|
3751 | 3754 | NOTE: Promises that are returned by several calls to |
3752 | 3755 | {{VideoFrame/copyTo()}} are not guaranteed to resolve in the order they |
3753 | 3756 | were returned. |
3754 | 3757 |
|
3755 | 3758 | When invoked, run these steps: |
3756 | | - 1. If {{platform object/[[Detached]]}} is `true`, throw an |
3757 | | - {{InvalidStateError}} {{DOMException}}. |
3758 | | - 2. If {{VideoFrame/[[format]]}} is `null`, throw a {{NotSupportedError}} |
3759 | | - {{DOMException}}. |
| 3759 | + 1. If {{platform object/[[Detached]]}} is `true`, return a promise rejected |
| 3760 | + with a {{InvalidStateError}} {{DOMException}}. |
| 3761 | + 2. If {{VideoFrame/[[format]]}} is `null`, return a promise rejected with a |
| 3762 | + {{NotSupportedError}} {{DOMException}}. |
3760 | 3763 | 3. Let |combinedLayout| be the result of running the [=Parse |
3761 | 3764 | VideoFrameCopyToOptions=] algorithm with |options|. |
3762 | 3765 | 4. If |combinedLayout| is an exception, return a promise rejected with |
3763 | 3766 | |combinedLayout|. |
3764 | 3767 | 5. If `destination.byteLength` is less than |combinedLayout|'s [=combined |
3765 | 3768 | buffer layout/allocationSize=], return a promise rejected with a |
3766 | 3769 | {{TypeError}}. |
3767 | | - 6. Let |p| be a new {{Promise}}. |
3768 | | - 7. Let |copyStepsQueue| be the result of starting a new [=parallel queue=]. |
3769 | | - 8. Let |planeLayouts| be a new [=list=]. |
3770 | | - 9. Enqueue the following steps to |copyStepsQueue|: |
| 3770 | + 6. If |options|.{{VideoFrameCopyToOptions/format}} is equal to one of |
| 3771 | + {{RGBA}}, {{RGBX}}, {{BGRA}}, {{BGRX}} then: |
| 3772 | + 1. Let |newOptions| be the result of running the <a>Clone Configuration</a> |
| 3773 | + algorithm with |options|. |
| 3774 | + 2. Assign `undefined` to |newOptions|.{{VideoFrameCopyToOptions/format}}. |
| 3775 | + 3. Let |rgbFrame| be the result of running the [=VideoFrame/Convert to RGB frame=] |
| 3776 | + algorithm with [=this=], |options|.{{VideoFrameCopyToOptions/format}}, |
| 3777 | + and |options|.{{VideoFrameCopyToOptions/colorSpace}}. |
| 3778 | + 4. Return the result of calling {{VideoFrame/copyTo()}} on |rgbFrame| with |
| 3779 | + |destination| and |newOptions|. |
| 3780 | + 7. Let |p| be a new {{Promise}}. |
| 3781 | + 8. Let |copyStepsQueue| be the result of starting a new [=parallel queue=]. |
| 3782 | + 9. Let |planeLayouts| be a new [=list=]. |
| 3783 | + 10. Enqueue the following steps to |copyStepsQueue|: |
3771 | 3784 | 1. Let resource be the [=media resource=] referenced by |
3772 | 3785 | [[resource reference]]. |
3773 | 3786 | 2. Let |numPlanes| be the number of planes as defined by |
|
3804 | 3817 | 10. Increment |planeIndex| by `1`. |
3805 | 3818 | 11. Append |layout| to |planeLayouts|. |
3806 | 3819 | 5. [=Queue a task=] to resolve |p| with |planeLayouts|. |
3807 | | - 10. Return |p|. |
| 3820 | + 11. Return |p|. |
3808 | 3821 |
|
3809 | 3822 | : <dfn method for=VideoFrame>clone()</dfn> |
3810 | 3823 | :: Creates a new {{VideoFrame}} with a reference to the same |
|
4048 | 4061 | 6. Let |optLayout| be `undefined`. |
4049 | 4062 | 7. If |options|.{{VideoFrameCopyToOptions/layout}} [=map/exists=], assign |
4050 | 4063 | its value to |optLayout|. |
4051 | | - 8. Let |combinedLayout| be the result of running the [=VideoFrame/Compute |
4052 | | - Layout and Allocation Size=] algorithm with |parsedRect|, |
4053 | | - {{VideoFrame/[[format]]}}, and |optLayout|. |
4054 | | - 9. Return |combinedLayout|. |
| 4064 | + 8. Let |format| be `undefined`. |
| 4065 | + 9. If |options|.{{VideoFrameCopyToOptions/format}} does not [=map/exist=], |
| 4066 | + assign {{VideoFrame/[[format]]}} to |format|. |
| 4067 | + 10. Otherwise, if |options|.{{VideoFrameCopyToOptions/format}} is equal to |
| 4068 | + one of {{RGBA}}, {{RGBX}}, {{BGRA}}, {{BGRX}}, then assign |
| 4069 | + |options|.{{VideoFrameCopyToOptions/format}} to |format|, |
| 4070 | + otherwise return {{NotSupportedError}}. |
| 4071 | + 11. Let |combinedLayout| be the result of running the [=VideoFrame/Compute |
| 4072 | + Layout and Allocation Size=] algorithm with |parsedRect|, |format|, |
| 4073 | + and |optLayout|. |
| 4074 | + 12. Return |combinedLayout|. |
4055 | 4075 |
|
4056 | 4076 | : <dfn for=VideoFrame>Verify Rect Offset Alignment</dfn> (with |format| and |
4057 | 4077 | |rect|) |
|
4183 | 4203 | [=combined buffer layout/allocationSize=]. |
4184 | 4204 | 9. Return |combinedLayout|. |
4185 | 4205 |
|
| 4206 | +: <dfn for=VideoFrame>Convert to RGB frame</dfn> (with |frame|, |format| and |colorSpace|) |
| 4207 | + :: 1. This algorithm <em class="rfc2119">MUST</em> be called only if |format| |
| 4208 | + is equal to one of {{RGBA}}, {{RGBX}}, {{BGRA}}, {{BGRX}}. |
| 4209 | + 2. Let |convertedFrame| be a new {{VideoFrame}}, constructed as follows: |
| 4210 | + 1. Assign `false` to {{platform object/[[Detached]]}}. |
| 4211 | + 2. Assign |format| to {{VideoFrame/[[format]]}}. |
| 4212 | + 3. Let |width| be |frame|'s {{VideoFrame/[[visible width]]}}. |
| 4213 | + 4. Let |height| be |frame|'s {{VideoFrame/[[visible height]]}}. |
| 4214 | + 5. Assign |width|, |height|, 0, 0, |width|, |height|, |width|, and |
| 4215 | + |height| to {{VideoFrame/[[coded width]]}}, |
| 4216 | + {{VideoFrame/[[coded height]]}}, {{VideoFrame/[[visible left]]}}, |
| 4217 | + {{VideoFrame/[[visible top]]}}, {{VideoFrame/[[visible width]]}}, |
| 4218 | + and {{VideoFrame/[[visible height]]}} respectively. |
| 4219 | + 6. Assign |frame|'s {{VideoFrame/[[duration]]}} and |frame|'s |
| 4220 | + {{VideoFrame/[[timestamp]]}} to {{VideoFrame/[[duration]]}} and |
| 4221 | + {{VideoFrame/[[timestamp]]}} respectively. |
| 4222 | + 7. Assign |colorSpace| to {{VideoFrame/[[color space]]}}. |
| 4223 | + 8. Let |resource| be a new [=media resource=] containing the result of |
| 4224 | + conversion of [=media resource=] referenced by |frame|'s |
| 4225 | + {{VideoFrame/[[resource reference]]}} into a color space and pixel |
| 4226 | + format specified by |colorSpace| and |format| respectively. |
| 4227 | + 9. Assign the reference to |resource| to {{VideoFrame/[[resource reference]]}} |
| 4228 | + 3. Return |convertedFrame|. |
| 4229 | + |
4186 | 4230 | : <dfn for=VideoFrame>Copy VideoFrame metadata</dfn> (with |metadata|) |
4187 | 4231 | :: 1. Let |metadataCopySerialized| be [$StructuredSerialize$](|metadata|). |
4188 | 4232 | 2. Let |metadataCopy| be [$StructuredDeserialize$](|metadataCopySerialized|, [=the current Realm=]). |
4189 | | - 3. return |metadataCopy|. |
| 4233 | + 3. Return |metadataCopy|. |
4190 | 4234 |
|
4191 | 4235 | The goal of this algorithm is to ensure that metadata owned by a {{VideoFrame}} is immutable. |
4192 | 4236 |
|
|
4239 | 4283 |
|
4240 | 4284 | VideoFrame CopyTo() Options {#videoframe-copyto-options} |
4241 | 4285 | ------------------------------------------------------------ |
4242 | | -Options to specify a rectangle of pixels to copy and the offset and stride of |
4243 | | -planes in the destination buffer. |
| 4286 | +Options to specify a rectangle of pixels to copy, their format, and the offset |
| 4287 | +and stride of planes in the destination buffer. |
4244 | 4288 |
|
4245 | 4289 | <xmp class='idl'> |
4246 | 4290 | dictionary VideoFrameCopyToOptions { |
4247 | 4291 | DOMRectInit rect; |
4248 | 4292 | sequence<PlaneLayout> layout; |
| 4293 | + VideoPixelFormat format; |
| 4294 | + PredefinedColorSpace colorSpace; |
4249 | 4295 | }; |
4250 | 4296 | </xmp> |
4251 | 4297 |
|
|
4273 | 4319 | to specify an offset and stride for each plane in the destination |
4274 | 4320 | {{BufferSource}}. If unspecified, the planes will be tightly packed. It is |
4275 | 4321 | invalid to specify planes that overlap. |
| 4322 | +: <dfn dict-member for=VideoFrameCopyToOptions>format</dfn> |
| 4323 | +:: A {{VideoPixelFormat}} for the pixel data in the destination |
| 4324 | + {{BufferSource}}. Potential values are: {{RGBA}}, {{RGBX}}, {{BGRA}}, |
| 4325 | + {{BGRX}}. If it does not [=map/exist=], the destination |
| 4326 | + {{BufferSource}} will be in the same format as {{VideoFrame/format}} . |
| 4327 | +: <dfn dict-member for=VideoFrameCopyToOptions>colorSpace</dfn> |
| 4328 | +:: A {{PredefinedColorSpace}} that <em class="rfc2119">MUST</em> be used as |
| 4329 | + a target color space for the pixel data in the destination |
| 4330 | + {{BufferSource}}, but only if {{VideoFrameCopyToOptions/format}} is one of |
| 4331 | + {{RGBA}}, {{RGBX}}, {{BGRA}}, {{BGRX}}, otherwise it is ignored. |
| 4332 | + If it does not [=map/exist=], {{srgb}} is used. |
| 4333 | + |
4276 | 4334 |
|
4277 | 4335 | DOMRects in VideoFrame {#videoframe-domrect} |
4278 | 4336 | -------------------------------------------- |
|
0 commit comments