feat(oakcodec): hardware video decoding by default on all platforms

FFmpeg 8 removed the standalone hardware decoders (h264_videotoolbox/
vaapi/nvdec/d3d11va no longer exist in its configure) — hardware decode
now only exists as a hwaccel attached to the software decoder. The new
oakcodec::hwdecode module therefore opens the regular decoder with the
platform's hardware device context attached (VideoToolbox on macOS,
VA-API then NVDEC on Linux, D3D11VA then NVDEC on Windows): FFmpeg
engages the matching hwaccel, decodes into hardware surfaces, and we
transfer them to system memory (NV12/P010) ahead of swscale.

- HardwareDecoding config switch, default ON by mandate; a checkbox in
  Preferences > Rendering (EN/ZH); device creation failure skips to the
  next candidate and finally to software; a decode-time failure on a
  hardware session reopens it as software and retries once.
- hw_decoder_name() observability hook plus a HW_TRANSFERS counter so
  tests can prove the hwaccel really engaged (not silently software).
- Verification: demo.mp4 H.264 decodes through VideoToolbox with a
  transferred hardware surface, and the pixels match the software
  decode within 0.05; switch off forces software.
- build-ffmpeg.sh also enables nvdec when ffnvcodec headers exist.
This commit is contained in:
2026-08-19 14:04:55 +08:00
parent 4dd4ceb08a
commit 35b9ad9541
7 changed files with 458 additions and 15 deletions
+3 -3
View File
@@ -182,10 +182,10 @@ case "$OS" in
esac
# NVIDIA (ffnvcodec headers are distribution-free; enable when present).
if [ -d /usr/local/cuda ] || pkg-config --exists ffnvcodec 2>/dev/null; then
FLAGS+=(--enable-nvenc --enable-cuda-llvm)
echo " + nvenc/cuda"
FLAGS+=(--enable-nvdec --enable-nvenc --enable-cuda-llvm)
echo " + nvdec/nvenc/cuda"
else
echo " - nvenc/cuda (no ffnvcodec headers)"
echo " - nvdec/nvenc/cuda (no ffnvcodec headers)"
fi
# --- Build ------------------------------------------------------------------