1use crate::types::{
2 error::Result,
3 video_frame::{DmaBufPlane, RawVideoFrame},
4};
5
6pub fn extract_dmabuf_planes(raw_frame: &RawVideoFrame) -> Result<Vec<DmaBufPlane>> {
7 match raw_frame.dmabuf_fd {
8 Some(fd) => Ok(vec![DmaBufPlane {
9 fd,
10 offset: raw_frame.offset,
11 stride: raw_frame.stride as u32,
12 }]),
13 None => Err("No DMA-BUF file descriptor in frame".into()),
14 }
15}
16
17pub fn calculate_dimensions(raw_frame: &RawVideoFrame) -> Result<(u32, u32)> {
18 let width = (raw_frame.stride / 4) as u32;
20 let height = raw_frame.size / raw_frame.stride as u32;
21
22 if width == 0 || height == 0 {
23 return Err("Invalid frame dimensions".into());
24 }
25
26 Ok((width, height))
27}