From f3f8ae18b7e21aaa7b350441ffae7bc30826d5c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 27 Nov 2026 14:19:07 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20share=20clarity:=20bits=20p?= =?UTF-8?q?er=20pixel=20doubled=20(AV1/H265=200.12,=20H264=200.16,=20VP9?= =?UTF-8?q?=200.14,=20VP8=200.18)=20with=20average=20=3D=20ceiling,=20BT.7?= =?UTF-8?q?09=20limited=20colour=20tag,=20decode=20width=20from=20the=20re?= =?UTF-8?q?al=20contain/cover=20rect=20so=20the=20viewer=20samples=20once;?= =?UTF-8?q?=20edith=209876fb67=20(desktop=20hint,=20quality=20level,=20CDE?= =?UTF-8?q?F,=20bilinear=20chroma)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/client/Cargo.toml | 22 +++++++++++----------- crates/client/src/gui/surface.rs | 15 ++++++++++++--- crates/client/src/share/encode.rs | 15 +++++++++------ crates/common/src/share.rs | 8 ++++---- 4 files changed, 36 insertions(+), 24 deletions(-) diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index dc828a6..7c90fbe 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 = "511a95b5" } -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } ureq = "3.5.2" bytes = "1.12.2" tracing = "0.1.44" diff --git a/crates/client/src/gui/surface.rs b/crates/client/src/gui/surface.rs index 5ab9e37..b4fce6d 100644 --- a/crates/client/src/gui/surface.rs +++ b/crates/client/src/gui/surface.rs @@ -67,11 +67,20 @@ impl Render for Surface { }; let network = self.network.clone(); let ((user_id, kind), id) = (self.source, self.id); + let aspect = self.frame.as_ref().map_or(WIDE, |frame| { + let size = frame.size(0); + size.width.0 as f32 / size.height.0.max(1) as f32 + }); + let cover = self.cover; let measure = canvas( move |bounds, window, _| { - let size = bounds.size; - let width = f32::from(size.width).max(f32::from(size.height) * WIDE); - let width = (width * window.scale_factor()).ceil() as u32; + let (width, height) = (f32::from(bounds.size.width), f32::from(bounds.size.height)); + let width = if cover { + width.max(height * aspect) + } else { + width.min(height * aspect) + }; + let width = (width * window.scale_factor()).round() as u32; network.show_share(user_id, kind, id, Some(width)); }, |_, _, _, _| {}, diff --git a/crates/client/src/share/encode.rs b/crates/client/src/share/encode.rs index eab741b..cada943 100644 --- a/crates/client/src/share/encode.rs +++ b/crates/client/src/share/encode.rs @@ -204,6 +204,12 @@ mod hardware { const VULKAN_ATTEMPTS: u32 = 5; const VULKAN_RETRY: std::time::Duration = std::time::Duration::from_millis(100); const RATE_BUFFER_MS: u32 = 66; + const BT709_LIMITED: ec_hw::types::Colour = ec_hw::types::Colour { + primaries: 1, + transfer: 1, + matrix: 1, + full_range: false, + }; use common::share::Codec; @@ -212,14 +218,10 @@ 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: average(bitrate), + bitrate, framerate: (fps, 1), })); } @@ -347,10 +349,11 @@ mod hardware { }; let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height); config.framerate = (settings.fps, 1); - config.bitrate = average(settings.bitrate); + config.bitrate = settings.bitrate; config.gop_size = settings.gop; config.rate_control = ec_hw::RateControlMode::VariableBitrate; config.buffer_ms = Some(RATE_BUFFER_MS); + config.colour = Some(BT709_LIMITED); let encoder = open_vulkan(config, settings.codec) .or_else(|| report(ec_hw::HwEncoder::open(config, None)))?; tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened"); diff --git a/crates/common/src/share.rs b/crates/common/src/share.rs index 6211e67..83b9c19 100644 --- a/crates/common/src/share.rs +++ b/crates/common/src/share.rs @@ -31,10 +31,10 @@ impl Codec { pub fn bits_per_pixel(self) -> f32 { match self { - Self::Vp8 => 0.1, - Self::H264 => 0.09, - Self::Vp9 => 0.07, - Self::H265 | Self::Av1 => 0.06, + Self::Vp8 => 0.18, + Self::H264 => 0.16, + Self::Vp9 => 0.14, + Self::H265 | Self::Av1 => 0.12, } } }