MCPcopy Create free account
hub / github.com/Vanilagy/webcodecs-polyfill / allocationSize

Method allocationSize

src/video_frame.ts:269–284  ·  view source on GitHub ↗

* Returns the number of bytes needed to hold a copy of the frame's pixel data.

(options: VideoFrameCopyToOptions = {})

Source from the content-addressed store, hash-verified

267 * Returns the number of bytes needed to hold a copy of the frame's pixel data.
268 */
269 allocationSize(options: VideoFrameCopyToOptions = {}): number {
270 // 1. If [[Detached]] is true, throw an InvalidStateError DOMException.
271 this.ensureNotClosed();
272
273 // 2. If [[format]] is null, throw a NotSupportedError DOMException.
274 if (this.format === null) {
275 throw new Error('NotSupportedError: VideoFrame format is null');
276 }
277
278 // 3. Let combinedLayout be the result of running the Parse VideoFrameCopyToOptions algorithm with options.
279 // 4. If combinedLayout is an exception, throw combinedLayout.
280 const combinedLayout = ParseVideoFrameCopyToOptions(this, options);
281
282 // 5. Return combinedLayout's allocationSize.
283 return combinedLayout.allocationSize;
284 }
285
286 /**
287 * Copies the frame's pixel data to a destination buffer. Returns the layout of the planes in the destination

Callers

nothing calls this directly

Calls 2

ensureNotClosedMethod · 0.95

Tested by

no test coverage detected