49d746a47c
The raw capabilities should not depend on the value for rt_format. Both in the Intel and Mesa implementations it can be seen that setting VAConfigAttribRTFormat as a parameter to vaCreateConfig only serves as a way to validate that the to-be-generated config supports it. This means that the Intel implementation will only use it in CheckAttribList, while Mesa will AND it with a precomputed bitmask of supported values in vaCreateConfig. Thus, creating one RawCaps instance per value of RT_FORMAT only serves to create needless duplication. Not only that, but it frequently makes the call to QUERY_CAPABILITIES fail, as the resulting structures become too large to fit into the 1024 byte buffer. Remove all traces of VA_RT_FORMAT_* from this code path. While we are at it, note that the libva crate API for vaQuerySurfaceAttribute changed to reflect that this call can return more than one attribute at once. This is particularly important for VASurfaceAttribPixelFormat, as one value per supported fourcc is returned. We now properly return one instance of RawCaps per VA_FOURCC supported. Also reflect that Surface attributes can be defined more than once This is particularly the case with VASurfaceAttribPixelFormat, where the driver will define one attrib per pixel format supported. This can be seen in the Intel driver, for example, in MediaLibvaCaps::QuerySurfaceAttributes. The previous code assumed that a given attribute could only be defined once, and thus used find(). It was refactored to use filter() instead. The name of the method was changed to reflect that it can now return more than one attribute per call. The return type was changed to Vec for the same reason. BUG=b:214478588 TEST="cargo test --package devices --lib --features video-decoder --features vaapi -- virtio::video::decoder::backend::vaapi::tests::test_get_capabilities --include-ignored" Change-Id: I914376beb026e30b2a52ca8f7d01c81e6a9a2775 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3946301 Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Commit-Queue: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> |
||
---|---|---|
.. | ||
src | ||
bindgen.sh | ||
build.rs | ||
Cargo.toml | ||
libva-wrapper.h | ||
README.md |
Libva Rust wrapper
Rust wrapper for libva. Provides safe libva abstractions for use within Rust code using its own bindgen-generated bindings.
This crate is used as part of the VirtIO Video VA-API backend. VA-API uses the GPU to perform the actual decoding/encoding of frames. In doing so, it frees the CPU for other uses and reduces power usage in the system. Hardware accelerated media workflows also tend to be faster than their software counterparts.
Note: This create requires the native libva library at link time. It also requires a VA-API driver to be installed on the system. The VA-API driver to use depends on the underlying hardware, e.g.: the implementation for Intel hardware is in intel-media-driver, whereas AMD hardware will depend on Mesa.
An easy way to see whether everything is in order is to run the vainfo
utility. This is usually
packaged with libva-utils
or as a standalone package in some distributions. vainfo
will print
the VA-API version, the driver string, and a list of supported profiles and endpoints, i.e.:
vainfo: VA-API version: 1.13 (libva 2.13.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.2.2 ()
vainfo: Supported profile and entrypoints
VAProfileNone : VAEntrypointVideoProc
VAProfileNone : VAEntrypointStats
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
VAProfileMPEG2Main : VAEntrypointVLD
VAProfileMPEG2Main : VAEntrypointEncSlice
VAProfileH264Main : VAEntrypointVLD
etc
For decoding, the desired profile must be supported under VAEntrypointVLD
. For example, in order
to decode VP8 media, this line must be present in the output of vainfo
:
VAProfileVP8Version0_3 : VAEntrypointVLD
Whereas to decode H264 Main profile media, this line must be present:
VAProfileH264Main : VAEntrypointVLD
For more information on VA-API and its usage within ChromeOS, see this guide.
For a brief introduction on how to use this crate, see the libva_utils_mpeg2vldemo
test under
src/lib.rs.