|
3950 | 3950 | :: 1. Let |defaultRect| be the result of performing the getter steps for
|
3951 | 3951 | {{VideoFrame/visibleRect}}.
|
3952 | 3952 | 2. Let |overrideRect| be `undefined`.
|
3953 |
| - 3. If |options|.{{VideoFrameCopyToOptions/rect}} [=map/exists=]: |
3954 |
| - 1. Assign the value of |options|.{{VideoFrameCopyToOptions/rect}} to |
3955 |
| - |overrideRect|. |
3956 |
| - 2. Let |validAlignment| be the result of running the |
3957 |
| - [=VideoFrame/Verify Rect Size Alignment=] algorithm with |
3958 |
| - |overrideRect| and {{VideoFrame/[[format]]}}. |
3959 |
| - 3. If |validAlignment| is `false`, throw a {{TypeError}}. |
| 3953 | + 3. If |options|.{{VideoFrameCopyToOptions/rect}} [=map/exists=], assign the |
| 3954 | + value of |options|.{{VideoFrameCopyToOptions/rect}} to |overrideRect|. |
3960 | 3955 | 4. Let |parsedRect| be the result of running the [=VideoFrame/Parse Visible
|
3961 | 3956 | Rect=] algorithm with |defaultRect|, |overrideRect|,
|
3962 | 3957 | {{VideoFrame/[[coded width]]}}, {{VideoFrame/[[coded height]]}}, and
|
|
3989 | 3984 | 8. Increment |planeIndex| by `1`.
|
3990 | 3985 | 5. Return `true`.
|
3991 | 3986 |
|
3992 |
| -: <dfn for=VideoFrame>Verify Rect Size Alignment</dfn> (with |format| and |
3993 |
| - |rect|) |
3994 |
| -:: 1. If |format| is `null`, return `true`. |
3995 |
| - 2. Let |planeIndex| be `0`. |
3996 |
| - 3. Let |numPlanes| be the number of planes as defined by |format|. |
3997 |
| - 4. While |planeIndex| is less than |numPlanes|: |
3998 |
| - 1. Let |plane| be the Plane identified by |planeIndex| as defined by |
3999 |
| - |format|. |
4000 |
| - 2. Let |sampleWidth| be the horizontal [=sub-sampling factor=] of each |
4001 |
| - subsample for |plane|. |
4002 |
| - 3. Let |sampleHeight| be the vertical [=sub-sampling factor=] of each |
4003 |
| - subsample for |plane|. |
4004 |
| - 6. If |rect|.{{DOMRectReadOnly/width}} is not a multiple of |
4005 |
| - |sampleWidth|, return `false`. |
4006 |
| - 7. If |rect|.{{DOMRectReadOnly/height}} is not a multiple of |
4007 |
| - |sampleHeight|, return `false`. |
4008 |
| - 8. Increment |planeIndex| by `1`. |
4009 |
| - 5. Return `true`. |
4010 |
| - |
4011 | 3987 | : <dfn for=VideoFrame>Parse Visible Rect</dfn> (with |defaultRect|,
|
4012 | 3988 | |overrideRect|, |codedWidth|, |codedHeight|, and |format|)
|
4013 | 3989 | :: 1. Let |sourceRect| be |defaultRect|
|
|
4048 | 4024 | |sampleBytes|.
|
4049 | 4025 | 6. Let |computedLayout| be a new [=computed plane layout=].
|
4050 | 4026 | 7. Set |computedLayout|'s [=computed plane layout/sourceTop=] to the
|
4051 |
| - result of the integer division of |
4052 |
| - truncated |parsedRect|.{{DOMRectInit/y}} by |sampleHeight|. |
| 4027 | + result of the division of truncated |parsedRect|.{{DOMRectInit/y}} |
| 4028 | + by |sampleHeight|, rounded up to the nearest integer. |
4053 | 4029 | 8. Set |computedLayout|'s [=computed plane layout/sourceHeight=] to the
|
4054 |
| - result of the integer division of |
4055 |
| - truncated |parsedRect|.{{DOMRectInit/height}} by |sampleHeight| |
| 4030 | + result of the division of truncated |
| 4031 | + |parsedRect|.{{DOMRectInit/height}} by |sampleHeight|, rounded up |
| 4032 | + to the nearest integer. |
4056 | 4033 | 9. Set |computedLayout|'s [=computed plane layout/sourceLeftBytes=] to
|
4057 | 4034 | the result of the integer division of
|
4058 | 4035 | truncated |parsedRect|.{{DOMRectInit/x}} by |sampleWidthBytes|.
|
|
4227 | 4204 | {{VideoFrame}} plane once copied to a {{BufferSource}}. A sequence of
|
4228 | 4205 | {{PlaneLayout}}s <em class="rfc2119">MAY</em> be provided to {{VideoFrame}}'s
|
4229 | 4206 | {{VideoFrame/copyTo()}} to specify how the plane is laid out in the destination
|
4230 |
| -{{BufferSource}}}. Alternatively, callers can inspect {{VideoFrame/copyTo()}}'s |
| 4207 | +{{BufferSource}}. Alternatively, callers can inspect {{VideoFrame/copyTo()}}'s |
4231 | 4208 | returned sequence of {{PlaneLayout}}s to learn the offset and stride for
|
4232 | 4209 | planes as decided by the User Agent.
|
4233 | 4210 |
|
|
4306 | 4283 | Each sample in this format is 8 bits.
|
4307 | 4284 |
|
4308 | 4285 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples
|
4309 |
| - (and therefore bytes) in the Y plane, arranged starting at the top left in |
4310 |
| - the image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
| 4286 | + (and therefore bytes) in the Y plane, arranged starting at the top left of |
| 4287 | + the image, in {{VideoFrame/codedHeight}} rows of {{VideoFrame/codedWidth}} |
4311 | 4288 | samples.
|
4312 | 4289 |
|
4313 |
| - There is {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 4 samples |
4314 |
| - (and therefore bytes) in the two U and V planes, arranged starting at the |
4315 |
| - top left in the image, in {{VideoFrame/codedHeight}} / 2 lines of |
4316 |
| - {{VideoFrame/codedWidth}} / 2 samples. |
| 4290 | + The U and V planes have a number of rows equal to the result of the |
| 4291 | + division of {{VideoFrame/codedHeight}} by 2, rounded up to the nearest |
| 4292 | + integer. Each row has a number of samples equal to the result of the |
| 4293 | + division of {{VideoFrame/codedWidth}} by 2, rounded up to the nearest |
| 4294 | + integer. Samples are arranged starting at the top left of the image. |
4317 | 4295 |
|
4318 |
| - The {{VideoFrame/codedWidth}} and {{VideoFrame/codedHeight}} MUST be even. |
4319 |
| - Similarly, the visible rectangle offset |
4320 |
| - ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4321 |
| - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4296 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} |
| 4297 | + and {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
4322 | 4298 | </dd>
|
4323 | 4299 | <dt><dfn enum-value for=VideoPixelFormat>I420A</dfn></dt>
|
4324 | 4300 | <dd>
|
4325 | 4301 |
|
4326 | 4302 | This format is composed of four distinct planes, one plane of Luma, two
|
4327 |
| - planes of Chroma, denoted Y, U and V, and one place of alpha values, all |
| 4303 | + planes of Chroma, denoted Y, U and V, and one plane of alpha values, all |
4328 | 4304 | present in this order. It is also often refered to as Planar YUV 4:2:0 with
|
4329 | 4305 | an alpha channel.
|
4330 | 4306 |
|
|
4333 | 4309 |
|
4334 | 4310 | Each sample in this format is 8 bits.
|
4335 | 4311 |
|
4336 |
| - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4337 |
| - therefore bytes) in the Y and alpha plane, arranged starting at the top left |
4338 |
| - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4312 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4313 | + (and therefore bytes) in the Y and alpha planes, arranged starting at the |
| 4314 | + top left of the image, in {{VideoFrame/codedHeight}} rows of |
4339 | 4315 | {{VideoFrame/codedWidth}} samples.
|
4340 | 4316 |
|
4341 |
| - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 4 samples |
4342 |
| - (and therefore bytes) in the two U and V planes, arranged starting at the |
4343 |
| - top left in the image, in {{VideoFrame/codedHeight}} / 2 lines of |
4344 |
| - {{VideoFrame/codedWidth}} / 2 samples. |
| 4317 | + The U and V planes have a number of rows equal to the result of the |
| 4318 | + division of {{VideoFrame/codedHeight}} by 2, rounded up to the nearest |
| 4319 | + integer. Each row has a number of samples equal to the result of the |
| 4320 | + division of {{VideoFrame/codedWidth}} by 2, rounded up to the nearest |
| 4321 | + integer. Samples are arranged starting at the top left of the image. |
4345 | 4322 |
|
4346 |
| - The {{VideoFrame/codedWidth}} and {{VideoFrame/codedHeight}} MUST be even. |
4347 |
| - Similarly, the visible rectangle offset |
4348 |
| - ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4349 |
| - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4323 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} |
| 4324 | + and {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
4350 | 4325 |
|
4351 | 4326 | {{I420A}}'s [=equivalent opaque format=] is {{I420}}.
|
4352 | 4327 | </dd>
|
|
4362 | 4337 |
|
4363 | 4338 | Each sample in this format is 8 bits.
|
4364 | 4339 |
|
4365 |
| - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4366 |
| - therefore bytes) in the Y plane, arranged starting at the top left in the |
4367 |
| - image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
4368 |
| - samples. |
4369 |
| - |
4370 |
| - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 2 samples |
4371 |
| - (and therefore bytes) in the two U and V planes, arranged starting at the |
4372 |
| - top left in the image, in {{VideoFrame/codedHeight}} / 2 lines of |
| 4340 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4341 | + (and therefore bytes) in the Y and plane, arranged starting at the top left |
| 4342 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4373 | 4343 | {{VideoFrame/codedWidth}} samples.
|
4374 | 4344 |
|
4375 |
| - The {{VideoFrame/codedHeight}} MUST be even. Similarly, the visible |
4376 |
| - rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4377 |
| - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4345 | + The U and V planes have {{VideoFrame/codedHeight}} rows. Each row has a |
| 4346 | + number of samples equal to the result of the division of |
| 4347 | + {{VideoFrame/codedWidth}} by 2, rounded up to the nearest integer. Samples |
| 4348 | + are arranged starting at the top left of the image. |
| 4349 | + |
| 4350 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}}) |
| 4351 | + MUST be even. |
4378 | 4352 | </dd>
|
4379 | 4353 | <dt><dfn enum-value for=VideoPixelFormat>I444</dfn></dt>
|
4380 | 4354 | <dd>
|
|
4386 | 4360 | Each sample in this format is 8 bits. This format does not use
|
4387 | 4361 | [=sub-sampling=].
|
4388 | 4362 |
|
4389 |
| - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4390 |
| - therefore bytes) in all three planes, arranged starting at the top left in the |
4391 |
| - image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
4392 |
| - samples. |
| 4363 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4364 | + (and therefore bytes) in all three planes, arranged starting at the top left |
| 4365 | + of the image, in {{VideoFrame/codedHeight}} rows of |
| 4366 | + {{VideoFrame/codedWidth}} samples. |
4393 | 4367 | </dd>
|
4394 | 4368 | <dt><dfn enum-value for=VideoPixelFormat>NV12</dfn></dt>
|
4395 | 4369 | <dd>
|
|
4403 | 4377 |
|
4404 | 4378 | Each sample in this format is 8 bits.
|
4405 | 4379 |
|
4406 |
| - There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples (and |
4407 |
| - therefore bytes) in the Y plane, arranged starting at the top left in the |
4408 |
| - image, in {{VideoFrame/codedHeight}} lines of {{VideoFrame/codedWidth}} |
4409 |
| - samples. |
| 4380 | + There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} samples |
| 4381 | + (and therefore bytes) in the Y and plane, arranged starting at the top left |
| 4382 | + of the image, in {{VideoFrame/codedHeight}} rows of |
| 4383 | + {{VideoFrame/codedWidth}} samples. |
4410 | 4384 |
|
4411 |
| - The UV planes is composed of interleaved U and V values, in |
4412 |
| - {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} / 4 elements (of two |
4413 |
| - bytes each), arranged starting at the top left in the image, in |
4414 |
| - {{VideoFrame/codedHeight}} / 2 lines of {{VideoFrame/codedWidth}} / 2 |
4415 |
| - elements. Each element is composed of a two Chroma values, the U and V |
4416 |
| - value, in this order. |
| 4385 | + The UV plane is composed of interleaved U and V values, in a number of |
| 4386 | + rows equal to the result of the division of {{VideoFrame/codedHeight}} |
| 4387 | + by 2, rounded up to the nearest integer. Each row has a number of elements |
| 4388 | + equal to the result of the division of {{VideoFrame/codedWidth}} by 2, |
| 4389 | + rounded up to the nearest integer. Each element is composed of two Chroma |
| 4390 | + samples, the U and V samples, in that order. Samples are arranged starting |
| 4391 | + at the top left of the image. |
4417 | 4392 |
|
4418 |
| - The {{VideoFrame/codedWidth}} and {{VideoFrame/codedHeight}} MUST be even. |
4419 |
| - Similarly, the visible rectangle offset |
4420 |
| - ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} and |
4421 |
| - {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
| 4393 | + The visible rectangle offset ({{VideoFrame/visibleRect}}.{{DOMRectInit/x}} |
| 4394 | + and {{VideoFrame/visibleRect}}.{{DOMRectInit/y}}) MUST be even. |
4422 | 4395 |
|
4423 | 4396 | <div class=example>
|
4424 | 4397 | An image in the NV12 pixel format that is 16 pixels wide and 10 pixels tall
|
|
4455 | 4428 |
|
4456 | 4429 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
|
4457 | 4430 | (and therefore bytes) in the single plane, arranged starting at the top
|
4458 |
| - left in the image, in {{VideoFrame/codedHeight}} lines of |
| 4431 | + left of the image, in {{VideoFrame/codedHeight}} rows of |
4459 | 4432 | {{VideoFrame/codedWidth}} samples.
|
4460 | 4433 |
|
4461 | 4434 | {{RGBA}}'s [=equivalent opaque format=] is {{RGBX}}.
|
|
4471 | 4444 |
|
4472 | 4445 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
|
4473 | 4446 | (and therefore bytes) in the single plane, arranged starting at the top left
|
4474 |
| - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4447 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4475 | 4448 | {{VideoFrame/codedWidth}} samples.
|
4476 | 4449 | </dd>
|
4477 | 4450 | <dt><dfn enum-value for=VideoPixelFormat>BGRA</dfn></dt>
|
|
4484 | 4457 |
|
4485 | 4458 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
|
4486 | 4459 | (and therefore bytes) in the single plane, arranged starting at the top left
|
4487 |
| - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4460 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4488 | 4461 | {{VideoFrame/codedWidth}} samples.
|
4489 | 4462 |
|
4490 | 4463 | {{BGRA}}'s [=equivalent opaque format=] is {{BGRX}}.
|
|
4500 | 4473 |
|
4501 | 4474 | There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
|
4502 | 4475 | (and therefore bytes) in the single plane, arranged starting at the top left
|
4503 |
| - in the image, in {{VideoFrame/codedHeight}} lines of |
| 4476 | + of the image, in {{VideoFrame/codedHeight}} rows of |
4504 | 4477 | {{VideoFrame/codedWidth}} samples.
|
4505 | 4478 | </dd>
|
4506 | 4479 | </dl>
|
|
0 commit comments