Skip to content

Commit 411ab10

Browse files
author
Dan Sanders
committed
Allow odd coded sizes
1 parent 2da7339 commit 411ab10

File tree

1 file changed

+55
-86
lines changed

1 file changed

+55
-86
lines changed

index.src.html

Lines changed: 55 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -3898,13 +3898,8 @@
38983898
:: 1. Let |defaultRect| be the result of performing the getter steps for
38993899
{{VideoFrame/visibleRect}}.
39003900
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|.
39083903
4. Let |parsedRect| be the result of running the [=VideoFrame/Parse Visible
39093904
Rect=] algorithm with |defaultRect|, |overrideRect|,
39103905
{{VideoFrame/[[coded width]]}}, {{VideoFrame/[[coded height]]}}, and
@@ -3937,25 +3932,6 @@
39373932
8. Increment |planeIndex| by `1`.
39383933
5. Return `true`.
39393934

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-
39593935
: <dfn for=VideoFrame>Parse Visible Rect</dfn> (with |defaultRect|,
39603936
|overrideRect|, |codedWidth|, |codedHeight|, and |format|)
39613937
:: 1. Let |sourceRect| be |defaultRect|
@@ -3996,11 +3972,11 @@
39963972
|sampleBytes|.
39973973
6. Let |computedLayout| be a new [=computed plane layout=].
39983974
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|.
40013977
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|.
40043980
9. Set |computedLayout|'s [=computed plane layout/sourceLeftBytes=] to
40053981
the result of the integer division of
40063982
truncated |parsedRect|.{{DOMRectInit/x}} by |sampleWidthBytes|.
@@ -4175,7 +4151,7 @@
41754151
{{VideoFrame}} plane once copied to a {{BufferSource}}. A sequence of
41764152
{{PlaneLayout}}s <em class="rfc2119">MAY</em> be provided to {{VideoFrame}}'s
41774153
{{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
41794155
returned sequence of {{PlaneLayout}}s to learn the offset and stride for
41804156
planes as decided by the User Agent.
41814157

@@ -4254,25 +4230,23 @@
42544230
Each sample in this format is 8 bits.
42554231

42564232
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}}
42594235
samples.
42604236

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

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.
42704244
</dd>
42714245
<dt><dfn enum-value for=VideoPixelFormat>I420A</dfn></dt>
42724246
<dd>
42734247

42744248
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
42764250
present in this order. It is also often refered to as Planar YUV 4:2:0 with
42774251
an alpha channel.
42784252

@@ -4281,20 +4255,18 @@
42814255

42824256
Each sample in this format is 8 bits.
42834257

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
42874261
{{VideoFrame/codedWidth}} samples.
42884262

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

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

42994271
{{I420A}}'s [=equivalent opaque format=] is {{I420}}.
43004272
</dd>
@@ -4310,19 +4282,18 @@
43104282

43114283
Each sample in this format is 8 bits.
43124284

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
43214288
{{VideoFrame/codedWidth}} samples.
43224289

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.
43264297
</dd>
43274298
<dt><dfn enum-value for=VideoPixelFormat>I444</dfn></dt>
43284299
<dd>
@@ -4334,10 +4305,10 @@
43344305
Each sample in this format is 8 bits. This format does not use
43354306
[=sub-sampling=].
43364307

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.
43414312
</dd>
43424313
<dt><dfn enum-value for=VideoPixelFormat>NV12</dfn></dt>
43434314
<dd>
@@ -4351,22 +4322,20 @@
43514322

43524323
Each sample in this format is 8 bits.
43534324

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

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

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

43714340
<div class=example>
43724341
An image in the NV12 pixel format that is 16 pixels wide and 10 pixels tall
@@ -4403,7 +4372,7 @@
44034372

44044373
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44054374
(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
44074376
{{VideoFrame/codedWidth}} samples.
44084377

44094378
{{RGBA}}'s [=equivalent opaque format=] is {{RGBX}}.
@@ -4419,7 +4388,7 @@
44194388

44204389
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44214390
(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
44234392
{{VideoFrame/codedWidth}} samples.
44244393
</dd>
44254394
<dt><dfn enum-value for=VideoPixelFormat>BGRA</dfn></dt>
@@ -4432,7 +4401,7 @@
44324401

44334402
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44344403
(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
44364405
{{VideoFrame/codedWidth}} samples.
44374406

44384407
{{BGRA}}'s [=equivalent opaque format=] is {{BGRX}}.
@@ -4448,7 +4417,7 @@
44484417

44494418
There are {{VideoFrame/codedWidth}} * {{VideoFrame/codedHeight}} * 4 samples
44504419
(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
44524421
{{VideoFrame/codedWidth}} samples.
44534422
</dd>
44544423
</dl>

0 commit comments

Comments
 (0)