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:
@@ -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 {
|
||||
|
||||
@@ -23,6 +23,12 @@ struct EncoderConfig {
|
||||
int height = 0;
|
||||
int frame_rate_num = 30;
|
||||
int frame_rate_den = 1;
|
||||
// CRF (constant rate factor, 0-51): the target visual quality level.
|
||||
// Lower = better quality. 23 is x264's default; screen content looks
|
||||
// good at 20-24.
|
||||
int crf = 22;
|
||||
// Maximum bitrate in kbps (the VBV cap). The encoder uses fewer bits on
|
||||
// static content and more on motion, but never exceeds this.
|
||||
int bitrate_kbps = 4000;
|
||||
bool hardware_accel = false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user