Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dav1d.js

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dav1d.js - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

40

dav1d.js

@@ -48,7 +48,21 @@ // Must be in sync with emcc settings!

function fetchAndInstantiate(data, url, imports) {
if (data) return WebAssembly.instantiate(data, imports);
const req = fetch(url, {credentials: "same-origin"});
if (WebAssembly.instantiateStreaming) {
return WebAssembly.instantiateStreaming(req, imports);
} else {
return req
.then(res => res.arrayBuffer())
.then(data => WebAssembly.instantiate(data, imports));
}
}
export function create(opts = {}) {
const data = opts.wasmData;
if (!opts.wasmURL && !opts.wasmData) {
return Promise.reject(new Error("Either wasmURL or wasmData shall be provided"));
}
const runtime = getRuntime();
const imports = {env: runtime};
return WebAssembly.instantiate(data, imports).then(wasm => {
return fetchAndInstantiate(opts.wasmData, opts.wasmURL, imports).then(wasm => {
const d = new Dav1d({wasm, runtime});

@@ -64,2 +78,4 @@ d._init();

class Dav1d {
/* Private methods, shall not be used */
constructor({wasm, runtime}) {

@@ -70,2 +86,3 @@ this.FFI = wasm.instance.exports;

this.ref = null;
this.lastFrameRef = null;
}

@@ -92,3 +109,3 @@ _init() {

if (unsafe) {
this.FFI.djs_free_frame(frameRef);
this.lastFrameRef = frameRef;
return srcData;

@@ -101,2 +118,5 @@ }

}
/* Public API methods */
/**

@@ -111,6 +131,8 @@ * Frame decoding, copy of frame data is returned.

}
/**
* Unsafe decoding with minimal overhead. We return pointer to WASM
* memory, so you can't call any dav1d.js methods while keeping
* reference to it.
* Unsafe decoding with minimal overhead, pointer to WebAssembly
* memory is returned. User can't call any dav1d.js methods while
* keeping reference to it and shall call `unsafeCleanup` when
* finished using the data.
*/

@@ -123,4 +145,10 @@ unsafeDecodeFrameAsYUV(obu) {

}
unsafeCleanup() {
if (this.lastFrameRef) {
this.FFI.djs_free_frame(this.lastFrameRef);
this.lastFrameRef = null;
}
}
}
export default {create};

5

package.json
{
"name": "dav1d.js",
"version": "0.1.0",
"version": "0.1.1",
"description": "WebAssembly AV1 decoder",
"main": "dav1d.js",
"scripts": {
"prepublishOnly": "make dav1d.wasm"
},
"repository": {

@@ -7,0 +10,0 @@ "type": "git",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc