cros-codecs-generic-vaapi 0.0.6-generic.2

Hardware-accelerated codecs for Linux with generic VA-API surface support
Documentation
# cros-codecs-generic-vaapi

[<img alt="crates.io" src="https://img.shields.io/crates/v/cros-codecs-generic-vaapi">](https://crates.io/crates/cros-codecs-generic-vaapi)
[<img alt="docs.rs" src="https://img.shields.io/docsrs/cros-codecs-generic-vaapi">](https://docs.rs/cros-codecs-generic-vaapi/latest/cros_codecs/)

This is a community-maintained fork of
[`cros-codecs`](https://github.com/chromeos/cros-codecs) 0.0.6. It is not an
official ChromiumOS project.

The fork keeps the upstream codec implementation and makes two focused changes:

- H.264 VA-API encoders can accept any handle which borrows a libva surface.
  Applications can use standard libva-owned surfaces instead of allocating
  ChromeOS-style GBM buffers.
- GBM and DRM dependencies are isolated behind the `dmabuf` feature. The
  `vaapi` feature can be built without the GBM allocation stack.

The legacy C2 wrappers remain available through the `c2` feature. Pair it with
either `vaapi` or `v4l2`. Applications that provide libva surfaces directly
only need `vaapi`.

Use the package under the original crate name to keep imports compatible:

```toml
[dependencies]
cros-codecs = {
    package = "cros-codecs-generic-vaapi",
    version = "0.0.6-generic.2",
    features = ["vaapi"],
}
```

## Upstream project

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

It is developed for use in ChromeOS (particularly
[crosvm](https://github.com/google/crosvm)), but has no dependency to ChromeOS
and should be usable anywhere.

## Current features

- Simple decoder API,
- VAAPI decoder support (using
  [cros-libva]https://github.com/chromeos/cros-libva) for H.264, H.265, VP8,
  VP9 and AV1,
- VAAPI encoder support for H.264, VP9 and AV1,
- Stateful V4L2 encoder support.

## Planned features

- Stateful V4L2 decoder support,
- Stateless V4L2 decoder support,
- Support for more encoder codecs,
- C API to be used in non-Rust projects.

## Non-goals

- Support for systems other than Linux.

## Example programs

The `ccdec` example program can decode an encoded stream and write the decoded
frames to a file. As such it can be used for testing purposes.

```shell
$ cargo build --examples
$ ./target/debug/examples/ccdec --help
Usage: ccdec <input> [--output <output>] --input-format <input-format> [--output-format <output-format>] [--compute-md5 <compute-md5>]

Simple player using cros-codecs

Positional Arguments:
  input             input file

Options:
  --output          output file to write the decoded frames to
  --input-format    input format to decode from.
  --output-format   pixel format to decode into. Default: i420
  --compute-md5     whether to display the MD5 of the decoded stream, and at
                    which granularity (stream or frame)
  --help            display usage information
```

## Testing

Fluster can be used for testing, using the `ccdec` example program described
above. [This branch](https://github.com/Gnurou/fluster/tree/cros-codecs)
contains support for cros-codecs testing. Just make sure the `ccdec` binary is
in your `PATH`, and run Fluster using one of the `ccdec` decoders, e.g.

```shell
python fluster.py run -d ccdec-H.264 -ts JVT-AVC_V1
```

## Credits

The majority of the code in the initial commit has been written by Daniel
Almeida as a VAAPI backend for crosvm, before being split into this crate.