From 244733778745e48fcc7163cfc97072d2483ad726 Mon Sep 17 00:00:00 2001 From: ferstar Date: Sat, 24 Oct 2026 01:27:45 +0800 Subject: [PATCH] vaapi: raise the in-process RC max_qp to 51 so capped presets reach the hardware floor (#33) max_qp is the worst-quality guardrail, not an operating point: the VCN VBR loop picks QP per frame inside [min_qp, max_qp]. Capping it at 44 stopped the encoder from degrading far enough to approach the bitrate target when the content needs more than the QP-44 floor; 51 is the codec maximum and matches what the FFmpeg process pipeline already runs at (max_qp unset). Measured (Cezanne, in-process VAAPI, tier 1 / 1M target, 600 frames): - 1920x1200 fullscreen testsrc2: 1.77 -> 1.36 Mbps - 2560x1600 fullscreen testsrc2: 4.16 -> 2.60 Mbps - regression: normal dynamic scene tier 1 ~0.9-1.0 Mbps, tier 3 unchanged --- c_engine/vaapi_engine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/c_engine/vaapi_engine.c b/c_engine/vaapi_engine.c index c06ac09..16e228f 100644 --- a/c_engine/vaapi_engine.c +++ b/c_engine/vaapi_engine.c @@ -732,7 +732,9 @@ int vaapi_encode_frame( rc.window_size = 1000; rc.initial_qp = 28; rc.min_qp = 16; - rc.max_qp = 44; + // The driver's VBR raises QP only up to max_qp; 44 blocked the capped presets from reaching + // the QP 51 hardware floor on hard content (2560x1600 testsrc2: 4.16 -> 2.60 Mbps, #33) + rc.max_qp = 51; rc.rc_flags.bits.disable_frame_skip = 1; // a remote desktop must not drop frames silently b.misc[b.misc_n++] = vaapi_create_misc_buffer(engine, VAEncMiscParameterTypeRateControl, &rc, sizeof(rc));