media: cros-codecs: vaapi: move required data to GenericBackendHandle so it can clean itself up

The destructor for BackendHandle had to take ownership of its
GenericBackendHandle in its destructor in order to return the underlying
surface to the surface pool. This means the handle had to be put behind
an Option that is always valid, but requires us to perform unwrap()s
when accessing it anyway.

By delegating the surface return to GenericBackendHandle, we can avoid
this Option and thus make the code a bit more sound.

BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs

Change-Id: I590172b69decac3250bb9e85a67d959b1eca83f8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4164543
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
4 files changed
tree: f007e0eebf5d1e7414cb2f0bcc5ef616d8d0d05c
  1. src/
  2. .gitignore
  3. Cargo.lock
  4. Cargo.toml
  5. CONTRIBUTING.md
  6. LICENSE
  7. README.md
README.md

Cros-codecs

A lightweight, simple, low-dependencies, and hopefully safe crate for using hardware-accelerated decoding and encoding on Linux.

It is developed for use in ChromeOS (particularly crosvm), but has no ChromeOS dependencies and should this be usable anywhere.

This crate is still under heavy development. Currently implemented features are:

  • Stateless decoder support.
  • VAAPI decoder support (using cros-libva) for H.264, VP8 and VP9.

Future features:

  • Stateful V4L2 decoder support.
  • Stateless V4L2 decoder support.
  • Vaapi encoder support.
  • V4L2 encoder support.
  • Support for stateless H.265 and AV1.
  • C API to be used in non-Rust projects.