MCPcopy Index your code
hub / github.com/chromeos/cros-codecs

github.com/chromeos/cros-codecs @v0.0.6

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.0.6 ↗ · + Follow
1,760 symbols 4,459 edges 123 files 436 documented · 25%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Cros-codecs

crates.io docs.rs

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>] [--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 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.

Extension points exported contracts — how you extend this code

StatelessDecoderBackendPicture (Interface)
Specifies the type of picture that a backend will create for a given codec. The picture type is state that is preserved [10 …
src/decoder/stateless.rs
VaStreamInfo (Interface)
A trait for providing the basic information needed to setup libva for decoding. [5 implementers]
src/backend/vaapi/decoder.rs
VideoFrame (Interface)
Unified abstraction for any kind of frame data that might be sent to the hardware. [4 implementers]
src/video_frame.rs
BackendPromise (Interface)
Trait for representing pending encoder output. [4 implementers]
src/encoder/stateless.rs
DecodedHandle (Interface)
The handle type used by the decoder backend. The only requirement from implementors is that they give access to the unde [3 …
src/decoder.rs
C2Worker (Interface)
J should be either C2DecodeJob or C2EncodeJob. [2 implementers]
src/c2_wrapper.rs
VideoEncoder (Interface)
Generic video encoder interface. [2 implementers]
src/encoder.rs
ObuStruct (Interface)
(no doc) [3 implementers]
src/codec/av1/synthesizer.rs

Core symbols most depended-on inside this repo

read_bit
called by 364
src/codec/vp8/bool_decoder.rs
f
called by 158
src/codec/av1/synthesizer.rs
clone
called by 143
src/codec/av1/parser.rs
invalid_element_value
called by 123
src/codec/av1/synthesizer.rs
push
called by 103
src/decoder.rs
map
called by 103
src/video_frame/frame_pool.rs
len
called by 101
src/codec/h265/dpb.rs
borrow
called by 96
src/backend/vaapi/surface_pool.rs

Shape

Method 1,081
Function 293
Class 246
Enum 100
Interface 40

Languages

Rust100%
Python1%

Modules by API surface

src/codec/h264/parser.rs114 symbols
src/codec/av1/parser.rs95 symbols
src/codec/h265/parser.rs79 symbols
src/codec/h264/dpb.rs59 symbols
src/decoder/stateless/h264.rs56 symbols
src/codec/vp9/parser.rs52 symbols
src/bitstream_utils.rs50 symbols
src/codec/av1/synthesizer.rs48 symbols
src/backend/v4l2/encoder.rs48 symbols
src/decoder/stateless/h265.rs47 symbols
src/decoder/stateless/h265/vaapi.rs36 symbols
src/decoder/stateless/h264/vaapi.rs31 symbols

For agents

$ claude mcp add cros-codecs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact