openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

add wasm build support

Open Yuhengwe1 opened this issue 3 years ago • 4 comments

add Webassembly build support for openh264.

our build & test environment:

  • emcc version 3.16.0
  • node.js version v16.16.0
  • chrome version 105.0.5195.127

build command

emmake make ARCH= OS=wasm EMFS=nodefs

several build flags for wasm:

  • EMFS=nodefs|memfs : select file system to use
  • WASMDEBUG=True : when linking, preserve function names in compiled code

test openh264 wasm with local files

h264enc.js, h264enc.wasm, h264dec.wasm, h264dec.wasm will appear in main project dir.

using MEMFS

when build, set EMFS=memfs to package files needed in encoder or decoder test.

for now, emcc with preload all files under testbin/workload

in MEMFS all files will exist strictly in-memory, and any data written to them is lost when web page is reloaded.

to test h264enc.js or h264dec.js in chrome, start chrome with:

chrome.exe --enable-features=SharedArrayBuffer

using NODEFS

set EMFS=nodefs when build.

NODEFS only works for node.js environment, it provides direct access to the local file system.

for now, we mount the main project dir into NODEFS.

run test like this:

node h264enc.js testbin/welsenc_vd_1d_wasm_nodefs.cfg

WIP

we are now optimizing several hotspot functions with wasm intrinsic, updates will be added into this branch.

welcome review!

Yuhengwe1 avatar Sep 22 '22 06:09 Yuhengwe1

could anyone help code review? @jrmuizel @GuangweiWang

Yuhengwe1 avatar Oct 09 '22 03:10 Yuhengwe1

Can you also add github actions support for building this so that it gets tested?

ok, will try to add workflow for wasm

Yuhengwe1 avatar Oct 10 '22 07:10 Yuhengwe1

Workflow for wasm build test added.

I tried encoder_binary_comparison on my local machine, but got SHA value mismatch in one of the test cases(Zhling_1280x720.264).

Similar SHA value mismatch occurred in unit test: ThreadDecodeFile/ThreadDecoderOutputTest.CompareOutput, the wasm version passed 7/39 cases.

I want to know, are the SHA values of codec results fixed in different build environment?

Yuhengwe1 avatar Feb 20 '23 05:02 Yuhengwe1

@jrmuizel @GuangweiWang A friendly remainder about open questions above 👍

Bessonov avatar Aug 24 '23 22:08 Bessonov