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, } } }