mirror of
https://github.com/VallierDev/uu-remote-linux.git
synced 2026-11-17 01:00:41 +01:00
viewer: decode H.265 and request 4:4:4
Offer H.265 (RFC 7798) next to H.264 and list H.265 and 4:4:4 decoder caps; the host picks the codec. Depacketize single NAL, AP and FU units with the existing reorder/loss handling and decode with the ffmpeg CLI (-f hevc). UU_VIEWER_CHROMA=444 requests true color via CaptureSettingRequest field 7 and follows CaptureSettingSync; UU_VIEWER_CODEC=h264 keeps H.264 only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
5c5958115a
commit
693660ed85
18 files changed
+368
-52
No files matched your search
+14
-7
@@ -1,29 +1,36 @@
|
||||
//! Uses the same optional FFmpeg dependency as the host inproc-av feature.
|
||||
use super::desktop::{Decoder,Frame};
|
||||
use ffmpeg_next as av;
|
||||
pub struct Ffmpeg { decoder:av::decoder::Video }
|
||||
use super::media::Codec;
|
||||
pub struct Ffmpeg { decoder:av::decoder::Video, codec:Codec }
|
||||
impl Ffmpeg {
|
||||
pub fn new()->Result<Self,String> {
|
||||
Self::with_codec(Codec::H264)
|
||||
}
|
||||
fn with_codec(kind:Codec)->Result<Self,String>{
|
||||
av::init().map_err(|_|"FFmpeg initialization failed")?;
|
||||
// Library diagnostics can contain bitstream data; suppress them globally in this viewer process.
|
||||
av::log::set_level(av::log::Level::Quiet);
|
||||
let codec=av::decoder::find(av::codec::Id::H264).ok_or("H264 decoder unavailable")?;
|
||||
let decoder=av::codec::context::Context::new().decoder().open_as(codec).and_then(|d|d.video()).map_err(|_|"H264 decoder initialization failed")?;
|
||||
Ok(Self{decoder})
|
||||
let codec=av::decoder::find(match kind {Codec::H264=>av::codec::Id::H264,Codec::H265=>av::codec::Id::HEVC}).ok_or("Video decoder unavailable")?;
|
||||
let decoder=av::codec::context::Context::new().decoder().open_as(codec).and_then(|d|d.video()).map_err(|_|"Video decoder initialization failed")?;
|
||||
Ok(Self{decoder,codec:kind})
|
||||
}
|
||||
}
|
||||
impl Decoder for Ffmpeg {
|
||||
fn set_codec(&mut self,codec:Codec)->Result<(),String>{
|
||||
if self.codec!=codec {*self=Self::with_codec(codec)?;}Ok(())
|
||||
}
|
||||
fn reset(&mut self){self.decoder.flush();}
|
||||
fn decode(&mut self,au:&[u8])->Result<Vec<Frame>,String>{
|
||||
self.decoder.send_packet(&av::Packet::copy(au)).map_err(|_|"H264 packet rejected")?;
|
||||
self.decoder.send_packet(&av::Packet::copy(au)).map_err(|_|"Video packet rejected")?;
|
||||
let mut frames=Vec::new();let mut decoded=av::frame::Video::empty();
|
||||
loop {
|
||||
match self.decoder.receive_frame(&mut decoded) {
|
||||
Ok(())=>{},
|
||||
Err(av::Error::Other{errno}) if errno==libc::EAGAIN=>break,
|
||||
Err(_)=>return Err("H264 decode failed".into()),
|
||||
Err(_)=>return Err("Video decode failed".into()),
|
||||
}
|
||||
if decoded.is_corrupt(){return Err("Corrupt H264 frame".into())}
|
||||
if decoded.is_corrupt(){return Err("Corrupt video frame".into())}
|
||||
let (w,h)=(decoded.width(),decoded.height());
|
||||
if w==0 || h==0 || w>8192 || h>8192 {return Err("Decoded dimensions exceed limit".into())}
|
||||
let mut scaler=av::software::scaling::context::Context::get(decoded.format(),w,h,av::format::Pixel::RGB24,w,h,av::software::scaling::flag::Flags::BILINEAR).map_err(|_|"Frame conversion unavailable")?;
|
||||
|
||||
Reference in new issue
Block a user