add wasm build support
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!
could anyone help code review? @jrmuizel @GuangweiWang
Can you also add github actions support for building this so that it gets tested?
ok, will try to add workflow for wasm
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?
@jrmuizel @GuangweiWang A friendly remainder about open questions above 👍