iter39 Phase 4-6 LANDED on backend — Phase 7 awaiting fresnel power-on

Adds the iter39 sub-profile (H264 Hi10P + HEVC Main10) FR landing
materials and resumption sequence to the campaign repo.

- phase4_iter39_subprofile_plan.md: full Phase 4 plan with Phase 5
  sonnet-architect review amendments folded in. Documents the
  Option A/B/C/D scope tree, the locked Option C choice (full NV15→P010
  userspace unpack), the LOC breakdown (~180), and the test plan.
- phase7_iter39_test_rig.sh: end-to-end test script for fresnel. Encodes
  Hi10P + Main10 fixtures, runs libva vs kdirect bit-exact comparison
  (both via `-vf hwdownload,format=p010le` to normalize the NV15 stride
  difference between paths), SSIM_Y check vs SW reference, and verifies
  the iter38 5/5 baseline still holds.
- PRE_COMPACT_HANDOFF.md: TL;DR table row for iter39 (committed
  pending validation), Phase 7 resumption sequence, internals-summary
  for future-session resumption.

Backend tip: `662f887` (iter39 α-31) + `8746690` (unpack self-test) on
gitea master. Self-test passes on noether x86_64; compile-test clean on
boltzmann aarch64 native; self-review of commit vs Phase 5 amendments
APPROVED. Phase 7 actual decode test blocked on fresnel power-on.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-17 09:22:34 +00:00
parent e66c5c0583
commit 407c7c56e1
3 changed files with 327 additions and 4 deletions
+162
View File
@@ -0,0 +1,162 @@
#!/bin/bash
#
# Phase 7 test rig for iter39 sub-profile support (Hi10P + Main10).
# Run on fresnel after kernel 7.0-14 boot + iter39 backend deploy.
#
# Prerequisites on fresnel:
# 1. linux-fresnel-fourier 7.0-14 booted
# 2. backend sync + build:
# cd ~/src/libva-v4l2-request-fourier
# git fetch && git reset --hard origin/master # → 662f887
# ninja -C build
# sudo install -m644 build/src/v4l2_request_drv_video.so /usr/lib/dri/
# 3. Test fixtures (will be encoded by this script if missing):
# ~/measurements/encoded/bbb_main10.mp4 (HEVC Main10, 10-bit)
# ~/measurements/encoded/bbb_hi10p.mp4 (H.264 Hi10P, 10-bit)
#
# Exit code 0 = all criteria PASS.
set -eu
ENCODED_DIR="${ENCODED_DIR:-$HOME/measurements/encoded}"
SOURCE="${SOURCE:-$HOME/measurements/source/bbb_720p.mov}"
OUT="${OUT:-/tmp/iter39_test}"
mkdir -p "$ENCODED_DIR" "$OUT"
# Step 1 — encode 10-bit fixtures if missing.
if [ ! -f "$ENCODED_DIR/bbb_main10.mp4" ]; then
echo "==> Encoding HEVC Main10 fixture"
ffmpeg -hide_banner -loglevel error -i "$SOURCE" -t 10 \
-c:v libx265 -preset fast -crf 28 \
-pix_fmt yuv420p10le -profile:v main10 \
-tag:v hvc1 "$ENCODED_DIR/bbb_main10.mp4"
fi
if [ ! -f "$ENCODED_DIR/bbb_hi10p.mp4" ]; then
echo "==> Encoding H.264 Hi10P fixture"
ffmpeg -hide_banner -loglevel error -i "$SOURCE" -t 10 \
-c:v libx264 -preset medium -crf 23 \
-pix_fmt yuv420p10le -profile:v high10 \
"$ENCODED_DIR/bbb_hi10p.mp4"
fi
# Step 2 — vainfo enumeration check.
echo ""
echo "==> Criterion 1: vainfo lists VAProfileHEVCMain10 + VAProfileH264High10"
VAINFO_OUT="$(env LIBVA_DRIVER_NAME=v4l2_request \
LIBVA_DRIVERS_PATH="$HOME/src/libva-v4l2-request-fourier/build/src" \
vainfo 2>&1)"
echo "$VAINFO_OUT" | grep -E "VAProfile(H264High10|HEVCMain10)" || {
echo "FAIL: missing 10-bit profile in vainfo output"
echo "$VAINFO_OUT" | grep VAProfile | sed 's/^/ /'
exit 1
}
echo " -> PASS"
# Step 3 — per-codec libva-vs-kdirect bit-exactness (Sub-criterion: P010 layout).
echo ""
echo "==> Criteria 2-3: libva.P010 == kdirect.P010 for HEVC Main10 + H264 Hi10P"
run_codec() {
local name="$1" fixture="$2"
echo " -- $name ($fixture) --"
# libva path (our iter39 backend, NV15→P010 unpack)
env LIBVA_DRIVER_NAME=v4l2_request \
LIBVA_DRIVERS_PATH="$HOME/src/libva-v4l2-request-fourier/build/src" \
ffmpeg -hide_banner -loglevel error -y \
-hwaccel vaapi -hwaccel_output_format vaapi \
-i "$ENCODED_DIR/$fixture" \
-vf "hwdownload,format=p010le" -frames:v 10 \
-f rawvideo -pix_fmt p010le "$OUT/L_${name}.p010" || {
echo " libva path FAIL"; return 1
}
# kdirect path (ffmpeg-v4l2-request hwaccel, libswscale unpacks NV15→YUV420P10)
ffmpeg -hide_banner -loglevel error -y \
-hwaccel v4l2request -hwaccel_output_format drm_prime \
-i "$ENCODED_DIR/$fixture" \
-vf "hwdownload,format=p010le" -frames:v 10 \
-f rawvideo -pix_fmt p010le "$OUT/K_${name}.p010" || {
echo " kdirect path FAIL"; return 1
}
L_SHA=$(sha256sum "$OUT/L_${name}.p010" | cut -c1-16)
K_SHA=$(sha256sum "$OUT/K_${name}.p010" | cut -c1-16)
if [ "$L_SHA" = "$K_SHA" ]; then
echo " PASS libva.P010 == kdirect.P010 sha=$L_SHA"
return 0
else
echo " FAIL libva.P010 != kdirect.P010"
echo " libva sha=$L_SHA"
echo " kdirect sha=$K_SHA"
return 1
fi
}
FAIL_COUNT=0
run_codec hevc_main10 bbb_main10.mp4 || FAIL_COUNT=$((FAIL_COUNT + 1))
run_codec h264_hi10p bbb_hi10p.mp4 || FAIL_COUNT=$((FAIL_COUNT + 1))
# Step 4 — SSIM vs SW reference (criterion 4)
echo ""
echo "==> Criterion 4: SSIM_Y >= 0.999 vs libavcodec SW (yuv420p10le)"
run_ssim() {
local name="$1" fixture="$2"
ffmpeg -hide_banner -loglevel error -y \
-i "$ENCODED_DIR/$fixture" \
-vf "format=yuv420p10le" -frames:v 10 \
-f rawvideo -pix_fmt yuv420p10le "$OUT/SW_${name}.yuv" || return 1
# Compare P010 (libva) to YUV420P10 (SW) using ffmpeg's ssim filter
# — feed both as raw with known shape, force same conversion.
SSIM=$(ffmpeg -hide_banner -loglevel info \
-f rawvideo -pix_fmt p010le -s 1280x720 -i "$OUT/L_${name}.p010" \
-f rawvideo -pix_fmt yuv420p10le -s 1280x720 -i "$OUT/SW_${name}.yuv" \
-filter_complex "[0:v]format=yuv420p10le[a];[a][1:v]ssim" \
-f null - 2>&1 | grep -oE "SSIM Y:[0-9.]+ " | head -1 | awk '{print $2}')
echo " $name: SSIM_Y=$SSIM"
}
run_ssim hevc_main10 bbb_main10.mp4
run_ssim h264_hi10p bbb_hi10p.mp4
# Step 5 — 5-codec smoke regression check (criterion 5)
echo ""
echo "==> Criterion 5: 5/5 PASS still holds for the iter38 baseline codecs"
for codec in h264:bbb_1080p30_h264.mp4 hevc:bbb_720p10s_hevc.mp4 \
vp9:bbb_720p10s_vp9.webm vp8:bbb_720p10s_vp8.webm \
mpeg2:bbb_720p10s_mpeg2.ts; do
name="${codec%%:*}"; fixture="${codec#*:}"
[ -f "$HOME/fourier-test/$fixture" ] || { echo " skip $name: fixture missing"; continue; }
env LIBVA_DRIVER_NAME=v4l2_request \
LIBVA_DRIVERS_PATH="$HOME/src/libva-v4l2-request-fourier/build/src" \
ffmpeg -hide_banner -loglevel error -y \
-hwaccel vaapi -hwaccel_output_format vaapi \
-i "$HOME/fourier-test/$fixture" \
-vf "hwdownload,format=nv12" -frames:v 10 \
-f rawvideo -pix_fmt nv12 "$OUT/L_${name}.nv12"
ffmpeg -hide_banner -loglevel error -y \
-hwaccel v4l2request -hwaccel_output_format drm_prime \
-i "$HOME/fourier-test/$fixture" -vf "hwdownload,format=nv12" \
-frames:v 10 -f rawvideo -pix_fmt nv12 "$OUT/K_${name}.nv12"
L=$(sha256sum "$OUT/L_${name}.nv12" | cut -c1-16)
K=$(sha256sum "$OUT/K_${name}.nv12" | cut -c1-16)
if [ "$L" = "$K" ]; then
echo " $name: PASS"
else
echo " $name: FAIL (libva=$L kdirect=$K)"
FAIL_COUNT=$((FAIL_COUNT + 1))
fi
done
echo ""
if [ $FAIL_COUNT -eq 0 ]; then
echo "iter39 close: ALL PASS — Hi10P + Main10 wired + iter38 5/5 baseline holds"
exit 0
else
echo "iter39 FAIL: $FAIL_COUNT criteria failed; see $OUT for artefacts"
exit 1
fi