#!/usr/bin/env bash
# gen-bitstream-fixtures.sh — raw VP9/AV1 elementary streams for the syntax crates.
#
# ffmpeg is ORACLE/test-input tooling only; no ec-* crate depends on it at runtime.
# Two sources: (a) the container fixtures from gen-fixtures.sh, remuxed to IVF so a
# header parser sees the elementary stream with no container in the way, and (b)
# small purpose-built clips for the header branches the 4:2:0 8/10-bit set never
# reaches — VP9 superframes with a hidden ALTREF plus show_existing_frame, 4:4:4
# (VP9 profile 1/3, AV1 profile 1), monochrome AV1, multi-tile AV1.
#
# Idempotent: non-empty outputs are skipped, partial outputs are deleted on failure.
#
# Usage: scripts/gen-bitstream-fixtures.sh [-f] (-f: regenerate everything)
# Env: EC_FIXTURES=
(default /fixtures)
set -uo pipefail
ROOT=$(cd -- "$(dirname -- "$0")/.." && pwd)
FIXTURES=${EC_FIXTURES:-$ROOT/fixtures}
OUT=$FIXTURES/bitstreams
FORCE=0
[ "${1:-}" = "-f" ] && FORCE=1
command -v ffmpeg >/dev/null || { echo "gen-bitstream-fixtures: ffmpeg not found" >&2; exit 2; }
mkdir -p "$OUT" || exit 2
TMPLOG=$(mktemp) || exit 2
trap 'rm -f "$TMPLOG"' EXIT
fail=0
# run