forge
Explore
Log in

Don't you dare go Hollow

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

Browse files at this commit

43606ce4bd615bba60c679f2e0f0085970df261fAhmet Kaan GümüşParent: 065b59d
crates/ec-hw/examples/hw_decode.rsmodified+8 -16
@@ -130,12 +130,7 @@ fn mixed_cases(dir: &Path) {
130130 }
131131
132132 fn mixed_case(label: &str, codec: Codec, units: &[&[u8]], ten: bool, gpu: &ec_vk::Gpu) {
133- let mut reference = if ten {
134- HwDecoder::open_16(codec)
135- } else {
136- HwDecoder::open(codec)
137- }
138- .expect("open decoder");
133+ let mut reference = HwDecoder::open(codec).expect("open decoder");
139134 let expected = decoded_planes(&mut reference, units, ten);
140135
141136 let mut decoder = HwDecoder::open(codec).expect("open mixed decoder");
@@ -187,17 +182,12 @@ fn dmabuf_cases(dir: &Path) {
187182 }
188183
189184 fn dmabuf_case(label: &str, codec: Codec, units: &[&[u8]], ten: bool) {
190- let mut reference = if ten {
191- HwDecoder::open_16(codec)
192- } else {
193- HwDecoder::open(codec)
194- }
195- .expect("open decoder");
185+ let mut reference = HwDecoder::open(codec).expect("open decoder");
196186 assert_eq!(reference.backend(), Backend::Vk, "{label}: must decode on Vulkan");
197187 let expected = decoded_planes(&mut reference, units, ten);
198188
199189 let gpu = ec_vk::Gpu::open().expect("Vulkan device");
200- let mut decoder = HwDecoder::open_dmabuf(codec).expect("open DMA-BUF decoder");
190+ let mut decoder = HwDecoder::open(codec).expect("open DMA-BUF decoder");
201191 assert_eq!(decoder.backend(), Backend::Vk, "{label}: DMA-BUF must decode on Vulkan");
202192 let mut got = Vec::new();
203193 for (pts, unit) in units.iter().enumerate() {
@@ -222,7 +212,8 @@ fn decoded_planes(decoder: &mut HwDecoder, units: &[&[u8]], ten: bool) -> Vec<(V
222212
223213 fn take_planes(decoder: &mut HwDecoder, ten: bool, out: &mut Vec<(Vec<u8>, Vec<u8>)>) {
224214 if ten {
225- while let Some((_, frame)) = decoder.next_frame_16().expect("next frame") {
215+ while let Some(picture) = decoder.next_picture().expect("next picture") {
216+ let frame = picture.to_i420_16().expect("to_i420_16");
226217 out.push(p010_planes(&frame));
227218 }
228219 } else {
@@ -250,8 +241,9 @@ fn p010_planes(frame: &I420_16) -> (Vec<u8>, Vec<u8>) {
250241 }
251242
252243 fn collect_dmabuf(decoder: &mut HwDecoder, gpu: &ec_vk::Gpu, out: &mut Vec<(Vec<u8>, Vec<u8>)>) {
253- while let Some((_, picture)) = decoder.next_dmabuf().expect("next DMA-BUF") {
254- out.push(read_back(gpu, picture));
244+ while let Some(picture) = decoder.next_picture().expect("next picture") {
245+ let dmabuf = picture.export_dmabuf().expect("export DMA-BUF");
246+ out.push(read_back(gpu, dmabuf));
255247 }
256248 }
257249
crates/ec-hw/examples/hw_ten.rsmodified+5 -5
@@ -59,17 +59,17 @@ fn run(
5959 let stem = format!("{dir}/ten_{codec:?}_{name}_{backend:?}");
6060 std::fs::write(format!("{stem}.bin"), &stream).expect("write bitstream");
6161
62- let mut decoder = HwDecoder::open_16(decode_codec(codec))?;
62+ let mut decoder = HwDecoder::open(decode_codec(codec))?;
6363 let mut decoded = Vec::new();
6464 for c in &coded {
6565 decoder.decode(&c.data, c.timestamp)?;
66- while let Some(frame) = decoder.next_frame_16()? {
67- decoded.push(frame);
66+ while let Some(picture) = decoder.next_picture()? {
67+ decoded.push((picture.timestamp, picture.to_i420_16()?));
6868 }
6969 }
7070 decoder.flush()?;
71- while let Some(frame) = decoder.next_frame_16()? {
72- decoded.push(frame);
71+ while let Some(picture) = decoder.next_picture()? {
72+ decoded.push((picture.timestamp, picture.to_i420_16()?));
7373 }
7474
7575 let mut yuv = Vec::new();
crates/ec-hw/src/hw.rsmodified+0 -30
@@ -12,8 +12,6 @@ use std::collections::VecDeque;
1212 use crate::error::{Error, Result};
1313 use crate::output::HwPicture;
1414 use crate::picture::{I420, I420_16, RgbPicture};
15-#[cfg(target_os = "linux")]
16-use crate::picture::DmaBufPicture;
1715 use crate::rate::{RateFeedback, hrd_buffer_ms};
1816 use crate::types::{
1917 Codec, CodedFrame, EncCodec, EncoderConfig, FrameMetadata, H264Profile, RateControlMode,
@@ -1207,17 +1205,6 @@ impl HwDecoder {
12071205 HwDecoder::open_with(codec, Some(output))
12081206 }
12091207
1210- /// Same as [`HwDecoder::open`]: every picture can be asked for 10-bit I420 with [`HwPicture::to_i420_16`].
1211- pub fn open_16(codec: Codec) -> Result<HwDecoder> {
1212- HwDecoder::open(codec)
1213- }
1214-
1215- /// Same as [`HwDecoder::open`]: every picture can be asked for DMA-BUF file descriptors with [`HwPicture::export_dmabuf`]. Linux only.
1216- #[cfg(target_os = "linux")]
1217- pub fn open_dmabuf(codec: Codec) -> Result<HwDecoder> {
1218- HwDecoder::open(codec)
1219- }
1220-
12211208 fn open_with(codec: Codec, rgb: Option<RgbOutput>) -> Result<HwDecoder> {
12221209 let mut reasons = Vec::new();
12231210 let born_epoch = crate::reset::gpu_reset_epoch();
@@ -1310,23 +1297,6 @@ impl HwDecoder {
13101297 }
13111298 }
13121299
1313- /// The next picture in display order, as 10-bit I420 with its timestamp.
1314- pub fn next_frame_16(&mut self) -> Result<Option<(i64, I420_16)>> {
1315- match self.pull()? {
1316- None => Ok(None),
1317- Some(picture) => Ok(Some((picture.timestamp, picture.to_i420_16()?))),
1318- }
1319- }
1320-
1321- /// The next picture in display order, as DMA-BUF file descriptors with its timestamp. Linux only.
1322- #[cfg(target_os = "linux")]
1323- pub fn next_dmabuf(&mut self) -> Result<Option<(i64, DmaBufPicture)>> {
1324- match self.pull()? {
1325- None => Ok(None),
1326- Some(picture) => Ok(Some((picture.timestamp, picture.export_dmabuf()?))),
1327- }
1328- }
1329-
13301300 /// The next picture in display order, as packed RGB with its timestamp. An error on a decoder not opened with [`HwDecoder::open_rgb`].
13311301 pub fn next_rgb(&mut self) -> Result<Option<(i64, RgbPicture)>> {
13321302 let mut dst = RgbPicture::default();