Skip to content

Video codec#1

Merged
igankevich merged 8 commits intomasterfrom
ivan/video-codec
Feb 18, 2026
Merged

Video codec#1
igankevich merged 8 commits intomasterfrom
ivan/video-codec

Conversation

@igankevich
Copy link
Collaborator

@igankevich igankevich commented Feb 18, 2026

This PR introduces a 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 my 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

Demo

Below are two animated PNG images generated with ffmpeg: the left image was generated from raw Quake frames (convert Quake frames RGB, then to PNG), the right image was generated from the CoreVM video stream (convert CoreVM frames to raw RGB, then to PNG).

Original CoreVM
quake-frames quake-frames corevm

@igankevich igankevich merged commit 1c85afe into master Feb 18, 2026
3 checks passed
@igankevich igankevich deleted the ivan/video-codec branch February 18, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant