open-standards/wai/tools/build_reference_decoders.sh
Transaction Science cf4c7bb8bd wai: archive reference-decoder build recipes for reproducible demo
Add tools/build_reference_decoders.sh: fetches and builds the open MPEG/3GPP
reference codecs that act as the sink decoders for the volumetric and
immersive-audio rows of the carriage demo, each pinned to a verified ref:
  - G-PCC  mpeg-pcc-tmc13  release-v23.0-rc2   -> tmc3
  - V-PCC  mpeg-pcc-tmc2   release-v25.0       -> PccApp{Encoder,Parser,...}
  - IVAS   3GPP ivas-codec main @ 3882460      -> IVAS_cod / IVAS_dec

It handles the cmake 4.x policy override the MPEG trees need (their build.sh
rejects cmake major != 3), is idempotent (skips already-built trees), and
prints the exact PATH/TMC2_CFG export line to run wai_carriage_demo.sh. So the
real+decode / real+parse rows reproduce from a clean checkout instead of the
ad-hoc /tmp builds.

- demo header + registry: cross-reference the build script.
- .gitignore: ignore the script's default ./.reference-tools prefix.

Verified: refs resolve on all three remotes; the printed exports drive the
demo to 5 real+decode + 1 real+parse rows, all byte-exact.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-20 11:44:42 -04:00

99 lines
4.5 KiB
Shell
Executable file

#!/usr/bin/env bash
# Build the open MPEG / 3GPP reference codecs that act as the *sink* decoders
# for the volumetric and immersive-audio rows of tools/wai_carriage_demo.sh.
# WAI never bundles a decoder — it carries bytes and dispatches. These are the
# field's own reference tools; this script just fetches and builds them at the
# exact versions verified for the demo, so the "real+decode" / "real+parse"
# rows reproduce without the ad-hoc /tmp builds.
#
# Builds (each pinned to a verified tag/ref):
# - G-PCC : MPEG mpeg-pcc-tmc13 release-v23.0-rc2 -> tmc3
# - V-PCC : MPEG mpeg-pcc-tmc2 release-v25.0 -> PccApp{Encoder,Parser,VideoEncoder,...}
# - IVAS : 3GPP ivas-codec main @ 3882460 -> IVAS_cod / IVAS_dec
#
# (JPEG 2000 / IAMF / Draco come from OpenJPEG / ffmpeg / draco, installed via a
# package manager — not built here.)
#
# Usage:
# ./tools/build_reference_decoders.sh [PREFIX] [-j N]
# PREFIX install/checkout root (default: ./.reference-tools, gitignored)
# -j N parallel build jobs (default: CPU count)
#
# On success it prints the exact `export PATH=… TMC2_CFG=…` line to source
# before running ./tools/wai_carriage_demo.sh.
#
# Toolchain notes (verified on macOS arm64, Apple clang 21, cmake 4.3.3):
# * tmc2/tmc13 ship a build.sh that rejects cmake major != 3; we invoke cmake
# directly with -DCMAKE_POLICY_VERSION_MINIMUM=3.5 so cmake 4.x accepts the
# pre-3.5 minimums the reference CMakeLists still declare.
# * Both MPEG trees vendor their video/HEVC dependencies, so no external
# HM/HEVC fetch is needed for the encode + parse paths the demo uses.
set -euo pipefail
PREFIX="${1:-$(cd "$(dirname "$0")/.." && pwd)/.reference-tools}"
[ "${PREFIX:0:1}" = "-" ] && PREFIX="$(cd "$(dirname "$0")/.." && pwd)/.reference-tools"
JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || sysctl -n hw.ncpu 2>/dev/null || echo 4)"
# allow `-j N` anywhere
prev=""; for a in "$@"; do [ "$prev" = "-j" ] && JOBS="$a"; prev="$a"; done
mkdir -p "$PREFIX"
PREFIX="$(cd "$PREFIX" && pwd)"
echo "reference-tool prefix: $PREFIX (jobs: $JOBS)"
need() { command -v "$1" >/dev/null 2>&1 || { echo "missing required tool: $1"; exit 1; }; }
need git; need cmake; need make
# clone_pinned <url> <ref> <dir>
clone_pinned() {
local url="$1" ref="$2" dir="$3"
if [ -d "$dir/.git" ]; then echo " exists: $dir"; return; fi
echo " cloning $url @ $ref"
git clone --branch "$ref" --depth 1 "$url" "$dir" 2>/dev/null \
|| git clone "$url" "$dir" # fall back to full clone if --branch ref isn't a branch/tag head
( cd "$dir" && git checkout -q "$ref" 2>/dev/null || true )
}
# ---------------------------------------------------------------- G-PCC (tmc13)
echo "== G-PCC: mpeg-pcc-tmc13 =="
GPCC="$PREFIX/mpeg-pcc-tmc13"
clone_pinned https://github.com/MPEGGroup/mpeg-pcc-tmc13.git release-v23.0-rc2 "$GPCC"
if [ ! -x "$GPCC/build/tmc3/tmc3" ]; then
mkdir -p "$GPCC/build"
( cd "$GPCC/build" && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
&& cmake --build . -j"$JOBS" )
fi
[ -x "$GPCC/build/tmc3/tmc3" ] && echo " -> $GPCC/build/tmc3/tmc3"
# ---------------------------------------------------------------- V-PCC (tmc2)
echo "== V-PCC: mpeg-pcc-tmc2 =="
VPCC="$PREFIX/mpeg-pcc-tmc2"
clone_pinned https://github.com/MPEGGroup/mpeg-pcc-tmc2.git release-v25.0 "$VPCC"
if [ ! -x "$VPCC/bin/PccAppEncoder" ]; then
mkdir -p "$VPCC/build"
( cd "$VPCC/build" && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
&& cmake --build . -j"$JOBS" )
fi
[ -x "$VPCC/bin/PccAppEncoder" ] && echo " -> $VPCC/bin/ (cfg: $VPCC/cfg/)"
# ---------------------------------------------------------------- IVAS (3GPP)
echo "== IVAS: 3GPP ivas-codec =="
IVAS="$PREFIX/ivas-codec"
clone_pinned https://forge.3gpp.org/rep/ivas-codec-pc/ivas-codec.git main "$IVAS"
# Pin the exact verified commit when present (main moves).
( cd "$IVAS" && git checkout -q 3882460b6c65 2>/dev/null || true )
if [ ! -x "$IVAS/IVAS_cod" ]; then
( cd "$IVAS" && make -j"$JOBS" )
fi
[ -x "$IVAS/IVAS_cod" ] && echo " -> $IVAS/IVAS_cod $IVAS/IVAS_dec"
# ---------------------------------------------------------------- summary
echo
echo "done. To reproduce the volumetric + immersive-audio decode rows, run:"
echo
echo " export PATH=\"$VPCC/bin:$IVAS:$GPCC/build/tmc3:\$PATH\""
echo " export TMC2_CFG=\"$VPCC/cfg\""
echo " ./tools/wai_carriage_demo.sh"
echo
echo "Expected: wai.image.jp2 / wai.audio.iamf / wai.audio.ivas / wai.mesh.draco"
echo "/ wai.pc.gpcc -> real+decode; wai.pc.vpcc -> real+parse; all byte-exact."