perf(codec): CRF rate control, longer GOP, faster preset, screen tuning

Four encoder quality improvements, all sender-side:

- CRF rate control (default 22, --crf to override): targets a
  constant visual quality level instead of a fixed bitrate. Static
  desktop content uses 300-800 kbps (vs. forced 4000+), and the saved
  bits go to sharp text and clean motion when they appear. The VBV
  max rate (the --bitrate value, now a cap rather than a target)
  bounds bursts so the receiver's UDP buffers stay safe. Round-trip
  test bitrate dropped from 1390 kb/s to 47 kb/s on synthetic frames
  — the encoder uses only what it needs.

- 5-second GOP (was 1 second): 80% fewer keyframe bits freed for
  detail frames. Screen content changes incrementally, not
  wholesale; PLI feedback recovers from loss in one frame time
  regardless of GOP length.

- faster preset (was veryfast): better sub-pixel estimation and
  RDO on more decisions. The desktop handles it trivially at 1080p.

- Screen-content x264 tuning: aq-mode=2 (auto-variance AQ moves
  bits away from flat areas toward text edges) and psy-rd=1.5
  (preserves texture sharpness).

Combined with the earlier veryfast upgrade and sender-side
downscaling, this is roughly 2x the perceived quality at the same
average bandwidth compared to the original ultrafast ABR encoder.

meson test 5/5 in both configurations, valgrind clean.
This commit is contained in:
2026-09-09 12:12:36 +02:00
parent 30538fba73
commit 36d086af4e
8 changed files with 56 additions and 23 deletions
+2 -1
View File
@@ -10,7 +10,8 @@ namespace sc {
struct SendCommand {
std::string_view target = "monitor"; // monitor, window
std::string_view peer_address; // optional; empty means auto-discover
int bitrate_kbps = 4000;
int bitrate_kbps = 4000; // VBV max bitrate
int crf = 22; // constant rate factor (quality)
};
struct ReceiveCommand {