# WebAssembly

# 说明

WebAssembly 是新一代的 Web 虚拟机标准,C/C 程序可以通过 Emscripten 工具链编译为 WebAssembly 二进制格式.wasm,进而导入网页中供 JavaScript 调用——这意味着使用 C/C 编写的程序将可以直接运行在网页中。

# 参考资料

WebAssembly - MDN (opens new window)
asm.js 和 Emscripten 入门教程 (opens new window)
C/C++面向 WebAssembly 编程 (opens new window)
WebAssembly 资料精选 - 中文版 (opens new window)

# Demo

<template>
  <pre><code ref="code" ></code></pre>
</template>
<script>
export default {
  mounted() {
    let code = `Demo1 compile Start\r\n`;
    WebAssembly.compile(
      new Uint8Array(
        `
  00 61 73 6d  01 00 00 00  01 0c 02 60  02 7f 7f 01
  7f 60 01 7f  01 7f 03 03  02 00 01 07  10 02 03 61
  64 64 00 00  06 73 71 75  61 72 65 00  01 0a 13 02
  08 00 20 00  20 01 6a 0f  0b 08 00 20  00 20 00 6c
  0f 0b`
          .trim()
          .split(/[\s\r\n]+/g)
          .map(str => parseInt(str, 16))
      )
    ).then(module => {
      const instance = new WebAssembly.Instance(module);
      const { add, square } = instance.exports;
      code += `Demo1 compile End\r\n`;
      code += `2 + 4     = ${add(2, 4)}\r\n`;
      code += `3^2       = ${square(3)}\r\n`;
      code += `(2 + 5)^2 = ${square(add(2 + 5))}`;
      this.$refs.code.innerHTML = code;
    });
  }
};
</script>

# 项目资料

https://github.com/ErosZy/WXInlinePlaye
https://github.com/sonysuqin/WasmVideoPlayer

  • openh264 https://github.com/cisco/openh264
  • tinyh264 https://github.com/udevbe/tinyh264
  • libde265 https://github.com/strukturag/libde265

https://github.com/sonysuqin/WasmVideoPlayer
https://github.com/ErosZy/WXInlinePlayer
https://github.com/liang520/webAssemblyPlayer
https://github.com/langhuihui/jessibuca
https://github.com/goldvideo/decoder_wasm
https://github.com/goldvideo/h265player
https://github.com/chenchenwuai/H265Player
https://github.com/numberwolf/h265web.js
https://github.com/tsingsee/EasyPlayer.js