Skip to content

Commit a7ea132

Browse files
Djuffindalecurtis
authored andcommitted
Add VideoFrameBufferInit.transfer
1 parent 119eb19 commit a7ea132

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

index.src.html

Lines changed: 32 additions & 17 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 {
@@ -3421,23 +3423,33 @@
34213423
3. Let |overrideRect| be `undefined`.
34223424
4. 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+
5. 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+
6. If |parsedRect| is an exception, return |parsedRect|.
3432+
7. Let |optLayout| be `undefined`.
3433+
8. 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+
9. 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+
10. If |combinedLayout| is an exception, throw |combinedLayout|.
3439+
11. 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+
12. If |init|.{{VideoFrameBufferInit/transfer}} contains more than one reference
3442+
to the same {{ArrayBuffer}}, then throw a {{DataCloneError}} {{DOMException}}.
3443+
13. For each |transferable| in |init|.{{VideoFrameBufferInit/transfer}}:
3444+
1. If {{platform object/[[Detached]]}} internal slot is `true`,
3445+
then throw a {{DataCloneError}} {{DOMException}}.
3446+
14. If |init|.{{VideoFrameBufferInit/transfer}} contains an {{ArrayBuffer}}
3447+
referenced by |data| the User Agent <em class="rfc2119">MAY</em> choose to:
3448+
1. Let |resource| be a new [=media resource=] referencing pixel data in
3449+
|data|.
3450+
15. 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,18 +3461,21 @@
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+
16. For each |transferable| in |init|.{{VideoFrameBufferInit/transfer}}:
3465+
1. Perform [DetachArrayBuffer](https://tc39.es/ecma262/#sec-detacharraybuffer)
3466+
on |transferable|
3467+
17. Let |resourceCodedWidth| be the coded width of |resource|.
3468+
18. Let |resourceCodedHeight| be the coded height of |resource|.
3469+
19. 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+
20. 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+
21. 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]]}},
@@ -3470,11 +3485,11 @@
34703485
1. Let |truncatedVisibleWidth| be the value of
34713486
{{VideoFrameBufferInit/visibleRect}}.{{DOMRectInit/width}} after
34723487
truncating.
3473-
1. Assign |truncatedVisibleWidth| to {{VideoFrame/[[visible width]]}}.
3488+
2. Assign |truncatedVisibleWidth| to {{VideoFrame/[[visible width]]}}.
34743489
3. Let |truncatedVisibleHeight| be the value of
34753490
{{VideoFrameBufferInit/visibleRect}}.{{DOMRectInit/height}} after
34763491
truncating.
3477-
2. Assign |truncatedVisibleHeight| to {{VideoFrame/[[visible height]]}}.
3492+
4. Assign |truncatedVisibleHeight| to {{VideoFrame/[[visible height]]}}.
34783493
3. Otherwise:
34793494
1. Assign {{VideoFrame/[[coded width]]}} to
34803495
{{VideoFrame/[[visible width]]}}.
@@ -3497,7 +3512,7 @@
34973512
{{VideoFrame/[[color space]]}}.
34983513
10. Assign the result of calling [=Copy VideoFrame metadata=]
34993514
with |init|'s {{VideoFrameInit/metadata}} to |frame|.{{VideoFrame/[[metadata]]}}.
3500-
17. Return |frame|.
3515+
22. Return |frame|.
35013516

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

0 commit comments

Comments
 (0)