crosvm/media/ffmpeg
Alexandre Courbot 5eba4ce565 media: ffmpeg: add pixel format wrapper and iterator
For the encoder device, we will need to be able to iterate over the
supported pixel formats in order to expose the ones that are supported.
Add a type to wrap the native AVPixelFormat as well as an iterator to
AvCodec that will let us list all the available pixel formats.

BUG=b:239897269
TEST=cargo build --features "video-decoder,ffmpeg"

Change-Id: Ia835dc428b221c70178f2cd6634566001f3a9256
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782040
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2022-08-05 11:09:42 +00:00
..
src media: ffmpeg: add pixel format wrapper and iterator 2022-08-05 11:09:42 +00:00
bindgen.sh virtio: video: decoder: add ffmpeg-based software decoder backend 2022-06-07 11:44:21 +00:00
build.rs virtio: video: decoder: add ffmpeg-based software decoder backend 2022-06-07 11:44:21 +00:00
Cargo.toml virtio: video: decoder: add ffmpeg-based software decoder backend 2022-06-07 11:44:21 +00:00
README.md virtio: video: decoder: add ffmpeg-based software decoder backend 2022-06-07 11:44:21 +00:00
VERSIONS virtio: video: decoder: add ffmpeg-based software decoder backend 2022-06-07 11:44:21 +00:00

FFmpeg wrapper

This is a minimal FFmpeg 4.4 wrapper for use with the virtio-video device, allowing to run a virtual video device backed by software decoding or encoding. This is useful for development and testing in situations where no supported video acceleration is available on the host.

Although several FFmpeg binding crates exist, most of them are not able to link against the system FFmpeg, and the only one that does is released under a software license that makes our lawyers nervous. Also they all run bindgen at build time, which is not possible to do under the Chrome OS build system and would require to patch the crate with fully generated bindings.

So taking this in consideration, as well as the extra work that it is to depend on external Rust crates in Chrome OS, it is preferable to add our own simple bindings here that cover just the parts of FFmpeg that we need.

This crate has minimal dependencies ; on the FFmpeg side, it just uses libavcodec, libavutil and libswscale.

The bindings can be updated using the bindgen.sh script. A few elements that bindgen cannot generate because they are behind C macros are re-defined in avutil.rs and error.rs, as well as tests to ensure their correctness.

And that's about it.