#!/bin/bash # Builds src/tools/video/x264/x264.wasm + x264.js (libx264 + pt_x264.c, single thread, WebAssembly SIMD, no asm) with Emscripten. # Tools live in qa-evidence/bench-tools (git-ignored): emsdk 3.1.74 and the x264 source (https://github.com/mirror/x264, commit in x264/.git). # One-time setup (see NOTES.md 2026-10-20): python emsdk.py install 3.1.74; git clone x264; configure: # CC=emcc AR=emar RANLIB=emranlib ./configure --host=i686-linux --disable-asm --disable-cli --enable-static --disable-thread --bit-depth=8 --chroma-format=420 \ # --disable-avs --disable-swscale --disable-lavf --disable-ffms --disable-gpac --disable-lsmash --disable-opencl --disable-interlaced --extra-cflags="-O3 -msimd128" # then edit config.mak: drop -m32 and -fno-tree-vectorize (lets LLVM vectorize the C code), make libx264.a. # x264 is GPL-2.0-or-later: the module and its source (x264 commit + pt_x264.c + this script) must stay available to users (see /open-source/). set -e BT="$(cd "$(dirname "$0")/../qa-evidence/bench-tools" && pwd)" export PATH="$BT/wasm-bin:$PATH" OUT="$(cd "$(dirname "$0")/../src/tools/video/x264" && pwd)" cd "$BT/x264" emcc -O3 -msimd128 -ffast-math -I. "$OUT/pt_x264.c" libx264.a -o "$OUT/x264.js" \ -sMODULARIZE=1 -sEXPORT_NAME=createX264 -sENVIRONMENT=web,worker -sALLOW_MEMORY_GROWTH=1 -sINITIAL_MEMORY=33554432 -sFILESYSTEM=1 -sNO_EXIT_RUNTIME=1 \ -sEXPORTED_FUNCTIONS=_pt_init,_pt_set,_pt_profile,_pt_start,_pt_input,_pt_headers,_pt_encode,_pt_flush,_pt_out,_pt_key,_pt_pts,_pt_dts,_pt_close,_malloc,_free \ -sEXPORTED_RUNTIME_METHODS=HEAPU8,UTF8ToString,stringToUTF8,lengthBytesUTF8,FS ls -la "$OUT"