From 06cc219cd48c3e202a7478f3e6e11b5c76411fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 25 Nov 2026 09:54:59 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20decode=20h265=20shares=20th?= =?UTF-8?q?rough=20vulkan=20and=20fall=20back=20on=20decode=20errors?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bumps edith_codecs for Vulkan H.265 decode. When a hardware decoder rejects a stream, such as 10-bit HEVC on Windows where there is no VA-API, the viewer switches to the software decoder and retries the packet. --- crates/client/Cargo.toml | 32 +++++++++++++------------- crates/client/src/media/decode.rs | 38 ++++++++++++++++++++----------- 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 736e8a3..b662b9a 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -10,22 +10,22 @@ tokio.workspace = true quinn = { workspace = true, features = ["rustls-ring", "platform-verifier"] } gpui-kit = { version = "0.11.0", features = ["syntect"] } -ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-mp4 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-matroska = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-aac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-mp3 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-vorbis = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } -ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "18fc8572e95c39dc8ac47448a887172471ced4a6" } +ec-opus = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-core = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-probe = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-mp4 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-matroska = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-ogg = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-h264 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-vp8 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-aac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-mp3 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-vorbis = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-flac = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-h265 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-hw = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-vp9 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } +ec-av1 = { git = "https://git.tahinli.com/Tahinli/edith_codecs.git", rev = "a11df786c72d7ca9cf5dff256713f18b20942941" } ureq = "3.5.2" bytes = "1.12.2" tracing = "0.1.44" diff --git a/crates/client/src/media/decode.rs b/crates/client/src/media/decode.rs index ec040a0..216d1a8 100644 --- a/crates/client/src/media/decode.rs +++ b/crates/client/src/media/decode.rs @@ -146,7 +146,7 @@ pub enum VideoDecoder { H265(Box), Vp9(Box), Av1(Box), - Hardware(Box, ec_hw::Codec), + Hardware(Box, Codec), } impl VideoDecoder { @@ -251,10 +251,17 @@ impl VideoDecoder { Vec::new() } }, - VideoDecoder::Hardware(decoder, _) => { + VideoDecoder::Hardware(decoder, codec) => { if let Err(error) = decoder.decode(&packet.data, packet.pts.unwrap_or(0)) { - warn!("video packet skipped: {error}"); - return Vec::new(); + warn!( + ?codec, + "hardware decode failed, switching to software: {error}" + ); + let Some(software) = software(*codec) else { + return Vec::new(); + }; + *self = software; + return self.send(packet); } hardware_pictures(decoder) } @@ -287,7 +294,9 @@ impl VideoDecoder { VideoDecoder::Vp9(decoder) => **decoder = ec_vp9::decode::Decoder::new(), VideoDecoder::Av1(decoder) => **decoder = av1_decoder(), VideoDecoder::Hardware(decoder, codec) => { - if let Ok(fresh) = ec_hw::HwDecoder::open(*codec) { + if let Some(fresh) = + hardware_codec(*codec).and_then(|codec| ec_hw::HwDecoder::open(codec).ok()) + { **decoder = fresh; } } @@ -295,15 +304,18 @@ impl VideoDecoder { } } +fn hardware_codec(codec: Codec) -> Option { + match codec { + Codec::H264 => Some(ec_hw::Codec::H264), + Codec::H265 => Some(ec_hw::Codec::H265), + Codec::Vp9 => Some(ec_hw::Codec::Vp9), + Codec::Av1 => Some(ec_hw::Codec::Av1), + Codec::Vp8 => None, + } +} + fn hardware(codec: Codec) -> Option { - let codec = match codec { - Codec::H264 => ec_hw::Codec::H264, - Codec::H265 => ec_hw::Codec::H265, - Codec::Vp9 => ec_hw::Codec::Vp9, - Codec::Av1 => ec_hw::Codec::Av1, - Codec::Vp8 => return None, - }; - let decoder = ec_hw::HwDecoder::open(codec).ok()?; + let decoder = ec_hw::HwDecoder::open(hardware_codec(codec)?).ok()?; tracing::info!(backend = ?decoder.backend(), ?codec, "hardware decoder opened"); Some(VideoDecoder::Hardware(Box::new(decoder), codec)) }