From 43606ce4bd615bba60c679f2e0f0085970df261f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 13:37:46 +0300 Subject: [PATCH] U16: remove HwDecoder open_16/open_dmabuf/next_frame_16/next_dmabuf (callers use open, next_picture and HwPicture::to_i420_16/export_dmabuf); migrate hw_decode and hw_ten --- crates/ec-hw/examples/hw_decode.rs | 24 ++++++++---------------- crates/ec-hw/examples/hw_ten.rs | 10 +++++----- crates/ec-hw/src/hw.rs | 30 ------------------------------ 3 files changed, 13 insertions(+), 51 deletions(-) diff --git a/crates/ec-hw/examples/hw_decode.rs b/crates/ec-hw/examples/hw_decode.rs index 1a69046d..99ca62bc 100644 --- a/crates/ec-hw/examples/hw_decode.rs +++ b/crates/ec-hw/examples/hw_decode.rs @@ -130,12 +130,7 @@ fn mixed_cases(dir: &Path) { } fn mixed_case(label: &str, codec: Codec, units: &[&[u8]], ten: bool, gpu: &ec_vk::Gpu) { - let mut reference = if ten { - HwDecoder::open_16(codec) - } else { - HwDecoder::open(codec) - } - .expect("open decoder"); + let mut reference = HwDecoder::open(codec).expect("open decoder"); let expected = decoded_planes(&mut reference, units, ten); let mut decoder = HwDecoder::open(codec).expect("open mixed decoder"); @@ -187,17 +182,12 @@ fn dmabuf_cases(dir: &Path) { } fn dmabuf_case(label: &str, codec: Codec, units: &[&[u8]], ten: bool) { - let mut reference = if ten { - HwDecoder::open_16(codec) - } else { - HwDecoder::open(codec) - } - .expect("open decoder"); + let mut reference = HwDecoder::open(codec).expect("open decoder"); assert_eq!(reference.backend(), Backend::Vk, "{label}: must decode on Vulkan"); let expected = decoded_planes(&mut reference, units, ten); let gpu = ec_vk::Gpu::open().expect("Vulkan device"); - let mut decoder = HwDecoder::open_dmabuf(codec).expect("open DMA-BUF decoder"); + let mut decoder = HwDecoder::open(codec).expect("open DMA-BUF decoder"); assert_eq!(decoder.backend(), Backend::Vk, "{label}: DMA-BUF must decode on Vulkan"); let mut got = Vec::new(); for (pts, unit) in units.iter().enumerate() { @@ -222,7 +212,8 @@ fn decoded_planes(decoder: &mut HwDecoder, units: &[&[u8]], ten: bool) -> Vec<(V fn take_planes(decoder: &mut HwDecoder, ten: bool, out: &mut Vec<(Vec, Vec)>) { if ten { - while let Some((_, frame)) = decoder.next_frame_16().expect("next frame") { + while let Some(picture) = decoder.next_picture().expect("next picture") { + let frame = picture.to_i420_16().expect("to_i420_16"); out.push(p010_planes(&frame)); } } else { @@ -250,8 +241,9 @@ fn p010_planes(frame: &I420_16) -> (Vec, Vec) { } fn collect_dmabuf(decoder: &mut HwDecoder, gpu: &ec_vk::Gpu, out: &mut Vec<(Vec, Vec)>) { - while let Some((_, picture)) = decoder.next_dmabuf().expect("next DMA-BUF") { - out.push(read_back(gpu, picture)); + while let Some(picture) = decoder.next_picture().expect("next picture") { + let dmabuf = picture.export_dmabuf().expect("export DMA-BUF"); + out.push(read_back(gpu, dmabuf)); } } diff --git a/crates/ec-hw/examples/hw_ten.rs b/crates/ec-hw/examples/hw_ten.rs index d7f5fb0e..668d6941 100644 --- a/crates/ec-hw/examples/hw_ten.rs +++ b/crates/ec-hw/examples/hw_ten.rs @@ -59,17 +59,17 @@ fn run( let stem = format!("{dir}/ten_{codec:?}_{name}_{backend:?}"); std::fs::write(format!("{stem}.bin"), &stream).expect("write bitstream"); - let mut decoder = HwDecoder::open_16(decode_codec(codec))?; + let mut decoder = HwDecoder::open(decode_codec(codec))?; let mut decoded = Vec::new(); for c in &coded { decoder.decode(&c.data, c.timestamp)?; - while let Some(frame) = decoder.next_frame_16()? { - decoded.push(frame); + while let Some(picture) = decoder.next_picture()? { + decoded.push((picture.timestamp, picture.to_i420_16()?)); } } decoder.flush()?; - while let Some(frame) = decoder.next_frame_16()? { - decoded.push(frame); + while let Some(picture) = decoder.next_picture()? { + decoded.push((picture.timestamp, picture.to_i420_16()?)); } let mut yuv = Vec::new(); diff --git a/crates/ec-hw/src/hw.rs b/crates/ec-hw/src/hw.rs index e13e53a6..ee29317e 100644 --- a/crates/ec-hw/src/hw.rs +++ b/crates/ec-hw/src/hw.rs @@ -12,8 +12,6 @@ use std::collections::VecDeque; use crate::error::{Error, Result}; use crate::output::HwPicture; use crate::picture::{I420, I420_16, RgbPicture}; -#[cfg(target_os = "linux")] -use crate::picture::DmaBufPicture; use crate::rate::{RateFeedback, hrd_buffer_ms}; use crate::types::{ Codec, CodedFrame, EncCodec, EncoderConfig, FrameMetadata, H264Profile, RateControlMode, @@ -1207,17 +1205,6 @@ impl HwDecoder { HwDecoder::open_with(codec, Some(output)) } - /// Same as [`HwDecoder::open`]: every picture can be asked for 10-bit I420 with [`HwPicture::to_i420_16`]. - pub fn open_16(codec: Codec) -> Result { - HwDecoder::open(codec) - } - - /// Same as [`HwDecoder::open`]: every picture can be asked for DMA-BUF file descriptors with [`HwPicture::export_dmabuf`]. Linux only. - #[cfg(target_os = "linux")] - pub fn open_dmabuf(codec: Codec) -> Result { - HwDecoder::open(codec) - } - fn open_with(codec: Codec, rgb: Option) -> Result { let mut reasons = Vec::new(); let born_epoch = crate::reset::gpu_reset_epoch(); @@ -1310,23 +1297,6 @@ impl HwDecoder { } } - /// The next picture in display order, as 10-bit I420 with its timestamp. - pub fn next_frame_16(&mut self) -> Result> { - match self.pull()? { - None => Ok(None), - Some(picture) => Ok(Some((picture.timestamp, picture.to_i420_16()?))), - } - } - - /// The next picture in display order, as DMA-BUF file descriptors with its timestamp. Linux only. - #[cfg(target_os = "linux")] - pub fn next_dmabuf(&mut self) -> Result> { - match self.pull()? { - None => Ok(None), - Some(picture) => Ok(Some((picture.timestamp, picture.export_dmabuf()?))), - } - } - /// The next picture in display order, as packed RGB with its timestamp. An error on a decoder not opened with [`HwDecoder::open_rgb`]. pub fn next_rgb(&mut self) -> Result> { let mut dst = RgbPicture::default();