perf(codec): upgrade x264 preset and downscale to the receiver display
Two quality improvements: Preset: ultrafast -> veryfast. Unlocks Main profile with CABAC entropy coding, hexagonal motion search, 3 reference frames, and adaptive quantization — typically 30-40% better quality at the same bitrate. The desktop handles the extra encoding cost trivially (150+ fps at 1080p). Downscaling: the receiver now advertises its display resolution in the signaling answer (display_width/display_height, 0 = unknown). When the capture exceeds the display (e.g. 2256x1504 source on a 1920x1080 receiver), the sender scales down preserving aspect ratio before encoding — the same sws_scale pass that already converts the pixel format also handles the resolution change, so there is no extra step. This concentrates the entire bitrate into pixels the display actually shows (~2.7x more bits per visible pixel at 4000 kbps when going from 2256x1504 to 1620x1080). The renderer caches the display size during window creation (native monitor resolution in fullscreen/KMSDRM; window size otherwise). The receiver includes it in every signaling answer; the sender pipeline computes aspect-preserving, even-rounded scaled dimensions when the display is smaller than the capture. meson test 5/5 in both configurations, valgrind clean.
This commit is contained in:
@@ -22,6 +22,11 @@ struct SenderPipelineConfig {
|
||||
// Session identity from signaling; written to the sender state file for
|
||||
// status widgets (waybar) and one-click restarts.
|
||||
std::string session_id;
|
||||
// The receiver's display resolution (0 = unknown). The sender downscales
|
||||
// to this before encoding so bitrate is not spent on pixels the display
|
||||
// cannot show.
|
||||
int max_encode_width = 0;
|
||||
int max_encode_height = 0;
|
||||
};
|
||||
|
||||
struct ReceiverPipelineConfig {
|
||||
|
||||
@@ -29,6 +29,10 @@ struct SessionAnswer {
|
||||
// The address may be empty: the sender then targets the address of its
|
||||
// signaling connection and the port carried here.
|
||||
Endpoint rtp_endpoint;
|
||||
// The receiver's display resolution (0 = unknown). The sender may
|
||||
// downscale to this to avoid encoding pixels the display cannot show.
|
||||
int display_width = 0;
|
||||
int display_height = 0;
|
||||
};
|
||||
|
||||
// Picture Loss Indication: the receiver asks the sender for a keyframe
|
||||
|
||||
@@ -24,6 +24,11 @@ class Renderer {
|
||||
// Present one decoded frame. Returns false if the window was closed.
|
||||
virtual bool present(const DecodedFrame& frame) = 0;
|
||||
|
||||
// The display resolution (native monitor size in fullscreen mode).
|
||||
// Used by the receiver to tell the sender what resolution to encode at.
|
||||
virtual int display_width() const = 0;
|
||||
virtual int display_height() const = 0;
|
||||
|
||||
// Pump events (window close, resize). Non-blocking.
|
||||
virtual bool poll_events() = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user