Sync cros-codecs code with ChromeOS

There are various downstream code change in cros-codecs directory in
ChromeOS [1]. This CL syncs the code based on upstream [2] to the code
in ChromeOS [3]. This is necessary to pass the build in cros-libva.

[1] https://chromium.googlesource.com/chromiumos/platform2/+/refs/heads/main/cros-codecs/
[2] https://github.com/chromeos/cros-codecs/commit/2c1b9d6c03fa50adeb4c4d3d7d2d77a89e6b3b57
[3] https://chromium.googlesource.com/chromiumos/platform2/+/8917a8d8b806404e0edc57f449d41803e779576b/cros-codecs/

Bug: 380289195, 377619217
Test: mm libcros_codecs
Change-Id: I8a209d3afa8f63e1a2ab5bcc2a2c3b8b7e904ac3
49 files changed
tree: 3e153da863cf35f93454ca4a28e5b61b3c8380cc
  1. ci/
  2. examples/
  3. fuzz/
  4. src/
  5. .clippy.toml
  6. .gitignore
  7. .prettierrc
  8. Android.bp
  9. Cargo.lock
  10. Cargo.toml
  11. cargo_embargo.json
  12. CONTRIBUTING.md
  13. DIR_METADATA
  14. LICENSE
  15. METADATA
  16. MODULE_LICENSE_BSD
  17. OWNERS
  18. README.md
  19. simple_test.py
README.md

Cros-codecs

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), but has no dependency to ChromeOS and should be usable anywhere.

Current features

  • Simple decoder API,
  • VAAPI decoder support (using 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.

$ cargo build --examples
$ ./target/debug/examples/ccdec --help
Usage: ccdec <input> [--output <output>] --input-format <input-format> [--output-format <output-format>] [--synchronous] [--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
  --synchronous     whether to decode frames synchronously
  --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 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.

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.