forge
Explore
Log in

Don't you dare go Hollow

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 commit

f3f8ae18b7e21aaa7b350441ffae7bc30826d5c9Ahmet Kaan GümüşParent: 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)
Show full message
✨ 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)
crates/client/Cargo.tomlmodified+11 -11
@@ -12,17 +12,17 @@ tokio.workspace = true
1212 quinn = { workspace = true, features = ["rustls-ring"] }
1313
1414 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" }
2626 ureq = "3.5.2"
2727 bytes = "1.12.2"
2828 tracing = "0.1.44"
crates/client/src/gui/surface.rsmodified+12 -3
@@ -67,11 +67,20 @@ impl Render for Surface {
6767 };
6868 let network = self.network.clone();
6969 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;
7075 let measure = canvas(
7176 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;
7584 network.show_share(user_id, kind, id, Some(width));
7685 },
7786 |_, _, _, _| {},
crates/client/src/share/encode.rsmodified+9 -6
@@ -204,6 +204,12 @@ mod hardware {
204204 const VULKAN_ATTEMPTS: u32 = 5;
205205 const VULKAN_RETRY: std::time::Duration = std::time::Duration::from_millis(100);
206206 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+ };
207213
208214 use common::share::Codec;
209215
@@ -212,14 +218,10 @@ mod hardware {
212218
213219 pub struct Encoder(ec_hw::HwEncoder);
214220
215- fn average(ceiling: u32) -> u32 {
216- ceiling / 3 * 2
217- }
218-
219221 impl Encoder {
220222 pub fn tune(&mut self, bitrate: u32, fps: u32) {
221223 report(self.0.tune(ec_hw::Tunings {
222- bitrate: average(bitrate),
224+ bitrate,
223225 framerate: (fps, 1),
224226 }));
225227 }
@@ -347,10 +349,11 @@ mod hardware {
347349 };
348350 let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height);
349351 config.framerate = (settings.fps, 1);
350- config.bitrate = average(settings.bitrate);
352+ config.bitrate = settings.bitrate;
351353 config.gop_size = settings.gop;
352354 config.rate_control = ec_hw::RateControlMode::VariableBitrate;
353355 config.buffer_ms = Some(RATE_BUFFER_MS);
356+ config.colour = Some(BT709_LIMITED);
354357 let encoder = open_vulkan(config, settings.codec)
355358 .or_else(|| report(ec_hw::HwEncoder::open(config, None)))?;
356359 tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened");
crates/common/src/share.rsmodified+4 -4
@@ -31,10 +31,10 @@ impl Codec {
3131
3232 pub fn bits_per_pixel(self) -> f32 {
3333 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,
3838 }
3939 }
4040 }