Skip to content

fix: skip HRD parameters when no target bitrate is set - #30

Open
maryny4 wants to merge 1 commit into
MuNeNiCK:mainfrom
maryny4:fix/vaapi-hrd-zero-bitrate
Open

fix: skip HRD parameters when no target bitrate is set#30
maryny4 wants to merge 1 commit into
MuNeNiCK:mainfrom
maryny4:fix/vaapi-hrd-zero-bitrate

Conversation

@maryny4

@maryny4 maryny4 commented Aug 6, 2026

Copy link
Copy Markdown

Problem

Selecting rate_control = "cqp" crashes the server on every client connection (SIGSEGV in a systemd restart loop). The crashing frame is inside Mesa radeonsi via vaEndPicture.

CQP mode has no target bitrate, so the rate-control policy carries bits_per_second = 0 — and the HRD misc buffer was built from it: buffer_size = 0, initial_buffer_fullness = 0. Mesa radeonsi segfaults on a zero-sized HRD buffer instead of rejecting it (driver bug, to be reported separately); ffmpeg's h264_vaapi works on the same driver because it never submits HRD parameters without a bitrate.

Bisected offline with the vaapi_encode_probe harness on radeonsi (Raphael iGPU, Mesa 26.1.6): the rate-control and frame-rate misc buffers are fine in every combination; any combination that includes the zero-sized HRD buffer reproduces the segfault.

Fix

HRD parameters are meaningless without a target bitrate — skip the HRD buffer when bits_per_second = 0. VBR behavior is unchanged. A CQP variant of the ignored probe test now guards the path; after the fix it produces a valid stream that decodes to the expected solid color.

cargo fmt --check, clippy -- -D warnings, cargo test (both feature sets) pass; verified live — the previously crashing configuration now serves a stable CQP session.

The branch is self-contained: it carries only the CQP probe variant. If #26 (which adds the VBR probe) lands as well, the two tests coexist; git may ask for a trivial context rebase on whichever merges second.

Mesa radeonsi segfaults inside vaEndPicture when it receives a
VAEncMiscParameterHRD buffer with buffer_size = 0, which is exactly
what CQP mode submitted (bits_per_second = 0): every client connection
crashed the server in a restart loop. ffmpeg's h264_vaapi works on the
same driver because it never sends HRD parameters without a bitrate.

Bisected offline with the vaapi_encode_probe harness: rate-control and
frame-rate buffers are fine, any combination including the zero-sized
HRD buffer reproduces the segfault. HRD is meaningless without a target
bitrate, so skip it in that case; a CQP variant of the probe now guards
the path.
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