README.md
1# Libva Rust wrapper
2
3Rust wrapper for libva. Provides safe libva abstractions for use within Rust code using its own
4bindgen-generated bindings.
5
6This crate is used as part of the VirtIO Video VA-API backend. VA-API uses the GPU to perform the
7actual decoding/encoding of frames. In doing so, it frees the CPU for other uses and reduces power
8usage in the system. Hardware accelerated media workflows also tend to be faster than their software
9counterparts.
10
11Note: This create requires the native [libva](https://github.com/intel/libva) library at link time.
12It also requires a VA-API driver to be installed on the system. The VA-API driver to use depends on
13the underlying hardware, e.g.: the implementation for Intel hardware is in
14[intel-media-driver](https://github.com/intel/media-driver), whereas AMD hardware will depend on
15[Mesa](https://gitlab.freedesktop.org/mesa/mesa).
16
17An easy way to see whether everything is in order is to run the `vainfo` utility. This is usually
18packaged with `libva-utils` or as a standalone package in some distributions. `vainfo` will print
19the VA-API version, the driver string, and a list of supported profiles and endpoints, i.e.:
20
21```
22vainfo: VA-API version: 1.13 (libva 2.13.0)
23vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 22.2.2 ()
24vainfo: Supported profile and entrypoints
25 VAProfileNone : VAEntrypointVideoProc
26 VAProfileNone : VAEntrypointStats
27 VAProfileMPEG2Simple : VAEntrypointVLD
28 VAProfileMPEG2Simple : VAEntrypointEncSlice
29 VAProfileMPEG2Main : VAEntrypointVLD
30 VAProfileMPEG2Main : VAEntrypointEncSlice
31 VAProfileH264Main : VAEntrypointVLD
32 etc
33```
34
35For decoding, the desired profile must be supported under `VAEntrypointVLD`. For example, in order
36to decode VP8 media, this line must be present in the output of `vainfo`:
37
38```
39 VAProfileVP8Version0_3 : VAEntrypointVLD
40```
41
42Whereas to decode H264 Main profile media, this line must be present:
43
44```
45 VAProfileH264Main : VAEntrypointVLD
46```
47
48For more information on VA-API and its usage within ChromeOS, see
49[this guide](https://chromium.googlesource.com/chromium/src/+/master/docs/gpu/vaapi.md).
50
51For a brief introduction on how to use this crate, see the `libva_utils_mpeg2vldemo` test under
52src/lib.rs.
53