Skip to content

Commit 1476a30

Browse files
authored
Merge pull request #666 from w3c/odd-coded-size
Support odd coded sizes and copy rects
2 parents 0fef16c + efda26d commit 1476a30

File tree

1 file changed

+59
-86
lines changed

1 file changed

+59
-86
lines changed

index.src.html

Lines changed: 59 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,13 +3950,8 @@
39503950
:: 1. Let |defaultRect| be the result of performing the getter steps for
39513951
{{VideoFrame/visibleRect}}.
39523952
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|.
39603955
4. Let |parsedRect| be the result of running the [=VideoFrame/Parse Visible
39613956
Rect=] algorithm with |defaultRect|, |overrideRect|,
39623957
{{VideoFrame/[[coded width]]}}, {{VideoFrame/[[coded height]]}}, and
@@ -3989,25 +3984,6 @@
39893984
8. Increment |planeIndex| by `1`.
39903985
5. Return `true`.
39913986

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-
40113987
: <dfn for=VideoFrame>Parse Visible Rect</dfn> (with |defaultRect|,
40123988
|overrideRect|, |codedWidth|, |codedHeight|, and |format|)
40133989
:: 1. Let |sourceRect| be |defaultRect|
@@ -4048,11 +4024,12 @@
40484024
|sampleBytes|.
40494025
6. Let |computedLayout| be a new [=computed plane layout=].
40504026
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.
40534029
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.
40564033
9. Set |computedLayout|'s [=computed plane layout/sourceLeftBytes=] to
40574034
the result of the integer division of
40584035
truncated |parsedRect|.{{DOMRectInit/x}} by |sampleWidthBytes|.
@@ -4227,7 +4204,7 @@
42274204
{{VideoFrame}} plane once copied to a {{BufferSource}}. A sequence of
42284205
{{PlaneLayout}}s <em class="rfc2119">MAY</em> be provided to {{VideoFrame}}'s
42294206
{{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
42314208
returned sequence of {{PlaneLayout}}s to learn the offset and stride for
42324209
planes as decided by the User Agent.
42334210

@@ -4306,25 +4283,24 @@
43064283
Each sample in this format is 8 bits.
43074284

43084285
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}}
43114288
samples.
43124289

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.
43174295

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.
43224298
</dd>
43234299
<dt><dfn enum-value for=VideoPixelFormat>I420A</dfn></dt>
43244300
<dd>
43254301

43264302
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
43284304
present in this order. It is also often refered to as Planar YUV 4:2:0 with
43294305
an alpha channel.
43304306

@@ -4333,20 +4309,19 @@
43334309

43344310
Each sample in this format is 8 bits.
43354311

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
43394315
{{VideoFrame/codedWidth}} samples.
43404316

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.
43454322

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.
43504325

43514326
{{I420A}}'s [=equivalent opaque format=] is {{I420}}.
43524327
</dd>
@@ -4362,19 +4337,18 @@
43624337

43634338
Each sample in this format is 8 bits.
43644339

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
43734343
{{VideoFrame/codedWidth}} samples.
43744344

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.
43784352
</dd>
43794353
<dt><dfn enum-value for=VideoPixelFormat>I444</dfn></dt>
43804354
<dd>
@@ -4386,10 +4360,10 @@
43864360
Each sample in this format is 8 bits. This format does not use
43874361
[=sub-sampling=].
43884362

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.
43934367
</dd>
43944368
<dt><dfn enum-value for=VideoPixelFormat>NV12</dfn></dt>
43954369
<dd>
@@ -4403,22 +4377,21 @@
44034377

44044378
Each sample in this format is 8 bits.
44054379

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.
44104384

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.
44174392

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.
44224395

44234396
<div class=example>
44244397
An image in the NV12 pixel format that is 16 pixels wide and 10 pixels tall
@@ -4455,7 +4428,7 @@
44554428

44564429
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44574430
(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
44594432
{{VideoFrame/codedWidth}} samples.
44604433

44614434
{{RGBA}}'s [=equivalent opaque format=] is {{RGBX}}.
@@ -4471,7 +4444,7 @@
44714444

44724445
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44734446
(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
44754448
{{VideoFrame/codedWidth}} samples.
44764449
</dd>
44774450
<dt><dfn enum-value for=VideoPixelFormat>BGRA</dfn></dt>
@@ -4484,7 +4457,7 @@
44844457

44854458
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44864459
(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
44884461
{{VideoFrame/codedWidth}} samples.
44894462

44904463
{{BGRA}}'s [=equivalent opaque format=] is {{BGRX}}.
@@ -4500,7 +4473,7 @@
45004473

45014474
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
45024475
(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
45044477
{{VideoFrame/codedWidth}} samples.
45054478
</dd>
45064479
</dl>

0 commit comments

Comments
 (0)