mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-08 19:33:07 +00:00
media: cros-codecs: simplify the Picture interface
backend_handle_unchecked* were only used in tests, and the DynPicture interface provides equivalent functions anyway, so use these ones and drop the former. Ideally these methods that can potentially panic should be replaced by something else, but this will have to wait further cleanups. BUG=b:214478588 TEST=cargo test --features vaapi -p cros-codecs TEST=`cros-codecs --include-ignored` passes on hatch. Change-Id: I339f6893599c5ffc24e738f5ad11f35cbfcaab25 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3998371 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
This commit is contained in:
parent
c0e235ae2d
commit
acc3aa6532
7 changed files with 10 additions and 48 deletions
|
@ -142,7 +142,11 @@ pub trait DynDecodedHandle {
|
|||
}
|
||||
|
||||
pub trait DynPicture {
|
||||
/// Gets a shared reference to the backend handle of this picture. Assumes
|
||||
/// that this picture is backed by a handle and panics if not the case.
|
||||
fn dyn_mappable_handle(&self) -> &dyn MappableHandle;
|
||||
/// Gets an exclusive reference to the backend handle of this picture.
|
||||
/// Assumes that this picture is backed by a handle and panics if not the case.
|
||||
fn dyn_mappable_handle_mut(&mut self) -> &mut dyn MappableHandle;
|
||||
}
|
||||
|
||||
|
|
|
@ -1147,7 +1147,7 @@ mod tests {
|
|||
use crate::decoders::h264::decoder::tests::process_ready_frames;
|
||||
use crate::decoders::h264::decoder::tests::run_decoding_loop;
|
||||
use crate::decoders::h264::decoder::Decoder;
|
||||
use crate::decoders::MappableHandle;
|
||||
use crate::decoders::DynPicture;
|
||||
|
||||
fn as_vaapi_backend(
|
||||
backend: &dyn StatelessDecoderBackend<Handle = AssociatedHandle>,
|
||||
|
@ -1164,7 +1164,7 @@ mod tests {
|
|||
frame_num: i32,
|
||||
) {
|
||||
let mut picture = handle.picture_mut();
|
||||
let backend_handle = picture.backend_handle_unchecked_mut();
|
||||
let backend_handle = picture.dyn_mappable_handle_mut();
|
||||
|
||||
let resolution = backend_handle.mapped_resolution().unwrap();
|
||||
|
||||
|
|
|
@ -372,20 +372,6 @@ impl<BackendHandle> Picture<BackendHandle> {
|
|||
self.is_second_field = true;
|
||||
}
|
||||
|
||||
/// Gets a shared reference to the backend handle of this picture. Assumes
|
||||
/// that this picture is backed by a handle, which may not be the case if
|
||||
/// the picture is a "non-existing" picture, for example.
|
||||
pub fn backend_handle_unchecked(&self) -> &BackendHandle {
|
||||
self.backend_handle.as_ref().unwrap()
|
||||
}
|
||||
|
||||
/// Gets an exclusive reference to the backend handle of this picture.
|
||||
/// Assumes that this picture is backed by a handle, which may not be the
|
||||
/// case if the picture is a "non-existing" picture, for example.
|
||||
pub fn backend_handle_unchecked_mut(&mut self) -> &mut BackendHandle {
|
||||
self.backend_handle.as_mut().unwrap()
|
||||
}
|
||||
|
||||
/// Get a reference to the picture's timestamp.
|
||||
pub fn timestamp(&self) -> u64 {
|
||||
self.timestamp
|
||||
|
|
|
@ -817,7 +817,7 @@ mod tests {
|
|||
use crate::decoders::vp8::decoder::tests::process_ready_frames;
|
||||
use crate::decoders::vp8::decoder::tests::run_decoding_loop;
|
||||
use crate::decoders::vp8::decoder::Decoder;
|
||||
use crate::decoders::MappableHandle;
|
||||
use crate::decoders::DynPicture;
|
||||
|
||||
fn as_vaapi_backend(
|
||||
backend: &dyn StatelessDecoderBackend<Handle = AssociatedHandle>,
|
||||
|
@ -834,7 +834,7 @@ mod tests {
|
|||
frame_num: i32,
|
||||
) {
|
||||
let mut picture = handle.picture_mut();
|
||||
let backend_handle = picture.backend_handle_unchecked_mut();
|
||||
let backend_handle = picture.dyn_mappable_handle_mut();
|
||||
|
||||
let resolution = backend_handle.mapped_resolution().unwrap();
|
||||
|
||||
|
|
|
@ -29,20 +29,6 @@ impl<T> Picture<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Gets a shared reference to the backend handle of this picture. Assumes
|
||||
/// that this picture is backed by a handle, which may not be the case if
|
||||
/// the picture has "show_previous_frame" set, for example.
|
||||
pub fn backend_handle_unchecked(&self) -> &T {
|
||||
self.backend_handle.as_ref().unwrap()
|
||||
}
|
||||
|
||||
/// Gets an exclusive reference to the backend handle of this picture.
|
||||
/// Assumes that this picture is backed by a handle, which may not be the
|
||||
/// case if the picture has "show_previous_frame" set, for example.
|
||||
pub fn backend_handle_unchecked_mut(&mut self) -> &mut T {
|
||||
self.backend_handle.as_mut().unwrap()
|
||||
}
|
||||
|
||||
/// Whether two pictures are the same.
|
||||
pub fn same(lhs: &Rc<RefCell<Self>>, rhs: &Rc<RefCell<Self>>) -> bool {
|
||||
Rc::ptr_eq(lhs, rhs)
|
||||
|
|
|
@ -1004,7 +1004,7 @@ mod tests {
|
|||
use crate::decoders::vp9::decoder::tests::run_decoding_loop;
|
||||
use crate::decoders::vp9::decoder::Decoder;
|
||||
use crate::decoders::vp9::parser::NUM_REF_FRAMES;
|
||||
use crate::decoders::MappableHandle;
|
||||
use crate::decoders::DynPicture;
|
||||
|
||||
fn as_vaapi_backend(
|
||||
backend: &dyn StatelessDecoderBackend<Handle = AssociatedHandle>,
|
||||
|
@ -1021,7 +1021,7 @@ mod tests {
|
|||
frame_num: i32,
|
||||
) {
|
||||
let mut picture = handle.picture_mut();
|
||||
let backend_handle = picture.backend_handle_unchecked_mut();
|
||||
let backend_handle = picture.dyn_mappable_handle_mut();
|
||||
|
||||
let resolution = backend_handle.mapped_resolution().unwrap();
|
||||
|
||||
|
|
|
@ -29,20 +29,6 @@ impl<T> Picture<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Gets a shared reference to the backend handle of this picture. Assumes
|
||||
/// that this picture is backed by a handle, which may not be the case if
|
||||
/// the picture has "show_previous_frame" set, for example.
|
||||
pub fn backend_handle_unchecked(&self) -> &T {
|
||||
self.backend_handle.as_ref().unwrap()
|
||||
}
|
||||
|
||||
/// Gets an exclusive reference to the backend handle of this picture.
|
||||
/// Assumes that this picture is backed by a handle, which may not be the
|
||||
/// case if the picture has "show_previous_frame" set, for example.
|
||||
pub fn backend_handle_unchecked_mut(&mut self) -> &mut T {
|
||||
self.backend_handle.as_mut().unwrap()
|
||||
}
|
||||
|
||||
/// Whether two pictures are the same.
|
||||
pub fn same(lhs: &Rc<RefCell<Self>>, rhs: &Rc<RefCell<Self>>) -> bool {
|
||||
Rc::ptr_eq(lhs, rhs)
|
||||
|
|
Loading…
Reference in a new issue