This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const RGBAToYUV420 = ({ width, height, data }: ImageData) => { | |
// Assume both width and height are even | |
let yuv = new Uint8Array(width * height * 1.5); | |
// Use loop tiling as a cache optimization | |
const tileSize = 64; | |
for (let y0 = 0; y0 < height; y0 += tileSize) { | |
for (let x0 = 0; x0 < width; x0 += tileSize) { | |
let limitX = Math.min(width, x0 + tileSize); | |
let limitY = Math.min(height, y0 + tileSize); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @Vanilagy 2019 | |
// | |
// Example: | |
// structuredClone([5, {hello: 'world'}, new Set()]).then((data) => console.log(data)); | |
// > [5, {hello: "world"}, Set(0)] | |
var structuredClone = (function() { | |
var sender = new BroadcastChannel('structuredClone'), | |
receiver = new BroadcastChannel('structuredClone'); |