From 5eec9962bad254bf8425974ba2969013446fcc63 Mon Sep 17 00:00:00 2001 From: Viktor Liu Date: Tue, 19 May 2026 12:40:05 +0200 Subject: [PATCH] Honour client JPEG quality fully now that backpressure caps it dynamically --- client/vnc/server/rfb.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/client/vnc/server/rfb.go b/client/vnc/server/rfb.go index a7c341de5..11a288eb3 100644 --- a/client/vnc/server/rfb.go +++ b/client/vnc/server/rfb.go @@ -544,10 +544,9 @@ func newTightStateWithLevels(qualityLevel, compressLevel int) *tightState { // jpegQualityForLevel maps a 0..9 client preference to a JPEG quality value. // Returns 0 when no preference is set (-1), letting the encoder fall back -// to the area-based tiers. The output is capped at jpegQualityClientCap -// so a client asking for the highest quality does not push per-frame JPEG -// byte counts into a regime that overwhelms bandwidth-constrained -// transports. Within the cap the mapping is still linear. +// to the area-based tiers. The encoder lowers this dynamically when the +// socket is backpressured, so this routine emits the unclamped, client- +// requested value. func jpegQualityForLevel(level int) int { if level < 0 { return 0 @@ -555,19 +554,9 @@ func jpegQualityForLevel(level int) int { if level > 9 { level = 9 } - q := 30 + level*7 - if q > jpegQualityClientCap { - q = jpegQualityClientCap - } - return q + return 30 + level*7 } -// jpegQualityClientCap upper-bounds the JPEG quality we honour from the -// client's QualityLevel pseudo-encoding. 50 keeps full-screen JPEGs in -// the same byte range as the area-tiered defaults used when the client -// does not express a preference. -const jpegQualityClientCap = 50 - // zlibLevelFor maps a 0..9 client preference to a zlib compression level. // Level 0 ("no compression") would emit larger output than input on most // rects, so we floor to BestSpeed (1). -1 (no preference) also picks