Share clarity: bits per pixel doubled (AV1/H265 0.12, H264 0.16, VP9 0.14, VP8 0.18) with average = ceiling, BT.709 limited colour tag, decode width from the real contain/cover rect so the viewer samples once
Browse files at this commitf3f8ae18b7e21aaa7b350441ffae7bc30826d5c9Parent: d3a62ab- feat
- share clarity: bits per pixel doubled (AV1/H265 0.12, H264 0.16, VP9 0.14, VP8 0.18) with average = ceiling, BT.709 limited colour tag, decode width from the real contain/cover rect so the viewer samples once
- edith 9876fb67 (desktop hint, quality level, CDEF, bilinear chroma)
4 changed files +36 -24
- crates/client/Cargo.toml +11 -11
- crates/client/src/gui/surface.rs +12 -3
- crates/client/src/share/encode.rs +9 -6
- crates/common/src/share.rs +4 -4
crates/client/Cargo.tomlmodified+11 -11
| @@ -12,17 +12,17 @@ tokio.workspace = true | ||
| 12 | 12 | quinn = { workspace = true, features = ["rustls-ring"] } |
| 13 | 13 | |
| 14 | 14 | gpui-kit = { version = "0.11.0", features = ["syntect"] } |
| 15 | -ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 16 | -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 17 | -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 18 | -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 19 | -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 20 | -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 21 | -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 22 | -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 23 | -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 24 | -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 25 | -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "511a95b5" } | |
| 15 | +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 16 | +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 17 | +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 18 | +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 19 | +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 20 | +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 21 | +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 22 | +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 23 | +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 24 | +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 25 | +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "9876fb67" } | |
| 26 | 26 | ureq = "3.5.2" |
| 27 | 27 | bytes = "1.12.2" |
| 28 | 28 | tracing = "0.1.44" |
crates/client/src/gui/surface.rsmodified+12 -3
| @@ -67,11 +67,20 @@ impl Render for Surface { | ||
| 67 | 67 | }; |
| 68 | 68 | let network = self.network.clone(); |
| 69 | 69 | let ((user_id, kind), id) = (self.source, self.id); |
| 70 | + let aspect = self.frame.as_ref().map_or(WIDE, |frame| { | |
| 71 | + let size = frame.size(0); | |
| 72 | + size.width.0 as f32 / size.height.0.max(1) as f32 | |
| 73 | + }); | |
| 74 | + let cover = self.cover; | |
| 70 | 75 | let measure = canvas( |
| 71 | 76 | move |bounds, window, _| { |
| 72 | - let size = bounds.size; | |
| 73 | - let width = f32::from(size.width).max(f32::from(size.height) * WIDE); | |
| 74 | - let width = (width * window.scale_factor()).ceil() as u32; | |
| 77 | + let (width, height) = (f32::from(bounds.size.width), f32::from(bounds.size.height)); | |
| 78 | + let width = if cover { | |
| 79 | + width.max(height * aspect) | |
| 80 | + } else { | |
| 81 | + width.min(height * aspect) | |
| 82 | + }; | |
| 83 | + let width = (width * window.scale_factor()).round() as u32; | |
| 75 | 84 | network.show_share(user_id, kind, id, Some(width)); |
| 76 | 85 | }, |
| 77 | 86 | |_, _, _, _| {}, |
crates/client/src/share/encode.rsmodified+9 -6
| @@ -204,6 +204,12 @@ mod hardware { | ||
| 204 | 204 | const VULKAN_ATTEMPTS: u32 = 5; |
| 205 | 205 | const VULKAN_RETRY: std::time::Duration = std::time::Duration::from_millis(100); |
| 206 | 206 | const RATE_BUFFER_MS: u32 = 66; |
| 207 | + const BT709_LIMITED: ec_hw::types::Colour = ec_hw::types::Colour { | |
| 208 | + primaries: 1, | |
| 209 | + transfer: 1, | |
| 210 | + matrix: 1, | |
| 211 | + full_range: false, | |
| 212 | + }; | |
| 207 | 213 | |
| 208 | 214 | use common::share::Codec; |
| 209 | 215 | |
| @@ -212,14 +218,10 @@ mod hardware { | ||
| 212 | 218 | |
| 213 | 219 | pub struct Encoder(ec_hw::HwEncoder); |
| 214 | 220 | |
| 215 | - fn average(ceiling: u32) -> u32 { | |
| 216 | - ceiling / 3 * 2 | |
| 217 | - } | |
| 218 | - | |
| 219 | 221 | impl Encoder { |
| 220 | 222 | pub fn tune(&mut self, bitrate: u32, fps: u32) { |
| 221 | 223 | report(self.0.tune(ec_hw::Tunings { |
| 222 | - bitrate: average(bitrate), | |
| 224 | + bitrate, | |
| 223 | 225 | framerate: (fps, 1), |
| 224 | 226 | })); |
| 225 | 227 | } |
| @@ -347,10 +349,11 @@ mod hardware { | ||
| 347 | 349 | }; |
| 348 | 350 | let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height); |
| 349 | 351 | config.framerate = (settings.fps, 1); |
| 350 | - config.bitrate = average(settings.bitrate); | |
| 352 | + config.bitrate = settings.bitrate; | |
| 351 | 353 | config.gop_size = settings.gop; |
| 352 | 354 | config.rate_control = ec_hw::RateControlMode::VariableBitrate; |
| 353 | 355 | config.buffer_ms = Some(RATE_BUFFER_MS); |
| 356 | + config.colour = Some(BT709_LIMITED); | |
| 354 | 357 | let encoder = open_vulkan(config, settings.codec) |
| 355 | 358 | .or_else(|| report(ec_hw::HwEncoder::open(config, None)))?; |
| 356 | 359 | tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened"); |
crates/common/src/share.rsmodified+4 -4
| @@ -31,10 +31,10 @@ impl Codec { | ||
| 31 | 31 | |
| 32 | 32 | pub fn bits_per_pixel(self) -> f32 { |
| 33 | 33 | match self { |
| 34 | - Self::Vp8 => 0.1, | |
| 35 | - Self::H264 => 0.09, | |
| 36 | - Self::Vp9 => 0.07, | |
| 37 | - Self::H265 | Self::Av1 => 0.06, | |
| 34 | + Self::Vp8 => 0.18, | |
| 35 | + Self::H264 => 0.16, | |
| 36 | + Self::Vp9 => 0.14, | |
| 37 | + Self::H265 | Self::Av1 => 0.12, | |
| 38 | 38 | } |
| 39 | 39 | } |
| 40 | 40 | } |