Decode h265 shares through vulkan and fall back on decode errors
Browse files at this commit06cc219cd48c3e202a7478f3e6e11b5c76411fe4Parent: 4a982ae- feat
- decode h265 shares through vulkan and fall back on decode errors
2 changed files +41 -29
- crates/client/Cargo.toml +16 -16
- crates/client/src/media/decode.rs +25 -13
crates/client/Cargo.tomlmodified+16 -16
| @@ -10,22 +10,22 @@ tokio.workspace = true | |||
| 10 | quinn = { workspace = true, features = ["rustls-ring", "platform-verifier"] } | 10 | quinn = { workspace = true, features = ["rustls-ring", "platform-verifier"] } |
| 11 | 11 | ||
| 12 | gpui-kit = { version = "0.11.0", features = ["syntect"] } | 12 | gpui-kit = { version = "0.11.0", features = ["syntect"] } |
| 13 | -ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 13 | +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 14 | -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 14 | +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 15 | -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 15 | +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 16 | -ec-mp4 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 16 | +ec-mp4 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 17 | -ec-matroska = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 17 | +ec-matroska = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 18 | -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 18 | +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 19 | -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 19 | +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 20 | -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 20 | +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 21 | -ec-aac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 21 | +ec-aac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 22 | -ec-mp3 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 22 | +ec-mp3 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 23 | -ec-vorbis = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 23 | +ec-vorbis = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 24 | -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 24 | +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 25 | -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 25 | +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 26 | -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 26 | +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 27 | -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 27 | +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 28 | -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } | 28 | +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } |
| 29 | ureq = "3.5.2" | 29 | ureq = "3.5.2" |
| 30 | bytes = "1.12.2" | 30 | bytes = "1.12.2" |
| 31 | tracing = "0.1.44" | 31 | tracing = "0.1.44" |
crates/client/src/media/decode.rsmodified+25 -13
| @@ -146,7 +146,7 @@ pub enum VideoDecoder { | |||
| 146 | H265(Box<ec_h265::Decoder>), | 146 | H265(Box<ec_h265::Decoder>), |
| 147 | Vp9(Box<ec_vp9::decode::Decoder>), | 147 | Vp9(Box<ec_vp9::decode::Decoder>), |
| 148 | Av1(Box<ec_av1::stream::StreamDecoder>), | 148 | Av1(Box<ec_av1::stream::StreamDecoder>), |
| 149 | - Hardware(Box<ec_hw::HwDecoder>, ec_hw::Codec), | 149 | + Hardware(Box<ec_hw::HwDecoder>, Codec), |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | impl VideoDecoder { | 152 | impl VideoDecoder { |
| @@ -251,10 +251,17 @@ impl VideoDecoder { | |||
| 251 | Vec::new() | 251 | Vec::new() |
| 252 | } | 252 | } |
| 253 | }, | 253 | }, |
| 254 | - VideoDecoder::Hardware(decoder, _) => { | 254 | + VideoDecoder::Hardware(decoder, codec) => { |
| 255 | if let Err(error) = decoder.decode(&packet.data, packet.pts.unwrap_or(0)) { | 255 | if let Err(error) = decoder.decode(&packet.data, packet.pts.unwrap_or(0)) { |
| 256 | - warn!("video packet skipped: {error}"); | 256 | + warn!( |
| 257 | - return Vec::new(); | 257 | + ?codec, |
| 258 | + "hardware decode failed, switching to software: {error}" | ||
| 259 | + ); | ||
| 260 | + let Some(software) = software(*codec) else { | ||
| 261 | + return Vec::new(); | ||
| 262 | + }; | ||
| 263 | + *self = software; | ||
| 264 | + return self.send(packet); | ||
| 258 | } | 265 | } |
| 259 | hardware_pictures(decoder) | 266 | hardware_pictures(decoder) |
| 260 | } | 267 | } |
| @@ -287,7 +294,9 @@ impl VideoDecoder { | |||
| 287 | VideoDecoder::Vp9(decoder) => **decoder = ec_vp9::decode::Decoder::new(), | 294 | VideoDecoder::Vp9(decoder) => **decoder = ec_vp9::decode::Decoder::new(), |
| 288 | VideoDecoder::Av1(decoder) => **decoder = av1_decoder(), | 295 | VideoDecoder::Av1(decoder) => **decoder = av1_decoder(), |
| 289 | VideoDecoder::Hardware(decoder, codec) => { | 296 | VideoDecoder::Hardware(decoder, codec) => { |
| 290 | - if let Ok(fresh) = ec_hw::HwDecoder::open(*codec) { | 297 | + if let Some(fresh) = |
| 298 | + hardware_codec(*codec).and_then(|codec| ec_hw::HwDecoder::open(codec).ok()) | ||
| 299 | + { | ||
| 291 | **decoder = fresh; | 300 | **decoder = fresh; |
| 292 | } | 301 | } |
| 293 | } | 302 | } |
| @@ -295,15 +304,18 @@ impl VideoDecoder { | |||
| 295 | } | 304 | } |
| 296 | } | 305 | } |
| 297 | 306 | ||
| 307 | +fn hardware_codec(codec: Codec) -> Option<ec_hw::Codec> { | ||
| 308 | + match codec { | ||
| 309 | + Codec::H264 => Some(ec_hw::Codec::H264), | ||
| 310 | + Codec::H265 => Some(ec_hw::Codec::H265), | ||
| 311 | + Codec::Vp9 => Some(ec_hw::Codec::Vp9), | ||
| 312 | + Codec::Av1 => Some(ec_hw::Codec::Av1), | ||
| 313 | + Codec::Vp8 => None, | ||
| 314 | + } | ||
| 315 | +} | ||
| 316 | + | ||
| 298 | fn hardware(codec: Codec) -> Option<VideoDecoder> { | 317 | fn hardware(codec: Codec) -> Option<VideoDecoder> { |
| 299 | - let codec = match codec { | 318 | + let decoder = ec_hw::HwDecoder::open(hardware_codec(codec)?).ok()?; |
| 300 | - Codec::H264 => ec_hw::Codec::H264, | ||
| 301 | - Codec::H265 => ec_hw::Codec::H265, | ||
| 302 | - Codec::Vp9 => ec_hw::Codec::Vp9, | ||
| 303 | - Codec::Av1 => ec_hw::Codec::Av1, | ||
| 304 | - Codec::Vp8 => return None, | ||
| 305 | - }; | ||
| 306 | - let decoder = ec_hw::HwDecoder::open(codec).ok()?; | ||
| 307 | tracing::info!(backend = ?decoder.backend(), ?codec, "hardware decoder opened"); | 319 | tracing::info!(backend = ?decoder.backend(), ?codec, "hardware decoder opened"); |
| 308 | Some(VideoDecoder::Hardware(Box::new(decoder), codec)) | 320 | Some(VideoDecoder::Hardware(Box::new(decoder), codec)) |
| 309 | } | 321 | } |