Skip to content

Commit

Permalink
decoder/stateless/v4l2/h264: remove unneeded V4l2CtrlH264Sps and `V…
Browse files Browse the repository at this point in the history
…4l2CtrlH264Pps` wrapper types

We can achieve the same result through existing `From` implementations.
  • Loading branch information
Gnurou committed Jul 8, 2024
1 parent 07dfccd commit 1af2ce1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 52 deletions.
18 changes: 10 additions & 8 deletions src/decoder/stateless/h264/v4l2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
use std::cell::RefCell;
use std::rc::Rc;

use v4l2r::bindings::v4l2_ctrl_h264_pps;
use v4l2r::bindings::v4l2_ctrl_h264_sps;
use v4l2r::controls::codec::H264Pps;
use v4l2r::controls::codec::H264Sps;
use v4l2r::controls::SafeExtControl;

use crate::backend::v4l2::decoder::stateless::BackendHandle;
use crate::backend::v4l2::decoder::stateless::V4l2Picture;
use crate::backend::v4l2::decoder::stateless::V4l2StatelessDecoderBackend;
Expand All @@ -25,9 +31,7 @@ use crate::decoder::BlockingMode;
use crate::device::v4l2::stateless::controls::h264::V4l2CtrlH264DecodeMode;
use crate::device::v4l2::stateless::controls::h264::V4l2CtrlH264DecodeParams;
use crate::device::v4l2::stateless::controls::h264::V4l2CtrlH264DpbEntry;
use crate::device::v4l2::stateless::controls::h264::V4l2CtrlH264Pps;
//TODO use crate::device::v4l2::stateless::controls::h264::V4l2CtrlH264ScalingMatrix;
use crate::device::v4l2::stateless::controls::h264::V4l2CtrlH264Sps;
use crate::Resolution;

impl StatelessDecoderBackendPicture<H264> for V4l2StatelessDecoderBackend {
Expand Down Expand Up @@ -87,21 +91,19 @@ impl StatelessH264DecoderBackend for V4l2StatelessDecoderBackend {
});
ref_pictures.push(ref_picture);
}
let mut h264_sps = V4l2CtrlH264Sps::new();
let mut h264_pps = V4l2CtrlH264Pps::new();
//TODO let mut h264_scaling_matrix = V4l2CtrlH264ScalingMatrix::new();
let mut h264_decode_params = V4l2CtrlH264DecodeParams::new();
h264_sps.set(sps);
h264_pps.set(pps);
let h264_sps = SafeExtControl::<H264Sps>::from(v4l2_ctrl_h264_sps::from(sps));
let h264_pps = SafeExtControl::<H264Pps>::from(v4l2_ctrl_h264_pps::from(pps));
h264_decode_params
.set_picture_data(picture_data)
.set_dpb_entries(dpb_entries)
.set_slice_header(slice_header);
let mut picture = picture.borrow_mut();
picture
.request()
.ioctl(&h264_sps)
.ioctl(&h264_pps)
.ioctl(h264_sps)
.ioctl(h264_pps)
//TODO.ioctl(&h264_scaling_matrix)
.ioctl(&h264_decode_params)
.ioctl(V4l2CtrlH264DecodeMode::FrameBased);
Expand Down
44 changes: 0 additions & 44 deletions src/device/v4l2/stateless/controls/h264.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ use v4l2r::bindings::V4L2_H264_SPS_FLAG_QPPRIME_Y_ZERO_TRANSFORM_BYPASS;
use v4l2r::bindings::V4L2_H264_SPS_FLAG_SEPARATE_COLOUR_PLANE;
use v4l2r::controls::codec::H264DecodeMode;
use v4l2r::controls::codec::H264DecodeParams;
use v4l2r::controls::codec::H264Pps;
use v4l2r::controls::codec::H264ScalingMatrix;
use v4l2r::controls::codec::H264Sps;
use v4l2r::controls::SafeExtControl;

impl From<&Sps> for v4l2_ctrl_h264_sps {
Expand Down Expand Up @@ -201,48 +199,6 @@ impl From<&V4l2CtrlH264DpbEntry> for v4l2_h264_dpb_entry {
}
}

#[derive(Default)]
pub struct V4l2CtrlH264Sps {
handle: v4l2_ctrl_h264_sps,
}

impl V4l2CtrlH264Sps {
pub fn new() -> Self {
Default::default()
}
pub fn set(&mut self, sps: &Sps) -> &mut Self {
self.handle = v4l2_ctrl_h264_sps::from(sps);
self
}
}

impl From<&V4l2CtrlH264Sps> for SafeExtControl<H264Sps> {
fn from(sps: &V4l2CtrlH264Sps) -> Self {
SafeExtControl::<H264Sps>::from(sps.handle)
}
}

#[derive(Default)]
pub struct V4l2CtrlH264Pps {
handle: v4l2_ctrl_h264_pps,
}

impl V4l2CtrlH264Pps {
pub fn new() -> Self {
Default::default()
}
pub fn set(&mut self, pps: &Pps) -> &mut Self {
self.handle = v4l2_ctrl_h264_pps::from(pps);
self
}
}

impl From<&V4l2CtrlH264Pps> for SafeExtControl<H264Pps> {
fn from(pps: &V4l2CtrlH264Pps) -> Self {
SafeExtControl::<H264Pps>::from(pps.handle)
}
}

#[derive(Default)]
pub struct V4l2CtrlH264ScalingMatrix {
handle: v4l2_ctrl_h264_scaling_matrix,
Expand Down

0 comments on commit 1af2ce1

Please sign in to comment.