Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
Same benchmark on
x86_64without CoreVM.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).