Share encoders use VBR capped at the bitrate ceiling (edith_codecs 299aff6), static and scrolling screens drop from ~30 Mbps to under 1 Mbps, H265 and H264 bpp lowered
Browse files at this commit040e8d45e320a52cc93c4d16b141dac5d6c23428Parent: c5e1fb0- perf
- share encoders use VBR capped at the bitrate ceiling (edith_codecs 299aff6), static and scrolling screens drop from ~30 Mbps to under 1 Mbps, H265 and H264 bpp lowered
3 changed files +22 -17
- crates/client/Cargo.toml +11 -11
- crates/client/src/share/encode.rs +7 -3
- crates/common/src/share.rs +4 -3
crates/client/Cargo.tomlmodified+11 -11
| @@ -12,17 +12,17 @@ tokio.workspace = true | |||
| 12 | quinn = { workspace = true, features = ["rustls-ring"] } | 12 | quinn = { workspace = true, features = ["rustls-ring"] } |
| 13 | 13 | ||
| 14 | gpui-kit = { version = "0.11.0", features = ["syntect"] } | 14 | gpui-kit = { version = "0.11.0", features = ["syntect"] } |
| 15 | -ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 15 | +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 16 | -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 16 | +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 17 | -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 17 | +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 18 | -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 18 | +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 19 | -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 19 | +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 20 | -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 20 | +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 21 | -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 21 | +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 22 | -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 22 | +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 23 | -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 23 | +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 24 | -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 24 | +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 25 | -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "c2d94dab62fc63b19f3abf4efefbb6e6131955b4" } | 25 | +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "299aff6793c2ca5b1b0cd9f192393245e4ee0af6" } |
| 26 | ureq = "3.5.2" | 26 | ureq = "3.5.2" |
| 27 | bytes = "1.12.2" | 27 | bytes = "1.12.2" |
| 28 | tracing = "0.1.44" | 28 | tracing = "0.1.44" |
crates/client/src/share/encode.rsmodified+7 -3
| @@ -149,10 +149,14 @@ mod hardware { | |||
| 149 | 149 | ||
| 150 | pub struct Encoder(ec_hw::HwEncoder); | 150 | pub struct Encoder(ec_hw::HwEncoder); |
| 151 | 151 | ||
| 152 | + fn average(ceiling: u32) -> u32 { | ||
| 153 | + ceiling / 3 * 2 | ||
| 154 | + } | ||
| 155 | + | ||
| 152 | impl Encoder { | 156 | impl Encoder { |
| 153 | pub fn tune(&mut self, bitrate: u32, fps: u32) { | 157 | pub fn tune(&mut self, bitrate: u32, fps: u32) { |
| 154 | report(self.0.tune(ec_hw::Tunings { | 158 | report(self.0.tune(ec_hw::Tunings { |
| 155 | - bitrate, | 159 | + bitrate: average(bitrate), |
| 156 | framerate: (fps, 1), | 160 | framerate: (fps, 1), |
| 157 | })); | 161 | })); |
| 158 | } | 162 | } |
| @@ -229,9 +233,9 @@ mod hardware { | |||
| 229 | }; | 233 | }; |
| 230 | let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height); | 234 | let mut config = ec_hw::EncoderConfig::new(codec, settings.width, settings.height); |
| 231 | config.framerate = (settings.fps, 1); | 235 | config.framerate = (settings.fps, 1); |
| 232 | - config.bitrate = settings.bitrate; | 236 | + config.bitrate = average(settings.bitrate); |
| 233 | config.gop_size = settings.gop; | 237 | config.gop_size = settings.gop; |
| 234 | - config.rate_control = ec_hw::RateControlMode::ConstantBitrate; | 238 | + config.rate_control = ec_hw::RateControlMode::VariableBitrate; |
| 235 | let encoder = report(ec_hw::HwEncoder::open(config, None))?; | 239 | let encoder = report(ec_hw::HwEncoder::open(config, None))?; |
| 236 | tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened"); | 240 | tracing::info!(backend = ?encoder.backend(), ?codec, "share hardware encoder opened"); |
| 237 | Some(Encoder(encoder)) | 241 | Some(Encoder(encoder)) |
crates/common/src/share.rsmodified+4 -3
| @@ -31,9 +31,10 @@ impl Codec { | |||
| 31 | 31 | ||
| 32 | pub fn bits_per_pixel(self) -> f32 { | 32 | pub fn bits_per_pixel(self) -> f32 { |
| 33 | match self { | 33 | match self { |
| 34 | - Self::H264 | Self::Vp8 => 0.1, | 34 | + Self::Vp8 => 0.1, |
| 35 | - Self::H265 | Self::Vp9 => 0.07, | 35 | + Self::H264 => 0.09, |
| 36 | - Self::Av1 => 0.06, | 36 | + Self::Vp9 => 0.07, |
| 37 | + Self::H265 | Self::Av1 => 0.06, | ||
| 37 | } | 38 | } |
| 38 | } | 39 | } |
| 39 | } | 40 | } |