|
3898 | 3898 | :: 1. Let |defaultRect| be the result of performing the getter steps for |
3899 | 3899 | {{VideoFrame/visibleRect}}. |
3900 | 3900 | 2. Let |overrideRect| be `undefined`. |
3901 | | - 3. If |options|.{{VideoFrameCopyToOptions/rect}} [=map/exists=]: |
3902 | | - 1. Assign the value of |options|.{{VideoFrameCopyToOptions/rect}} to |
3903 | | - |overrideRect|. |
3904 | | - 2. Let |validAlignment| be the result of running the |
3905 | | - [=VideoFrame/Verify Rect Size Alignment=] algorithm with |
3906 | | - |overrideRect| and {{VideoFrame/[[format]]}}. |
3907 | | - 3. If |validAlignment| is `false`, throw a {{TypeError}}. |
| 3901 | + 3. If |options|.{{VideoFrameCopyToOptions/rect}} [=map/exists=], assign the |
| 3902 | + value of |options|.{{VideoFrameCopyToOptions/rect}} to |overrideRect|. |
3908 | 3903 | 4. Let |parsedRect| be the result of running the [=VideoFrame/Parse Visible |
3909 | 3904 | Rect=] algorithm with |defaultRect|, |overrideRect|, |
3910 | 3905 | {{VideoFrame/[[coded width]]}}, {{VideoFrame/[[coded height]]}}, and |
|
3937 | 3932 | 8. Increment |planeIndex| by `1`. |
3938 | 3933 | 5. Return `true`. |
3939 | 3934 |
|
3940 | | -: <dfn for=VideoFrame>Verify Rect Size Alignment</dfn> (with |format| and |
3941 | | - |rect|) |
3942 | | -:: 1. If |format| is `null`, return `true`. |
3943 | | - 2. Let |planeIndex| be `0`. |
3944 | | - 3. Let |numPlanes| be the number of planes as defined by |format|. |
3945 | | - 4. While |planeIndex| is less than |numPlanes|: |
3946 | | - 1. Let |plane| be the Plane identified by |planeIndex| as defined by |
3947 | | - |format|. |
3948 | | - 2. Let |sampleWidth| be the horizontal [=sub-sampling factor=] of each |
3949 | | - subsample for |plane|. |
3950 | | - 3. Let |sampleHeight| be the vertical [=sub-sampling factor=] of each |
3951 | | - subsample for |plane|. |
3952 | | - 6. If |rect|.{{DOMRectReadOnly/width}} is not a multiple of |
3953 | | - |sampleWidth|, return `false`. |
3954 | | - 7. If |rect|.{{DOMRectReadOnly/height}} is not a multiple of |
3955 | | - |sampleHeight|, return `false`. |
3956 | | - 8. Increment |planeIndex| by `1`. |
3957 | | - 5. Return `true`. |
3958 | | - |
3959 | 3935 | : <dfn for=VideoFrame>Parse Visible Rect</dfn> (with |defaultRect|, |
3960 | 3936 | |overrideRect|, |codedWidth|, |codedHeight|, and |format|) |
3961 | 3937 | :: 1. Let |sourceRect| be |defaultRect| |
|
3996 | 3972 | |sampleBytes|. |
3997 | 3973 | 6. Let |computedLayout| be a new [=computed plane layout=]. |
3998 | 3974 | 7. Set |computedLayout|'s [=computed plane layout/sourceTop=] to the |
3999 | | - result of the integer division of |
4000 | | - truncated |parsedRect|.{{DOMRectInit/y}} by |sampleHeight|. |
| 3975 | + ceiling of the division of truncated |parsedRect|.{{DOMRectInit/y}} |
| 3976 | + by |sampleHeight|. |
4001 | 3977 | 8. Set |computedLayout|'s [=computed plane layout/sourceHeight=] to the |
4002 | | - result of the integer division of |
4003 | | - truncated |parsedRect|.{{DOMRectInit/height}} by |sampleHeight| |
| 3978 | + ceiling of the division of truncated |
| 3979 | + |parsedRect|.{{DOMRectInit/height}} by |sampleHeight|. |
4004 | 3980 | 9. Set |computedLayout|'s [=computed plane layout/sourceLeftBytes=] to |
4005 | 3981 | the result of the integer division of |
4006 | 3982 | truncated |parsedRect|.{{DOMRectInit/x}} by |sampleWidthBytes|. |
|
4175 | 4151 | {{VideoFrame}} plane once copied to a {{BufferSource}}. A sequence of |
4176 | 4152 | {{PlaneLayout}}s <em class="rfc2119">MAY</em> be provided to {{VideoFrame}}'s |
4177 | 4153 | {{VideoFrame/copyTo()}} to specify how the plane is laid out in the destination |
4178 | | -{{BufferSource}}}. Alternatively, callers can inspect {{VideoFrame/copyTo()}}'s |
| 4154 | +{{BufferSource}}. Alternatively, callers can inspect {{VideoFrame/copyTo()}}'s |
4179 | 4155 | returned sequence of {{PlaneLayout}}s to learn the offset and stride for |
4180 | 4156 | planes as decided by the User Agent. |
4181 | 4157 |
|
|
4254 | 4230 | Each sample in this format is 8 bits. |
4255 | 4231 |
|
4256 | 4232 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
4257 | | - (and therefore bytes) in the Y plane, arranged starting at the top left in |
4258 | | - the image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
| 4233 | + (and therefore bytes) in the Y plane, arranged starting at the top left of |
| 4234 | + the image, in {{VideoFrame/codedHeight}} rows of {{VideoFrame/codedWidth}} |
4259 | 4235 | samples. |
4260 | 4236 |
|
4261 | | - There is {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 4 samples |
4262 | | - (and therefore bytes) in the two U and V planes, arranged starting at the |
4263 | | - top left in the image, in {{VideoFrame/codedHeight}} / 2 lines of |
4264 | | - {{VideoFrame/codedWidth}} / 2 samples. |
| 4237 | + The U and V planes have a number of rows equal to the ceiling of the |
| 4238 | + division of {{VideoFrame/codedHeight}} by 2. Each row has a number of |
| 4239 | + samples equal to the ceiling of the division of {{VideoFrame/codedWidth}} by |
| 4240 | + 2. Samples are arranged starting at the top left of the image. |
4265 | 4241 |
|
4266 | | - The {{VideoFrame/codedWidth}} and {{VideoFrame/codedHeight}} MUST be even. |
4267 | | - Similarly, the visible rectangle offset |
4268 | | - ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4269 | | - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4242 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} |
| 4243 | + and {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
4270 | 4244 | </dd> |
4271 | 4245 | <dt><dfn enum-value for=VideoPixelFormat>I420A</dfn></dt> |
4272 | 4246 | <dd> |
4273 | 4247 |
|
4274 | 4248 | This format is composed of four distinct planes, one plane of Luma, two |
4275 | | - planes of Chroma, denoted Y, U and V, and one place of alpha values, all |
| 4249 | + planes of Chroma, denoted Y, U and V, and one plane of alpha values, all |
4276 | 4250 | present in this order. It is also often refered to as Planar YUV 4:2:0 with |
4277 | 4251 | an alpha channel. |
4278 | 4252 |
|
|
4281 | 4255 |
|
4282 | 4256 | Each sample in this format is 8 bits. |
4283 | 4257 |
|
4284 | | - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4285 | | - therefore bytes) in the Y and alpha plane, arranged starting at the top left |
4286 | | - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4258 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4259 | + (and therefore bytes) in the Y and alpha planes, arranged starting at the |
| 4260 | + top left of the image, in {{VideoFrame/codedHeight}} rows of |
4287 | 4261 | {{VideoFrame/codedWidth}} samples. |
4288 | 4262 |
|
4289 | | - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 4 samples |
4290 | | - (and therefore bytes) in the two U and V planes, arranged starting at the |
4291 | | - top left in the image, in {{VideoFrame/codedHeight}} / 2 lines of |
4292 | | - {{VideoFrame/codedWidth}} / 2 samples. |
| 4263 | + The U and V planes have a number of rows equal to the ceiling of the |
| 4264 | + division of {{VideoFrame/codedHeight}} by 2. Each row has a number of |
| 4265 | + samples equal to the ceiling of the division of {{VideoFrame/codedWidth}} by |
| 4266 | + 2. Samples are arranged starting at the top left of the image. |
4293 | 4267 |
|
4294 | | - The {{VideoFrame/codedWidth}} and {{VideoFrame/codedHeight}} MUST be even. |
4295 | | - Similarly, the visible rectangle offset |
4296 | | - ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4297 | | - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4268 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} |
| 4269 | + and {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
4298 | 4270 |
|
4299 | 4271 | {{I420A}}'s [=equivalent opaque format=] is {{I420}}. |
4300 | 4272 | </dd> |
|
4310 | 4282 |
|
4311 | 4283 | Each sample in this format is 8 bits. |
4312 | 4284 |
|
4313 | | - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4314 | | - therefore bytes) in the Y plane, arranged starting at the top left in the |
4315 | | - image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
4316 | | - samples. |
4317 | | - |
4318 | | - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 2 samples |
4319 | | - (and therefore bytes) in the two U and V planes, arranged starting at the |
4320 | | - top left in the image, in {{VideoFrame/codedHeight}} / 2 lines of |
| 4285 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4286 | + (and therefore bytes) in the Y and plane, arranged starting at the top left |
| 4287 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4321 | 4288 | {{VideoFrame/codedWidth}} samples. |
4322 | 4289 |
|
4323 | | - The {{VideoFrame/codedHeight}} MUST be even. Similarly, the visible |
4324 | | - rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4325 | | - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4290 | + The U and V planes have {{VideoFrame/codedHeight}} rows. Each row has a |
| 4291 | + number of samples equal to the ceiling of the division of |
| 4292 | + {{VideoFrame/codedWidth}} by 2. Samples are arranged starting at the top |
| 4293 | + left of the image. |
| 4294 | + |
| 4295 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}}) |
| 4296 | + MUST be even. |
4326 | 4297 | </dd> |
4327 | 4298 | <dt><dfn enum-value for=VideoPixelFormat>I444</dfn></dt> |
4328 | 4299 | <dd> |
|
4334 | 4305 | Each sample in this format is 8 bits. This format does not use |
4335 | 4306 | [=sub-sampling=]. |
4336 | 4307 |
|
4337 | | - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4338 | | - therefore bytes) in all three planes, arranged starting at the top left in the |
4339 | | - image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
4340 | | - samples. |
| 4308 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4309 | + (and therefore bytes) in all three planes, arranged starting at the top left |
| 4310 | + of the image, in {{VideoFrame/codedHeight}} rows of |
| 4311 | + {{VideoFrame/codedWidth}} samples. |
4341 | 4312 | </dd> |
4342 | 4313 | <dt><dfn enum-value for=VideoPixelFormat>NV12</dfn></dt> |
4343 | 4314 | <dd> |
|
4351 | 4322 |
|
4352 | 4323 | Each sample in this format is 8 bits. |
4353 | 4324 |
|
4354 | | - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4355 | | - therefore bytes) in the Y plane, arranged starting at the top left in the |
4356 | | - image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
4357 | | - samples. |
| 4325 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4326 | + (and therefore bytes) in the Y and plane, arranged starting at the top left |
| 4327 | + of the image, in {{VideoFrame/codedHeight}} rows of |
| 4328 | + {{VideoFrame/codedWidth}} samples. |
4358 | 4329 |
|
4359 | | - The UV planes is composed of interleaved U and V values, in |
4360 | | - {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 4 elements (of two |
4361 | | - bytes each), arranged starting at the top left in the image, in |
4362 | | - {{VideoFrame/codedHeight}} / 2 lines of {{VideoFrame/codedWidth}} / 2 |
4363 | | - elements. Each element is composed of a two Chroma values, the U and V |
4364 | | - value, in this order. |
| 4330 | + The UV plane is composed of interleaved U and V values, in a number of |
| 4331 | + rows equal to the ceiling of the division of {{VideoFrame/codedHeight}} by |
| 4332 | + 2. Each row has a number of elements equal to the ceiling of the division of |
| 4333 | + {{VideoFrame/codedWidth}} by 2. Each element is composed of two chroma |
| 4334 | + samples, the U and V samples, in that order. Samples are arranged starting |
| 4335 | + at the top left of the image. |
4365 | 4336 |
|
4366 | | - The {{VideoFrame/codedWidth}} and {{VideoFrame/codedHeight}} MUST be even. |
4367 | | - Similarly, the visible rectangle offset |
4368 | | - ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4369 | | - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4337 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} |
| 4338 | + and {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
4370 | 4339 |
|
4371 | 4340 | <div class=example> |
4372 | 4341 | An image in the NV12 pixel format that is 16 pixels wide and 10 pixels tall |
|
4403 | 4372 |
|
4404 | 4373 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples |
4405 | 4374 | (and therefore bytes) in the single plane, arranged starting at the top |
4406 | | - left in the image, in {{VideoFrame/codedHeight}} lines of |
| 4375 | + left of the image, in {{VideoFrame/codedHeight}} rows of |
4407 | 4376 | {{VideoFrame/codedWidth}} samples. |
4408 | 4377 |
|
4409 | 4378 | {{RGBA}}'s [=equivalent opaque format=] is {{RGBX}}. |
|
4419 | 4388 |
|
4420 | 4389 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples |
4421 | 4390 | (and therefore bytes) in the single plane, arranged starting at the top left |
4422 | | - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4391 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4423 | 4392 | {{VideoFrame/codedWidth}} samples. |
4424 | 4393 | </dd> |
4425 | 4394 | <dt><dfn enum-value for=VideoPixelFormat>BGRA</dfn></dt> |
|
4432 | 4401 |
|
4433 | 4402 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples |
4434 | 4403 | (and therefore bytes) in the single plane, arranged starting at the top left |
4435 | | - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4404 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4436 | 4405 | {{VideoFrame/codedWidth}} samples. |
4437 | 4406 |
|
4438 | 4407 | {{BGRA}}'s [=equivalent opaque format=] is {{BGRX}}. |
|
4448 | 4417 |
|
4449 | 4418 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples |
4450 | 4419 | (and therefore bytes) in the single plane, arranged starting at the top left |
4451 | | - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4420 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4452 | 4421 | {{VideoFrame/codedWidth}} samples. |
4453 | 4422 | </dd> |
4454 | 4423 | </dl> |
|
0 commit comments