Add AV1 frame size override support

Previously the AV1 stateless decoder made no distinction between visible
resolution and coded resolution, and would only change the coded
resolution when it received a new SequenceHeaderObu. This would not
allow for DRC through AV1's frame_size_override flag.

This change makes it so that the AV1 stateless decoder keeps track of
the visible resolution and will trigger a resolution change event if the
incoming frame resolution does not match the previous visible
resolution.

Bug: 382695401
Test: video.PlatformDecoding.cros_codecs_vaapi_av1_files_from_bugs_346405213
Change-Id: I6cc2ee982da46b53ed74cc963ad39e0f9389a571
3 files changed
tree: 4d85eab46007e5eb3a27b46af0d72daa9ca764cc
  1. .cargo/
  2. ci/
  3. examples/
  4. fuzz/
  5. src/
  6. .clippy.toml
  7. .gitignore
  8. Android.bp
  9. Cargo.toml
  10. cargo_embargo.json
  11. CONTRIBUTING.md
  12. DIR_METADATA
  13. LICENSE
  14. METADATA
  15. MODULE_LICENSE_BSD
  16. OWNERS
  17. README.md
  18. 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.