Skip to content

Commit 050ec9d

Browse files
committed
Add VideoFrameBufferInit.transfer
1 parent 3a96dbd commit 050ec9d

File tree

1 file changed

+44
-29
lines changed

1 file changed

+44
-29
lines changed

index.src.html

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3277,6 +3277,8 @@
32773277
[EnforceRange] unsigned long displayHeight;
32783278

32793279
VideoColorSpaceInit colorSpace;
3280+
3281+
sequence<ArrayBuffer> transfer = [];
32803282
};
32813283

32823284
dictionary VideoFrameMetadata {
@@ -3415,29 +3417,39 @@
34153417
VideoFrame(data, init)
34163418
</dfn>
34173419
1. If |init| is not a [=valid VideoFrameBufferInit=], throw a {{TypeError}}.
3418-
2. Let |defaultRect| be «[ "x:" → `0`, "y" → `0`,
3420+
1. Let |defaultRect| be «[ "x:" → `0`, "y" → `0`,
34193421
"width" → |init|.{{VideoFrameBufferInit/codedWidth}}, "height" →
34203422
|init|.{{VideoFrameBufferInit/codedWidth}} ]».
3421-
3. Let |overrideRect| be `undefined`.
3422-
4. If |init|.{{VideoFrameBufferInit/visibleRect}} [=map/exists=], assign its
3423+
1. Let |overrideRect| be `undefined`.
3424+
1. If |init|.{{VideoFrameBufferInit/visibleRect}} [=map/exists=], assign its
34233425
value to |overrideRect|.
3424-
4. Let |parsedRect| be the result of running the [=VideoFrame/Parse Visible
3426+
1. Let |parsedRect| be the result of running the [=VideoFrame/Parse Visible
34253427
Rect=] algorithm with |defaultRect|, |overrideRect|,
34263428
|init|.{{VideoFrameBufferInit/codedWidth}},
34273429
|init|.{{VideoFrameBufferInit/codedHeight}}, and
34283430
|init|.{{VideoFrameBufferInit/format}}.
3429-
5. If |parsedRect| is an exception, return |parsedRect|.
3430-
6. Let |optLayout| be `undefined`.
3431-
7. If |options|.{{VideoFrameBufferInit/layout}} [=map/exists=], assign its value
3431+
1. If |parsedRect| is an exception, return |parsedRect|.
3432+
1. Let |optLayout| be `undefined`.
3433+
1. If |options|.{{VideoFrameBufferInit/layout}} [=map/exists=], assign its value
34323434
to |optLayout|.
3433-
8. Let |combinedLayout| be the result of running the [=VideoFrame/Compute
3435+
1. Let |combinedLayout| be the result of running the [=VideoFrame/Compute
34343436
Layout and Allocation Size=] algorithm with |parsedRect|,
34353437
|init|.{{VideoFrameBufferInit/format}}, and |optLayout|.
3436-
9. If |combinedLayout| is an exception, throw |combinedLayout|.
3437-
10. If `data.byteLength` is less than |combinedLayout|’s
3438+
1. If |combinedLayout| is an exception, throw |combinedLayout|.
3439+
1. If `data.byteLength` is less than |combinedLayout|’s
34383440
[=combined buffer layout/allocationSize=], throw a {{TypeError}}.
3439-
11. Let |resource| be a new [=media resource=] containing a copy of |data|. Use
3440-
{{VideoFrameBufferInit/visibleRect}} and {{VideoFrameBufferInit/layout}}
3441+
1. For each |transferable| in |init|.{{VideoFrameBufferInit/transfer}}:
3442+
1. If {{platform object/[[Detached]]}} internal slot is `true`,
3443+
then throw a {{DataCloneError}} {{DOMException}}.
3444+
1. If |init|.{{VideoFrameBufferInit/transfer}} contains an ArrayBuffer referenced
3445+
by |data|:
3446+
1. Let |resource| be a new [=media resource=] referencing pixels in |data|
3447+
without a copy.
3448+
Use {{VideoFrameBufferInit/visibleRect}} and {{VideoFrameBufferInit/layout}}
3449+
to determine where in |data| the pixels for each plane reside.
3450+
1. Otherwise:
3451+
1. Let |resource| be a new [=media resource=] containing a copy of |data|.
3452+
Use {{VideoFrameBufferInit/visibleRect}} and {{VideoFrameBufferInit/layout}}
34413453
to determine where in |data| the pixels for each plane reside.
34423454

34433455
The User Agent <em class="rfc2119">MAY</em> choose to allocate
@@ -3449,55 +3461,58 @@
34493461
reposition the visible rectangle within |resource|. The final position
34503462
will be reflected by {{VideoFrame/visibleRect}}.
34513463

3452-
12. Let |resourceCodedWidth| be the coded width of |resource|.
3453-
13. Let |resourceCodedHeight| be the coded height of |resource|.
3454-
14. Let |resourceVisibleLeft| be the left offset for the visible rectangle of
3464+
1. For each |transferable| in |init|.{{VideoFrameBufferInit/transfer}}:
3465+
1. Perform [DetachArrayBuffer](https://tc39.es/ecma262/#sec-detacharraybuffer)
3466+
on |transferable|
3467+
1. Let |resourceCodedWidth| be the coded width of |resource|.
3468+
1. Let |resourceCodedHeight| be the coded height of |resource|.
3469+
1. Let |resourceVisibleLeft| be the left offset for the visible rectangle of
34553470
|resource|.
3456-
15. Let |resourceVisibleTop| be the top offset for the visible rectangle of
3471+
1. Let |resourceVisibleTop| be the top offset for the visible rectangle of
34573472
|resource|.
34583473

34593474
ISSUE: The spec <em class="rfc2119">SHOULD</em> provide definitions (and
34603475
possibly diagrams) for coded size, visible rectangle, and display size.
34613476
See [#166](https://github.com/w3c/webcodecs/issues/166).
34623477

3463-
16. Let |frame| be a new {{VideoFrame}} object initialized as follows:
3478+
1. Let |frame| be a new {{VideoFrame}} object initialized as follows:
34643479
1. Assign |resourceCodedWidth|, |resourceCodedHeight|,
34653480
|resourceVisibleLeft|, and |resourceVisibleTop| to
34663481
{{VideoFrame/[[coded width]]}}, {{VideoFrame/[[coded height]]}},
34673482
{{VideoFrame/[[visible left]]}}, and {{VideoFrame/[[visible top]]}}
34683483
respectively.
3469-
2. If |init|.{{VideoFrameBufferInit/visibleRect}} [=map/exists=]:
3484+
1. If |init|.{{VideoFrameBufferInit/visibleRect}} [=map/exists=]:
34703485
1. Let |truncatedVisibleWidth| be the value of
34713486
{{VideoFrameBufferInit/visibleRect}}.{{DOMRectInit/width}} after
34723487
truncating.
34733488
1. Assign |truncatedVisibleWidth| to {{VideoFrame/[[visible width]]}}.
3474-
3. Let |truncatedVisibleHeight| be the value of
3489+
1. Let |truncatedVisibleHeight| be the value of
34753490
{{VideoFrameBufferInit/visibleRect}}.{{DOMRectInit/height}} after
34763491
truncating.
3477-
2. Assign |truncatedVisibleHeight| to {{VideoFrame/[[visible height]]}}.
3478-
3. Otherwise:
3492+
1. Assign |truncatedVisibleHeight| to {{VideoFrame/[[visible height]]}}.
3493+
1. Otherwise:
34793494
1. Assign {{VideoFrame/[[coded width]]}} to
34803495
{{VideoFrame/[[visible width]]}}.
34813496
2. Assign {{VideoFrame/[[coded height]]}} to
34823497
{{VideoFrame/[[visible height]]}}.
3483-
4. If |init|.{{VideoFrameBufferInit/displayWidth}} [=map/exists=], assign
3498+
1. If |init|.{{VideoFrameBufferInit/displayWidth}} [=map/exists=], assign
34843499
it to {{VideoFrame/[[display width]]}}. Otherwise, assign
34853500
{{VideoFrame/[[visible width]]}} to {{VideoFrame/[[display width]]}}.
3486-
5. If |init|.{{VideoFrameBufferInit/displayHeight}} [=map/exists=], assign
3501+
1. If |init|.{{VideoFrameBufferInit/displayHeight}} [=map/exists=], assign
34873502
it to {{VideoFrame/[[display height]]}}. Otherwise, assign
34883503
{{VideoFrame/[[visible height]]}} to {{VideoFrame/[[display height]]}}.
3489-
6. Assign |init|'s {{VideoFrameBufferInit/timestamp}} and
3504+
1. Assign |init|'s {{VideoFrameBufferInit/timestamp}} and
34903505
{{VideoFrameBufferInit/duration}} to {{VideoFrame/[[timestamp]]}} and
34913506
{{VideoFrame/[[duration]]}} respectively.
3492-
7. Let |colorSpace| be `undefined`.
3493-
8. If |init|.{{VideoFrameBufferInit/colorSpace}} [=map/exists=], assign its
3507+
1. Let |colorSpace| be `undefined`.
3508+
1. If |init|.{{VideoFrameBufferInit/colorSpace}} [=map/exists=], assign its
34943509
value to |colorSpace|.
3495-
9. Assign the result of running the [=VideoFrame/Pick Color Space=]
3510+
1. Assign the result of running the [=VideoFrame/Pick Color Space=]
34963511
algorithm, with |colorSpace| and {{VideoFrame/[[format]]}}, to
34973512
{{VideoFrame/[[color space]]}}.
3498-
10. Assign the result of calling [=Copy VideoFrame metadata=]
3513+
1. Assign the result of calling [=Copy VideoFrame metadata=]
34993514
with |init|'s {{VideoFrameInit/metadata}} to |frame|.{{VideoFrame/[[metadata]]}}.
3500-
17. Return |frame|.
3515+
1. Return |frame|.
35013516

35023517
### Attributes ###{#videoframe-attributes}
35033518
: <dfn attribute for=VideoFrame>format</dfn>

0 commit comments

Comments
 (0)