mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-07 18:59:13 +00:00
media: cros-codecs: vaapi: get coded resolution from the buffer pool
The coded resolution stored in the VAAPI backend was changed in lockstep with the same information stored in the buffer pool. Let's remove the former and always use the latter to avoid duplicating the same information. BUG=b:214478588 TEST=cargo test --features vaapi -p cros-codecs Change-Id: I08bfb7c2aaf6609a43a2753f143a58cd06ece4c4 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4164542 Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com> Commit-Queue: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
This commit is contained in:
parent
74cd872091
commit
9e7b90a000
2 changed files with 9 additions and 14 deletions
|
@ -311,7 +311,7 @@ impl StatelessDecoderBackend for Backend {
|
|||
|
||||
let metadata = self.backend.metadata_state.get_parsed_mut()?;
|
||||
let context = &metadata.context;
|
||||
let coded_resolution = metadata.coded_resolution;
|
||||
let coded_resolution = metadata.surface_pool.coded_resolution();
|
||||
|
||||
let iq_buffer = context.create_buffer(Backend::build_iq_matrix(picture, segmentation)?)?;
|
||||
|
||||
|
|
|
@ -150,13 +150,12 @@ impl DecodedHandle {
|
|||
/// Creates a new handle
|
||||
pub fn new(
|
||||
inner: Rc<RefCell<GenericBackendHandle>>,
|
||||
resolution: Resolution,
|
||||
timestamp: u64,
|
||||
surface_pool: SurfacePoolHandle,
|
||||
) -> Self {
|
||||
Self {
|
||||
inner: Some(inner),
|
||||
resolution,
|
||||
resolution: surface_pool.coded_resolution(),
|
||||
timestamp,
|
||||
surface_pool,
|
||||
display_order: None,
|
||||
|
@ -177,7 +176,7 @@ impl Drop for DecodedHandle {
|
|||
let pool = &mut self.surface_pool;
|
||||
|
||||
// Only retrieve if the resolutions match, otherwise let the stale Surface drop.
|
||||
if *pool.current_resolution() == self.resolution {
|
||||
if pool.coded_resolution() == self.resolution {
|
||||
// Retrieve if not currently used by another field.
|
||||
if let Ok(Some(surface)) = inner.try_into() {
|
||||
pool.add_surface(surface);
|
||||
|
@ -215,7 +214,7 @@ impl DecodedHandleTrait for DecodedHandle {
|
|||
#[derive(Clone)]
|
||||
pub struct SurfacePoolHandle {
|
||||
surfaces: Rc<RefCell<VecDeque<Surface>>>,
|
||||
current_resolution: Resolution,
|
||||
coded_resolution: Resolution,
|
||||
}
|
||||
|
||||
impl SurfacePoolHandle {
|
||||
|
@ -223,13 +222,13 @@ impl SurfacePoolHandle {
|
|||
pub fn new(surfaces: Vec<Surface>, resolution: Resolution) -> Self {
|
||||
Self {
|
||||
surfaces: Rc::new(RefCell::new(VecDeque::from(surfaces))),
|
||||
current_resolution: resolution,
|
||||
coded_resolution: resolution,
|
||||
}
|
||||
}
|
||||
|
||||
/// Retrieve the current resolution for the pool
|
||||
pub fn current_resolution(&self) -> &Resolution {
|
||||
&self.current_resolution
|
||||
/// Retrieve the current coded resolution of the pool
|
||||
pub fn coded_resolution(&self) -> Resolution {
|
||||
self.coded_resolution
|
||||
}
|
||||
|
||||
/// Adds a new surface to the pool
|
||||
|
@ -274,8 +273,6 @@ pub(crate) struct ParsedStreamMetadata {
|
|||
pub(crate) surface_pool: SurfacePoolHandle,
|
||||
/// The number of surfaces required to parse the stream.
|
||||
pub(crate) min_num_surfaces: usize,
|
||||
/// The decoder current coded resolution.
|
||||
pub(crate) coded_resolution: Resolution,
|
||||
/// The decoder current display resolution.
|
||||
pub(crate) display_resolution: Resolution,
|
||||
/// The image format we will use to map the surfaces. This is usually the
|
||||
|
@ -421,7 +418,6 @@ impl StreamMetadataState {
|
|||
config,
|
||||
surface_pool,
|
||||
min_num_surfaces,
|
||||
coded_resolution,
|
||||
display_resolution,
|
||||
map_format: Rc::new(map_format),
|
||||
rt_format,
|
||||
|
@ -682,7 +678,6 @@ where
|
|||
|
||||
Ok(DecodedHandle::new(
|
||||
Rc::clone(picture),
|
||||
metadata.coded_resolution,
|
||||
timestamp,
|
||||
metadata.surface_pool.clone(),
|
||||
))
|
||||
|
@ -698,7 +693,7 @@ where
|
|||
fn coded_resolution(&self) -> Option<Resolution> {
|
||||
self.metadata_state
|
||||
.get_parsed()
|
||||
.map(|m| m.coded_resolution)
|
||||
.map(|m| m.surface_pool.coded_resolution)
|
||||
.ok()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue