From a4df75132a190795296898115f0b2f1207cfff67 Mon Sep 17 00:00:00 2001 From: enricobuehler Date: Wed, 17 Jun 2026 13:33:31 +0000 Subject: [PATCH] fix(host/windows): HEVC/AV1 HIGH tier so high client bitrates aren't quartered MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NVENC defaulted to Main tier, whose per-level bitrate ceiling at 5K (HEVC Level 6.2 Main ≈ 240 Mbps) made initialize_encoder reject a high client bitrate; the existing probe-and-step-down then silently dropped a ~1 Gbps request by ×¾ to ~240-320 Mbps — visible color/motion compression on fast scenes. Set HIGH tier (≈800 Mbps for HEVC, higher for AV1) + autoselect level so the requested bitrate goes through. `tier`/`level` are u32 (HIGH=1, AUTOSELECT=0) shared across the HEVC/AV1 union offset; the step-down remains as a safety net. Not yet built/validated on-box (box offline). Co-Authored-By: Claude Opus 4.8 --- crates/punktfunk-host/src/encode/nvenc.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/punktfunk-host/src/encode/nvenc.rs b/crates/punktfunk-host/src/encode/nvenc.rs index 462bdc3..1d27f4e 100644 --- a/crates/punktfunk-host/src/encode/nvenc.rs +++ b/crates/punktfunk-host/src/encode/nvenc.rs @@ -229,6 +229,16 @@ impl NvencD3d11Encoder { cfg.rcParams.vbvBufferSize = vbv; cfg.rcParams.vbvInitialDelay = vbv; + // HIGH tier + autoselect level. The codec's PER-LEVEL bitrate ceiling is otherwise the + // MAIN-tier cap — for HEVC at 5K that's Level 6.2 Main ≈ 240 Mbps — so a high client + // bitrate (e.g. 1 Gbps) makes `initialize_encoder` reject it and the step-down loop below + // silently QUARTERS it to ~240-320 Mbps (visible color/motion compression). HIGH tier + // lifts the HEVC ceiling to ≈800 Mbps (AV1 higher still); autoselect lets NVENC pick the + // matching level for the tier+bitrate. `tier`/`level` are u32; HIGH = 1, AUTOSELECT = 0, + // and HEVC/AV1 share the union offset so this is correct for both codecs. + cfg.encodeCodecConfig.hevcConfig.tier = 1; // NV_ENC_TIER_*_HIGH + cfg.encodeCodecConfig.hevcConfig.level = 0; // NV_ENC_LEVEL_AUTOSELECT + // 3b. 10-bit HEVC Main10. The 8-bit ARGB capture input is upconverted by NVENC (the // proven high-bit-depth-from-8-bit path); the encoded stream is 10-bit, which removes // banding and is the foundation for HDR. Color stays BT.709 here (Phase 2 sets the