Skip to content

feat: use vpp_qsv hardware padding when available - #1

Closed
M-Pepper wants to merge 2 commits into
mainfrom
qsv-hardware-pad
Closed

feat: use vpp_qsv hardware padding when available#1
M-Pepper wants to merge 2 commits into
mainfrom
qsv-hardware-pad

Conversation

@M-Pepper

@M-Pepper M-Pepper commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Two commits:

feat: use vpp_qsv hardware padding when availableFfmpegInfo
gains per-filter option probing (ffmpeg -h filter=vpp_qsv), and the
QSV best_filter substitutes a hardware PadQsv op for the software
pad when the binary's vpp_qsv has pad_w. On stock ffmpeg the probe
finds nothing and the existing software pad chain is emitted unchanged
— no behavior change without a patched binary (see companion
ErsatzTV-ffmpeg PR; the patches are also on ffmpeg-devel upstream).

perf: fuse qsv scale+pad into a single vpp_qsv instance — measured
on hardware: two chained vpp_qsv instances drop the final frame at
EOF (1439/1440; reproducible with two plain scales on stock ffmpeg), a
single combined instance does not. The fusion pass follows the existing
CUDA scale/format fusion precedent in FilterChain::optimize().

Emitted chain for the canonical 4:3→16:9 case:

vpp_qsv=w=1440:h=1080:pad_w=1920:pad_h=1080:pad_x=-1:pad_y=-1:pad_color=black,setsar=1

Validated end-to-end with the real ersatztv-channel worker on an
Intel Arc Pro B50: patched-ffmpeg arm emits the fused chain with no
hwdownload and produces true-black 1920x1080 HLS segments
(Y/U/V = 16/128/128); stock-ffmpeg arm falls back to the software pad
and works. Benchmarks: GPU pad at parity with pad_vaapi (563 fps) vs
212 fps for the hwdownload/pad/hwupload chain. Running in production
against live channels since 2026-07-30.

Known limitation (pre-existing, unchanged): anamorphic sources use a
separate SAR pre-scale instance ahead of the fused scale+pad, so they
still emit two chained instances and keep the pre-existing EOF
last-frame behavior.

Companion PRs: M-Pepper/ErsatzTV-ffmpeg#1 (carries the ffmpeg patches),
M-Pepper/legacy#1 (same feature for the C# pipeline).

QSV padding currently falls back to the software pad filter, which forces
an hwdownload/hwupload round-trip per frame. Measured on an Intel Arc Pro
B50 (640x480 4:3 -> 1440x1080 padded to 1920x1080, h264), that chain runs
at 212 fps / 5.2s CPU versus 563 fps / 1.3s CPU for a hardware pad —
parity with pad_vaapi, and essentially free relative to plain scaling.

ffmpeg's vpp_qsv only gained pad_w/pad_h/pad_x/pad_y/pad_color in patched
builds (submission to ffmpeg-devel pending), so plain filter presence
cannot gate this. FfmpegInfo now probes AVOptions for selected filters
via `ffmpeg -h filter=NAME` (currently just vpp_qsv), and the QSV
best_filter substitutes PadQsv only when the pad_w option is advertised;
otherwise behaviour is unchanged and the software pad chain is used.

Co-Authored-By: Claude Fable 5 <[email protected]>
Chaining two vpp_qsv instances (scale then pad) drops the final frame at
EOF on real hardware (measured on Intel B50: 1439/1440 packets). This
reproduces with two plain vpp_qsv scales on stock ffmpeg, so it is a
pre-existing ffmpeg flush quirk we must avoid triggering. A single
combined instance delivers every frame and uses one VPP session.

PadQsv gains an optional fused ScaleQsv; the optimize() pass folds a
ScaleQsv into an immediately-following PadQsv (mirroring the existing
CUDA fusion), emitting one
vpp_qsv=w=..:h=..:pad_w=..:pad_h=..:pad_x=-1:pad_y=-1:pad_color=black.

Pad-only chains, scale-only chains, and the software fallback are
unchanged. The pad_w capability gate still governs the combined form.

Co-Authored-By: Claude Fable 5 <[email protected]>
@M-Pepper

Copy link
Copy Markdown
Owner Author

Superseded by the upstream PR: ErsatzTV#182

@M-Pepper M-Pepper closed this Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant