corevm-codec 0.2.0

CoreVM codec collection. Used to encode and decode output streams produced by the guest.
Documentation
  • Coverage
  • 100%
    22 out of 22 items documented1 out of 16 items with examples
  • Size
  • Source code size: 142.35 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.79 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 22s Average build duration of successful builds.
  • all releases: 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • paritytech/corevm-codec
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • igankevich

CoreVM codec

This is a collection of codecs that are used internally by CoreVM to encode and decode output streams produced by the guest. Currently this includes only video codec.

Video codec

This is fast and reasonably efficient video codec optimized for RISCV. This codec uses YUV color model, Haar wavelet transform, scalar quantization, rANS encoder, and simple inter-frame delta encoding. To the best of author's knowledge this is the smallest number of stages of a video encoding pipeline that are required to get decent compression ratio without significant performance degradation.

There are many royalty-free and open source video codecs but they tend to trade encoding speed for better compression ratio. This is acceptable tradeoff for a codec that is made for the web, but unacceptable in CoreVM context where a guest has only 6 seconds to generate and encode all video frames for the next time slot (i.e. next 6 seconds). Another problem is that a sizable portion of the source code in such codecs is written in x86/ARM assembly (example), and fallback code doesn't perform well on RISCV. Hence a custom codec.

Benchmarks

Below are the results of a benchmark for AV1, CoreVM and QOI+rANS codecs. The benchmark encodes 6 seconds worth of Quake frames. The benchmark was run inside CoreVM. Original video size is 9327 KiB.

Codec Compressed size Encoding time Compression ratio Crate
CoreVM 2283 KiB 308 ms 76%
QOI+rANS 5142 KiB 192 ms 45% qoi
AV1 275 KiB 22403 ms 97% rav1e

Same benchmark on x86_64 without CoreVM.

Codec Encoding time
CoreVM 172 ms
QOI+rANS 88 ms
AV1 1109 ms