-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
61 lines (46 loc) · 1.86 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: "VideoFrame: allocationSize() method"
short-title: allocationSize()
slug: Web/API/VideoFrame/allocationSize
page-type: web-api-instance-method
browser-compat: api.VideoFrame.allocationSize
---
{{APIRef("Web Codecs API")}}{{AvailableInWorkers("window_and_dedicated")}}
The **`allocationSize()`** method of the {{domxref("VideoFrame")}} interface returns the number of bytes required to hold the video as filtered by options passed into the method.
## Syntax
```js-nolint
allocationSize()
allocationSize(options)
```
### Parameters
- `options` {{optional_inline}}
- : An object containing the following:
- `rect` {{optional_inline}}
- : The rectangle of pixels to copy from the `VideoFrame`. If unspecified the {{domxref("VideoFrame.visibleRect","visibleRect")}} will be used. This is in the format of a dictionary object containing:
- `x`: The x-coordinate.
- `y`: The y-coordinate.
- `width`: The width of the frame.
- `height`: The height of the frame.
- `layout` {{optional_inline}}
- : A list containing the following values for each plane in the `VideoFrame`. Planes may not overlap. If unspecified the planes will be tightly packed:
- `offset`
- : An integer representing the offset in bytes where the given plane begins.
- `stride`
- : An integer representing the number of bytes, including padding, used by each row of the plane.
### Return value
An integer containing the number of bytes needed to hold the frame as specified by `options`.
## Examples
In the following example the `allocationSize` is returned for the rectangle at top left with dimensions of 800 by 600.
```js
const videoRect = {
x: 0,
y: 0,
width: 800,
height: 600,
};
let size = VideoFrame.allocationSize({ rect: videoRect });
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}