From a074f281648f37b8a2cde2278e19e4aac7a73911 Mon Sep 17 00:00:00 2001 From: Alexandre Courbot Date: Tue, 8 Nov 2022 14:50:31 +0900 Subject: [PATCH] media: cros-codecs: vaapi: remove AssociatedBackendHandle types We don't really need to use the BackendHandle associated type here as we know that vaapi will always use the GenericBackendHandle - so let's just use this and simplify the type map a bit. BUG=b:214478588 TEST=cargo test --features vaapi -p cros-codecs Change-Id: Idb77ecda7bdd566ffb7bc46a35ebaadcb11cdeef Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4060493 Reviewed-by: Daniel Almeida Reviewed-by: Keiichi Watanabe Commit-Queue: Alexandre Courbot --- .../decoders/h264/backends/stateless/vaapi.rs | 23 ++++++++----------- .../decoders/vp8/backends/stateless/vaapi.rs | 9 +++----- .../decoders/vp9/backends/stateless/vaapi.rs | 9 +++----- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/media/cros-codecs/src/decoders/h264/backends/stateless/vaapi.rs b/media/cros-codecs/src/decoders/h264/backends/stateless/vaapi.rs index 1fa0a047d4..4ee6f82a4c 100644 --- a/media/cros-codecs/src/decoders/h264/backends/stateless/vaapi.rs +++ b/media/cros-codecs/src/decoders/h264/backends/stateless/vaapi.rs @@ -52,9 +52,6 @@ use crate::Resolution; /// Resolves to the type used as Handle by the backend. type AssociatedHandle = ::Handle; -/// Resolves to the type used as BackendHandle by the backend. -type AssociatedBackendHandle = ::BackendHandle; - /// Keeps track of where the backend is in the negotiation process. #[derive(Clone, Debug)] enum NegotiationStatus { @@ -117,7 +114,7 @@ pub struct Backend { /// The current picture being worked on. current_picture: Option>, /// The FIFO for all pending pictures, in the order they were submitted. - pending_jobs: VecDeque>, + pending_jobs: VecDeque>, /// The image formats we can decode into. image_formats: Rc>, /// The number of allocated surfaces. @@ -273,7 +270,7 @@ impl Backend { } /// Gets the VASurfaceID for the given `picture`. - fn surface_id(picture: &H264Picture) -> libva::VASurfaceID { + fn surface_id(picture: &H264Picture) -> libva::VASurfaceID { if picture.nonexisting { return libva::constants::VA_INVALID_SURFACE; } @@ -283,7 +280,7 @@ impl Backend { /// Fills the internal `va_pic` picture parameter with data from `h264_pic` fn fill_va_h264_pic( - h264_pic: &H264Picture, + h264_pic: &H264Picture, surface_id: libva::VASurfaceID, merge_other_field: bool, ) -> libva::PictureH264 { @@ -382,7 +379,7 @@ impl Backend { fn build_pic_param( slice: &Slice>, - current_picture: &H264Picture, + current_picture: &H264Picture, current_surface_id: libva::VASurfaceID, dpb: &Dpb, sps: &Sps, @@ -492,7 +489,7 @@ impl Backend { fn build_va_decoded_handle( &self, - picture: &ContainedPicture, + picture: &ContainedPicture, ) -> Result { Ok(VADecodedHandle::new( Rc::clone(picture), @@ -739,7 +736,7 @@ impl StatelessDecoderBackend for Backend { fn handle_picture( &mut self, - picture: &H264Picture, + picture: &H264Picture, timestamp: u64, sps: &Sps, pps: &Pps, @@ -822,7 +819,7 @@ impl StatelessDecoderBackend for Backend { fn submit_picture( &mut self, - picture: H264Picture, + picture: H264Picture, block: bool, ) -> StatelessBackendResult { let current_picture = self.current_picture.take().unwrap(); @@ -901,7 +898,7 @@ impl StatelessDecoderBackend for Backend { fn new_handle( &mut self, - picture: ContainedPicture, + picture: ContainedPicture, ) -> StatelessBackendResult { self.build_va_decoded_handle(&picture) .map_err(|e| StatelessBackendError::Other(anyhow!(e))) @@ -909,8 +906,8 @@ impl StatelessDecoderBackend for Backend { fn new_split_picture( &mut self, - split_picture: ContainedPicture, - new_picture: ContainedPicture, + split_picture: ContainedPicture, + new_picture: ContainedPicture, ) -> StatelessBackendResult<()> { let backend_handle = split_picture.borrow().backend_handle.as_ref().cloned(); diff --git a/media/cros-codecs/src/decoders/vp8/backends/stateless/vaapi.rs b/media/cros-codecs/src/decoders/vp8/backends/stateless/vaapi.rs index 911c91c811..5ba2f0d241 100644 --- a/media/cros-codecs/src/decoders/vp8/backends/stateless/vaapi.rs +++ b/media/cros-codecs/src/decoders/vp8/backends/stateless/vaapi.rs @@ -44,9 +44,6 @@ use crate::Resolution; /// Resolves to the type used as Handle by the backend. type AssociatedHandle = ::Handle; -/// Resolves to the type used as BackendHandle by the backend. -type AssociatedBackendHandle = ::BackendHandle; - /// The number of surfaces to allocate for this codec. Same as GStreamer's vavp8dec. const NUM_SURFACES: usize = 7; @@ -93,7 +90,7 @@ pub struct Backend { /// The metadata state. Updated whenever the decoder reads new data from the stream. metadata_state: StreamMetadataState, /// The FIFO for all pending pictures, in the order they were submitted. - pending_jobs: VecDeque>, + pending_jobs: VecDeque>, /// The image formats we can decode into. image_formats: Rc>, /// The number of allocated surfaces. @@ -212,7 +209,7 @@ impl Backend { } /// Gets the VASurfaceID for the given `picture`. - fn surface_id(picture: &Vp8Picture) -> libva::VASurfaceID { + fn surface_id(picture: &Vp8Picture) -> libva::VASurfaceID { picture.backend_handle.as_ref().unwrap().surface_id() } @@ -393,7 +390,7 @@ impl Backend { fn build_va_decoded_handle( &self, - picture: &ContainedPicture, + picture: &ContainedPicture, ) -> Result { Ok(VADecodedHandle::new( Rc::clone(picture), diff --git a/media/cros-codecs/src/decoders/vp9/backends/stateless/vaapi.rs b/media/cros-codecs/src/decoders/vp9/backends/stateless/vaapi.rs index cfc5f72182..d961afbab9 100644 --- a/media/cros-codecs/src/decoders/vp9/backends/stateless/vaapi.rs +++ b/media/cros-codecs/src/decoders/vp9/backends/stateless/vaapi.rs @@ -59,9 +59,6 @@ use crate::Resolution; /// Resolves to the type used as Handle by the backend. type AssociatedHandle = ::Handle; -/// Resolves to the type used as BackendHandle by the backend. -type AssociatedBackendHandle = ::BackendHandle; - /// The number of surfaces to allocate for this codec. const NUM_SURFACES: usize = 12; @@ -128,7 +125,7 @@ pub struct Backend { /// The metadata state. Updated whenever the decoder reads new data from the stream. metadata_state: StreamMetadataState, /// The FIFO for all pending pictures, in the order they were submitted. - pending_jobs: VecDeque>, + pending_jobs: VecDeque>, /// The image formats we can decode into. image_formats: Rc>, /// The number of allocated surfaces. @@ -330,7 +327,7 @@ impl Backend { } /// Gets the VASurfaceID for the given `picture`. - fn surface_id(picture: &Vp9Picture) -> libva::VASurfaceID { + fn surface_id(picture: &Vp9Picture) -> libva::VASurfaceID { picture.backend_handle.as_ref().unwrap().surface_id() } @@ -606,7 +603,7 @@ impl Backend { fn build_va_decoded_handle( &self, - picture: &ContainedPicture, + picture: &ContainedPicture, ) -> Result { Ok(VADecodedHandle::new( Rc::clone(picture),