uvg266 VVC Encoder
repository·master·Indexed 43 days ago
https://github.com/ultravideo/uvg266An open-source Versatile Video Coding (VVC) encoder designed for high-performance video compression research and application. It supports Linux and Windows, featuring a wide range of CLI parameters for rate control, GOP structure, and compression tools, as well as encoding presets ranging from ultrafast to placebo.
What's inside uvg266
- uvg266 is an open-source VVC (Versatile Video Coding) encoder licensed under the 3-clause BSD license. It is currently under active development with ongoing improvements to encoding speed and Rate-Distortion (RD) quality. It supports Linux and Windows platforms.
What is ThreadWrapper
masterThreadWrapper is a utility that wrapspthreadfunctions to ensure they call C++ standard functions instead. This is specifically designed to provide compatibility for the Kvazaar open-source HEVC encoder. Currently, it only implements the subset of functions required by Kvazaar, though it is designed to be extensible by contributors.Understand the compressed cost data format
masterThe extracted block costs are stored in a compressed format sorted by block QP. Because the datasets are extremely large (often exceeding workstation RAM), they are designed to be processed with $O(1)$ memory complexity rather than being memory-mapped.
Each entry in the compressed file follows this structure:
Size (B) Description 4 size: Coeff group size, in int16's4 ccc: Coeff group's coding costsize * 2coeffs: Coeff group dataUnderstand LP-GOP (Low-Delay GOP) syntax
masterThe
uvg266encoder supports a specific syntax for Low-Delay GOPs to control temporal scaling. The syntax follows the patternlp-g(num)d(num)t(num):g: GOP length.d: Number of GOP layers.t: Number of references to skip for temporal scaling (e.g.,t4means only every fourth picture needs to be decoded).
Example:
lp-g8d4t1defines a GOP with length 8, 4 layers, and a temporal skip factor of 1.# Syntax: lp-g<gop_length>d<layers>t<temporal_skip> # Example: lp-g8d4t1Integrate the uvg266 library
masterThe core API is defined in
uvg266.h.Windows Static Linking: When using the static uvg266 library on Windows, you must define the
UVG_STATIC_LIBmacro.Dependencies: You can use
pkg-configto obtain the necessary linker and compiler flags for integration.Extract block costs using extract_rdcosts.py
masterTo extract block costs, you must first build
Kvazaaras usual. Then, configure theextract_rdcosts.pyscript by editing the parameters at the beginning of the file—specifically the number of CPU cores to use and the list of video sequences you wish to encode.Running
extract_rdcosts.pywill useKvazaarto encode each sequence and extract the measured costs for the quantized blocks. The resulting data is stored in a compressed format, sorted by block QP.# Edit extract_rdcosts.py parameters (cores and sequences) then run: python extract_rdcosts.pyRun unit tests
masterThe project uses the
greatestunit testing framework.Setup: Before running tests, you must initialize and update the submodules:
git submodule init git submodule updateExecution:
- Linux: Run
make test. - Windows: The Visual Studio project links unit tests against the actual
.libfile used by the encoder.
git submodule init git submodule update make test- Linux: Run
Basic usage of uvg266 VVC encoder
masterTo encode a video using
uvg266, you must provide an input file and an output filename. If the input resolution is not part of the filename or if you are using a pipe, you must explicitly specify the resolution using--input-res.By default, the encoder expects 8-bit
yuv420por 10-bityuv420p10leinput. You can override these using--input-formatand--input-bitdepth.uvg266 --input BQMall_832x480_60.yuv --output out.vvc # If resolution is not in filename: uvg266 --input input.yuv --input-res 1920x1080 -o out.vvcBuild uvg266 using CMake
masterTo compile uvg266 from source using CMake, follow these steps. On Ubuntu, ensure
build-essentialandcmakeare installed.- Configure the build:
cmake -B build -S . - Build the project:
cmake --build build --parallel - Install (optional):
sudo cmake --install build
Visual Studio users can open the
CMakeLists.txtdirectly, or use the CMake-CLI to generate Visual Studio project files.cmake -B build -S . cmake --build build --parallel sudo cmake --install build- Configure the build:
Calculate per-QP average costs with rdcost_do_avg.py
masterAfter running the regression, use
rdcost_do_avg.pyto calculate the average costs per QP across all processed sequences. For each QP, the script takes the results for that QP from every sequence and calculates their average.This averaged data is intended to be used to populate the
default_fast_coeff_cost_wtstable located insrc/fast_coeff_cost.h.python rdcost_do_avg.pyBuild and run the RD cost analysis tools
masterTo analyze costs via linear regression, you must first compile the two C tools. Once compiled, you can run the regression in parallel using
run_filter.py.# Build the tools gcc filter_rdcosts.c -O2 -o frcosts_matrix gcc ols_2ndpart.c -O2 -o ols_2ndpart # Run the regression in parallel python run_filter.pyUse Region of Interest (ROI) files with Kvazaar
masterYou can use the
--roiswitch in Kvazaar to specify a text file that defines regions of interest for encoding. This allows you to assign different quantization parameter (QP) offsets to specific areas of a frame, controlling the bit distribution and quality across the image.ROI File Format
The ROI file is a simple text file structured as follows:
- Header Row: Contains two integers representing the number of columns and rows the frame is divided into.
- Data Row: Contains a single row of integers. The number of entries must equal
columns * rows. Each entry represents the delta QP value assigned to that specific region.
Example Configuration
The following example divides a frame into a 2x2 grid. The top two regions are assigned a delta QP of
5(lower quality/higher compression), while the bottom two regions are assigned0(standard quality/no offset).2 2 5 5 0 0