mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-08 19:33:07 +00:00
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 <daniel.almeida@collabora.corp-partner.google.com> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
parent
feba776773
commit
a074f28164
3 changed files with 16 additions and 25 deletions
|
@ -52,9 +52,6 @@ use crate::Resolution;
|
||||||
/// Resolves to the type used as Handle by the backend.
|
/// Resolves to the type used as Handle by the backend.
|
||||||
type AssociatedHandle = <Backend as StatelessDecoderBackend>::Handle;
|
type AssociatedHandle = <Backend as StatelessDecoderBackend>::Handle;
|
||||||
|
|
||||||
/// Resolves to the type used as BackendHandle by the backend.
|
|
||||||
type AssociatedBackendHandle = <AssociatedHandle as DecodedHandle>::BackendHandle;
|
|
||||||
|
|
||||||
/// Keeps track of where the backend is in the negotiation process.
|
/// Keeps track of where the backend is in the negotiation process.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
enum NegotiationStatus {
|
enum NegotiationStatus {
|
||||||
|
@ -117,7 +114,7 @@ pub struct Backend {
|
||||||
/// The current picture being worked on.
|
/// The current picture being worked on.
|
||||||
current_picture: Option<VaPicture<PictureNew>>,
|
current_picture: Option<VaPicture<PictureNew>>,
|
||||||
/// The FIFO for all pending pictures, in the order they were submitted.
|
/// The FIFO for all pending pictures, in the order they were submitted.
|
||||||
pending_jobs: VecDeque<PendingJob<AssociatedBackendHandle>>,
|
pending_jobs: VecDeque<PendingJob<GenericBackendHandle>>,
|
||||||
/// The image formats we can decode into.
|
/// The image formats we can decode into.
|
||||||
image_formats: Rc<Vec<libva::VAImageFormat>>,
|
image_formats: Rc<Vec<libva::VAImageFormat>>,
|
||||||
/// The number of allocated surfaces.
|
/// The number of allocated surfaces.
|
||||||
|
@ -273,7 +270,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the VASurfaceID for the given `picture`.
|
/// Gets the VASurfaceID for the given `picture`.
|
||||||
fn surface_id(picture: &H264Picture<AssociatedBackendHandle>) -> libva::VASurfaceID {
|
fn surface_id(picture: &H264Picture<GenericBackendHandle>) -> libva::VASurfaceID {
|
||||||
if picture.nonexisting {
|
if picture.nonexisting {
|
||||||
return libva::constants::VA_INVALID_SURFACE;
|
return libva::constants::VA_INVALID_SURFACE;
|
||||||
}
|
}
|
||||||
|
@ -283,7 +280,7 @@ impl Backend {
|
||||||
|
|
||||||
/// Fills the internal `va_pic` picture parameter with data from `h264_pic`
|
/// Fills the internal `va_pic` picture parameter with data from `h264_pic`
|
||||||
fn fill_va_h264_pic(
|
fn fill_va_h264_pic(
|
||||||
h264_pic: &H264Picture<AssociatedBackendHandle>,
|
h264_pic: &H264Picture<GenericBackendHandle>,
|
||||||
surface_id: libva::VASurfaceID,
|
surface_id: libva::VASurfaceID,
|
||||||
merge_other_field: bool,
|
merge_other_field: bool,
|
||||||
) -> libva::PictureH264 {
|
) -> libva::PictureH264 {
|
||||||
|
@ -382,7 +379,7 @@ impl Backend {
|
||||||
|
|
||||||
fn build_pic_param(
|
fn build_pic_param(
|
||||||
slice: &Slice<impl AsRef<[u8]>>,
|
slice: &Slice<impl AsRef<[u8]>>,
|
||||||
current_picture: &H264Picture<AssociatedBackendHandle>,
|
current_picture: &H264Picture<GenericBackendHandle>,
|
||||||
current_surface_id: libva::VASurfaceID,
|
current_surface_id: libva::VASurfaceID,
|
||||||
dpb: &Dpb<AssociatedHandle>,
|
dpb: &Dpb<AssociatedHandle>,
|
||||||
sps: &Sps,
|
sps: &Sps,
|
||||||
|
@ -492,7 +489,7 @@ impl Backend {
|
||||||
|
|
||||||
fn build_va_decoded_handle(
|
fn build_va_decoded_handle(
|
||||||
&self,
|
&self,
|
||||||
picture: &ContainedPicture<AssociatedBackendHandle>,
|
picture: &ContainedPicture<GenericBackendHandle>,
|
||||||
) -> Result<AssociatedHandle> {
|
) -> Result<AssociatedHandle> {
|
||||||
Ok(VADecodedHandle::new(
|
Ok(VADecodedHandle::new(
|
||||||
Rc::clone(picture),
|
Rc::clone(picture),
|
||||||
|
@ -739,7 +736,7 @@ impl StatelessDecoderBackend for Backend {
|
||||||
|
|
||||||
fn handle_picture(
|
fn handle_picture(
|
||||||
&mut self,
|
&mut self,
|
||||||
picture: &H264Picture<AssociatedBackendHandle>,
|
picture: &H264Picture<GenericBackendHandle>,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
sps: &Sps,
|
sps: &Sps,
|
||||||
pps: &Pps,
|
pps: &Pps,
|
||||||
|
@ -822,7 +819,7 @@ impl StatelessDecoderBackend for Backend {
|
||||||
|
|
||||||
fn submit_picture(
|
fn submit_picture(
|
||||||
&mut self,
|
&mut self,
|
||||||
picture: H264Picture<AssociatedBackendHandle>,
|
picture: H264Picture<GenericBackendHandle>,
|
||||||
block: bool,
|
block: bool,
|
||||||
) -> StatelessBackendResult<Self::Handle> {
|
) -> StatelessBackendResult<Self::Handle> {
|
||||||
let current_picture = self.current_picture.take().unwrap();
|
let current_picture = self.current_picture.take().unwrap();
|
||||||
|
@ -901,7 +898,7 @@ impl StatelessDecoderBackend for Backend {
|
||||||
|
|
||||||
fn new_handle(
|
fn new_handle(
|
||||||
&mut self,
|
&mut self,
|
||||||
picture: ContainedPicture<AssociatedBackendHandle>,
|
picture: ContainedPicture<GenericBackendHandle>,
|
||||||
) -> StatelessBackendResult<Self::Handle> {
|
) -> StatelessBackendResult<Self::Handle> {
|
||||||
self.build_va_decoded_handle(&picture)
|
self.build_va_decoded_handle(&picture)
|
||||||
.map_err(|e| StatelessBackendError::Other(anyhow!(e)))
|
.map_err(|e| StatelessBackendError::Other(anyhow!(e)))
|
||||||
|
@ -909,8 +906,8 @@ impl StatelessDecoderBackend for Backend {
|
||||||
|
|
||||||
fn new_split_picture(
|
fn new_split_picture(
|
||||||
&mut self,
|
&mut self,
|
||||||
split_picture: ContainedPicture<AssociatedBackendHandle>,
|
split_picture: ContainedPicture<GenericBackendHandle>,
|
||||||
new_picture: ContainedPicture<AssociatedBackendHandle>,
|
new_picture: ContainedPicture<GenericBackendHandle>,
|
||||||
) -> StatelessBackendResult<()> {
|
) -> StatelessBackendResult<()> {
|
||||||
let backend_handle = split_picture.borrow().backend_handle.as_ref().cloned();
|
let backend_handle = split_picture.borrow().backend_handle.as_ref().cloned();
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,6 @@ use crate::Resolution;
|
||||||
/// Resolves to the type used as Handle by the backend.
|
/// Resolves to the type used as Handle by the backend.
|
||||||
type AssociatedHandle = <Backend as StatelessDecoderBackend>::Handle;
|
type AssociatedHandle = <Backend as StatelessDecoderBackend>::Handle;
|
||||||
|
|
||||||
/// Resolves to the type used as BackendHandle by the backend.
|
|
||||||
type AssociatedBackendHandle = <AssociatedHandle as DecodedHandle>::BackendHandle;
|
|
||||||
|
|
||||||
/// The number of surfaces to allocate for this codec. Same as GStreamer's vavp8dec.
|
/// The number of surfaces to allocate for this codec. Same as GStreamer's vavp8dec.
|
||||||
const NUM_SURFACES: usize = 7;
|
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.
|
/// The metadata state. Updated whenever the decoder reads new data from the stream.
|
||||||
metadata_state: StreamMetadataState,
|
metadata_state: StreamMetadataState,
|
||||||
/// The FIFO for all pending pictures, in the order they were submitted.
|
/// The FIFO for all pending pictures, in the order they were submitted.
|
||||||
pending_jobs: VecDeque<PendingJob<AssociatedBackendHandle>>,
|
pending_jobs: VecDeque<PendingJob<GenericBackendHandle>>,
|
||||||
/// The image formats we can decode into.
|
/// The image formats we can decode into.
|
||||||
image_formats: Rc<Vec<libva::VAImageFormat>>,
|
image_formats: Rc<Vec<libva::VAImageFormat>>,
|
||||||
/// The number of allocated surfaces.
|
/// The number of allocated surfaces.
|
||||||
|
@ -212,7 +209,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the VASurfaceID for the given `picture`.
|
/// Gets the VASurfaceID for the given `picture`.
|
||||||
fn surface_id(picture: &Vp8Picture<AssociatedBackendHandle>) -> libva::VASurfaceID {
|
fn surface_id(picture: &Vp8Picture<GenericBackendHandle>) -> libva::VASurfaceID {
|
||||||
picture.backend_handle.as_ref().unwrap().surface_id()
|
picture.backend_handle.as_ref().unwrap().surface_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +390,7 @@ impl Backend {
|
||||||
|
|
||||||
fn build_va_decoded_handle(
|
fn build_va_decoded_handle(
|
||||||
&self,
|
&self,
|
||||||
picture: &ContainedPicture<AssociatedBackendHandle>,
|
picture: &ContainedPicture<GenericBackendHandle>,
|
||||||
) -> Result<AssociatedHandle> {
|
) -> Result<AssociatedHandle> {
|
||||||
Ok(VADecodedHandle::new(
|
Ok(VADecodedHandle::new(
|
||||||
Rc::clone(picture),
|
Rc::clone(picture),
|
||||||
|
|
|
@ -59,9 +59,6 @@ use crate::Resolution;
|
||||||
/// Resolves to the type used as Handle by the backend.
|
/// Resolves to the type used as Handle by the backend.
|
||||||
type AssociatedHandle = <Backend as StatelessDecoderBackend>::Handle;
|
type AssociatedHandle = <Backend as StatelessDecoderBackend>::Handle;
|
||||||
|
|
||||||
/// Resolves to the type used as BackendHandle by the backend.
|
|
||||||
type AssociatedBackendHandle = <AssociatedHandle as DecodedHandle>::BackendHandle;
|
|
||||||
|
|
||||||
/// The number of surfaces to allocate for this codec.
|
/// The number of surfaces to allocate for this codec.
|
||||||
const NUM_SURFACES: usize = 12;
|
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.
|
/// The metadata state. Updated whenever the decoder reads new data from the stream.
|
||||||
metadata_state: StreamMetadataState,
|
metadata_state: StreamMetadataState,
|
||||||
/// The FIFO for all pending pictures, in the order they were submitted.
|
/// The FIFO for all pending pictures, in the order they were submitted.
|
||||||
pending_jobs: VecDeque<PendingJob<AssociatedBackendHandle>>,
|
pending_jobs: VecDeque<PendingJob<GenericBackendHandle>>,
|
||||||
/// The image formats we can decode into.
|
/// The image formats we can decode into.
|
||||||
image_formats: Rc<Vec<libva::VAImageFormat>>,
|
image_formats: Rc<Vec<libva::VAImageFormat>>,
|
||||||
/// The number of allocated surfaces.
|
/// The number of allocated surfaces.
|
||||||
|
@ -330,7 +327,7 @@ impl Backend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the VASurfaceID for the given `picture`.
|
/// Gets the VASurfaceID for the given `picture`.
|
||||||
fn surface_id(picture: &Vp9Picture<AssociatedBackendHandle>) -> libva::VASurfaceID {
|
fn surface_id(picture: &Vp9Picture<GenericBackendHandle>) -> libva::VASurfaceID {
|
||||||
picture.backend_handle.as_ref().unwrap().surface_id()
|
picture.backend_handle.as_ref().unwrap().surface_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +603,7 @@ impl Backend {
|
||||||
|
|
||||||
fn build_va_decoded_handle(
|
fn build_va_decoded_handle(
|
||||||
&self,
|
&self,
|
||||||
picture: &ContainedPicture<AssociatedBackendHandle>,
|
picture: &ContainedPicture<GenericBackendHandle>,
|
||||||
) -> Result<AssociatedHandle> {
|
) -> Result<AssociatedHandle> {
|
||||||
Ok(VADecodedHandle::new(
|
Ok(VADecodedHandle::new(
|
||||||
Rc::clone(picture),
|
Rc::clone(picture),
|
||||||
|
|
Loading…
Reference in a new issue