From 040e8d45e320a52cc93c4d16b141dac5d6c23428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Thu, 26 Nov 2026 07:47:21 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20perf:=20share=20encoders=20use=20VB?= =?UTF-8?q?R=20capped=20at=20the=20bitrate=20ceiling=20(edith=5Fcodecs=202?= =?UTF-8?q?99aff6),=20static=20and=20scrolling=20screens=20drop=20from=20~?= =?UTF-8?q?30=20Mbps=20to=20under=201=20Mbps,=20H265=20and=20H264=20bpp=20?= =?UTF-8?q?lowered?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/Cargo.toml | 22 +++++++++++----------- crates/client/src/share/encode.rs | 10 +++++++--- crates/common/src/share.rs | 7 ++++--- 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 3b61f4f..2bf82df 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -12,17 +12,17 @@ tokio.workspace = true quinn = { workspace = true, features = ["rustls-ring"] } gpui-kit = { version = "0.11.0", features = ["syntect"] } -ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } ureq = "3.5.2" bytes = "1.12.2" tracing = "0.1.44" diff --git a/crates/client/src/share/encode.rs b/crates/client/src/share/encode.rs index daf78f5..f539f64 100644 --- a/crates/client/src/share/encode.rs +++ b/crates/client/src/share/encode.rs @@ -149,10 +149,14 @@ mod hardware { pub struct Encoder(ec_hw::HwEncoder); + fn average(ceiling: u32) -> u32 { + ceiling / 3 * 2 + } + impl Encoder { pub fn tune(&mut self, bitrate: u32, fps: u32) { report(self.0.tune(ec_hw::Tunings { - bitrate, + bitrate: average(bitrate), framerate: (fps, 1), })); } @@ -229,9 +233,9 @@ mod hardware { }; let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height); config.framerate = (settings.fps, 1); - config.bitrate = settings.bitrate; + config.bitrate = average(settings.bitrate); config.gop_size = settings.gop; - config.rate_control = ec_hw::RateControlMode::ConstantBitrate; + config.rate_control = ec_hw::RateControlMode::VariableBitrate; let encoder = report(ec_hw::HwEncoder::open(config, None))?; tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened"); Some(Encoder(encoder)) diff --git a/crates/common/src/share.rs b/crates/common/src/share.rs index 05bc487..8f210f7 100644 --- a/crates/common/src/share.rs +++ b/crates/common/src/share.rs @@ -31,9 +31,10 @@ impl Codec { pub fn bits_per_pixel(self) -> f32 { match self { - Self::H264 | Self::Vp8 => 0.1, - Self::H265 | Self::Vp9 => 0.07, - Self::Av1 => 0.06, + Self::Vp8 => 0.1, + Self::H264 => 0.09, + Self::Vp9 => 0.07, + Self::H265 | Self::Av1 => 0.06, } } }