Git Product home page Git Product logo

rav1e's Introduction

rav1e Actions Status CodeCov

The fastest and safest AV1 encoder.

Table of Content

Overview

rav1e is an AV1 video encoder. It is designed to eventually cover all use cases, though in its current form it is most suitable for cases where libaom (the reference encoder) is too slow.

Features

  • Intra, inter, and switch frames
  • 64x64 superblocks
  • 4x4 to 64x64 RDO-selected square and rectangular blocks
  • DC, H, V, Paeth, smooth, and all directional prediction modes
  • DCT, (FLIP-)ADST and identity transforms (up to 64x64, 16x16 and 32x32 respectively)
  • 8-, 10- and 12-bit depth color
  • 4:2:0, 4:2:2 and 4:4:4 chroma sampling
  • 11 speed settings (0-10, exhaustive to near real-time)
  • Constant quantizer and target bitrate (single- and multi-pass) encoding modes
  • Still picture mode

Documentation

Find the documentation in doc/

Releases

For the foreseeable future, a weekly pre-release of rav1e will be published every Tuesday.

Building

Toolchain: Rust

rav1e currently requires Rust 1.70.0 or later to build.

Dependency: NASM

Some x86_64-specific optimizations require NASM 2.14.02 or newer and are enabled by default. strip will be used if available to remove the local symbols from the asm objects.

The CI is testing against nasm 2.15.05, so bugs for other versions might happen. If you find one please open an issue!

Install nasm

ubuntu 20.04 (nasm 2.14.02)

sudo apt install nasm

ubuntu 18.04 (nasm 2.14.02)

sudo apt install nasm-mozilla
# link nasm into $PATH
sudo ln /usr/lib/nasm-mozilla/bin/nasm /usr/local/bin/

fedora 31, 32 (nasm 2.14.02)

sudo dnf install nasm

windows (nasm 2.15.05)
Have a NASM binary in your system PATH.

$NASM_VERSION="2.15.05" # or newer
$LINK="https://www.nasm.us/pub/nasm/releasebuilds/$NASM_VERSION/win64"
curl --ssl-no-revoke -LO "$LINK/nasm-$NASM_VERSION-win64.zip"
7z e -y "nasm-$NASM_VERSION-win64.zip" -o "C:\nasm"
# set path for the current sessions
set PATH="%PATH%;C:\nasm"

macOS (nasm 2.15.05)

brew install nasm

Release binary

To build release binary in target/release/rav1e run:

cargo build --release

Unstable features

Experimental API and Features can be enabled by using the unstable feature.

cargo build --features <feature>,unstable

Current unstable features

  • Channel API:
cargo build --features channel-api,unstable

Those Features and API are bound to change and evolve, do not rely on them staying the same over releases.

Target-specific builds

The rust compiler can produce a binary that is about 11%-13% faster if it can use avx2, bmi1, bmi2, fma, lzcnt and popcnt in the general code, you may allow it by issuing:

RUSTFLAGS="-C target-cpu=native" cargo build --release
# or
RUSTFLAGS="-C target-cpu=x86-64-v3" cargo build --release

The resulting binary will not work on cpus that do not sport the same set of extensions enabled.

NOTE : You may use rustc --print target-cpus to check if the cpu is supported, if not -C target-cpu=native would be a no-op.

Building the C-API

rav1e provides a C-compatible set of library, header and pkg-config file.

To build and install it you can use cargo-c:

cargo install cargo-c
cargo cinstall --release

Please refer to the cargo-c installation instructions.

Usage

Compressing video

Input videos must be in y4m format. The monochrome color format is not supported.

cargo run --release --bin rav1e -- input.y4m -o output.ivf

(Find a y4m-file for testing at tests/small_input.y4m or at http://ultravideo.cs.tut.fi/#testsequences)

Decompressing video

Encoder output should be compatible with any AV1 decoder compliant with the v1.0.0 specification. You can decode using dav1d, which is now packaged in over 40 repositories.

dav1d -i output.ivf -o output.y4m

Configuring

rav1e has several optional features that can be enabled by passing --features to cargo. Passing --all-features is discouraged.

Features

Find a full list in feature-table in Cargo.toml

  • asm - enabled by default. When enabled, assembly is built for the platforms supporting it.
    • x86_64: Requires nasm.
    • aarch64
      • Requires gas
      • Alternative: Use clang assembler by setting CC=clang

NOTE: SSE2 is always enabled on x86_64, neon is always enabled for aarch64, you may set the environment variable RAV1E_CPU_TARGET to rust to disable all the assembly-optimized routines at the runtime.

Contributing

Please read our guide to contributing to rav1e.

Getting in Touch

Come chat with us on the IRC channel #daala on Libera.Chat! You can also use a web client to join with a web browser.

rav1e's People

Contributors

anotherwon avatar barrbrain avatar dependabot[bot] avatar dwbuiten avatar ewouth avatar gramner-twoorioles avatar kodawah avatar kylesiefring avatar lu-zero avatar luni-4 avatar mbebenita avatar mstorsjo avatar negge avatar psilokos avatar rbultje avatar redzic avatar renovate[bot] avatar rom1v avatar rzumer avatar shssoichiro avatar smarter avatar takehirokj avatar tdaede avatar tmatth avatar urhengulas avatar vibhoothi avatar vladimir-kazakov avatar xiphmont avatar yalter avatar ycho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rav1e's Issues

Add partition splitting to RDO

Currently in encode_tile for every superblock, we search for the intra mode with the best RD (based on a 64x64 SSE), for PARTITION_NONE. We should extend this search to one-level of split.

Need to add reset_skip_context()

If current block is skipped, the encoder should reset coeff contexts of above and left as zeros,
for width and height of the current block size, resp.

A better name?

rav1e is great and all, but it doesn't quite roll off the tongue. Let's comment on this issue with name ideas, and then vote on them using ๐Ÿ‘.

Warnings with "cargo bench"

yushin@maui:~/workspace/rav1e$ cargo test
Compiling bitstream-io v0.6.3
Compiling bitflags v1.0.1
Compiling bencher v0.1.5
Compiling bitflags v0.4.0
Compiling encode_unicode v0.1.3
Compiling vec_map v0.8.0
Compiling unicode-width v0.1.4
Compiling ansi_term v0.10.2
Compiling y4m v0.1.1
Compiling byteorder v1.2.1
Compiling libc v0.2.36
Compiling strsim v0.7.0
Compiling textwrap v0.9.0
Compiling nix v0.5.1
Compiling atty v0.2.6
Compiling rand v0.4.2
Compiling clap v2.30.0
Compiling rustyline v1.0.0
Compiling rav1e v0.1.0 (file:///home/yushin/workspace/rav1e)
Finished dev [unoptimized + debuginfo] target(s) in 9.73 secs
Running target/debug/deps/rav1e-9b00cc822757fb1d

running 6 tests
test ec::test::booleans ... ok
test ec::test::cdf ... ok
test ec::test::mixed ... ok
test predict::test::pred_max ... ok
test predict::test::pred_same ... ok
test predict::test::pred_matches ... ok

test result: ok. 6 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

 Running target/debug/deps/rav1e-5895d273f770ce9f

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

 Running target/debug/deps/rav1repl-81dcf9202be56248

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

Doc-tests rav1e

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

yushin@maui:~/workspace/rav1e$ cargo bench
Compiling bencher v0.1.5
Compiling rav1e v0.1.0 (file:///home/yushin/workspace/rav1e)
warning: unused import: rav1e::predict::*;
--> benches/bench.rs:95:5
|
95 | use rav1e::predict::*;
| ^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default

warning: unused variable: mode
--> benches/bench.rs:111:9
|
111 | let mode = PredictionMode::DC_PRED;
| ^^^^
|
= note: #[warn(unused_variables)] on by default
= note: to avoid this warning, consider using _mode instead

warning: foreign function is never used: highbd_dc_left_predictor
--> benches/bench.rs:15:5
|
15 | / fn highbd_dc_left_predictor(dst: *mut u16, stride: libc::ptrdiff_t, bw: libc::c_int,
16 | | bh: libc::c_int, above: *const u16,
17 | | left: *const u16, bd: libc::c_int);
| |______________________________________________________________^
|
= note: #[warn(dead_code)] on by default

warning: foreign function is never used: highbd_dc_top_predictor
--> benches/bench.rs:18:5
|
18 | / fn highbd_dc_top_predictor(dst: *mut u16, stride: libc::ptrdiff_t, bw: libc::c_int,
19 | | bh: libc::c_int, above: *const u16,
20 | | left: *const u16, bd: libc::c_int);
| |______________________________________________________________^

warning: foreign function is never used: highbd_h_predictor
--> benches/bench.rs:21:5
|
21 | / fn highbd_h_predictor(dst: *mut u16, stride: libc::ptrdiff_t, bw: libc::c_int,
22 | | bh: libc::c_int, above: *const u16,
23 | | left: *const u16, bd: libc::c_int);
| |______________________________________________________________^

warning: foreign function is never used: highbd_v_predictor
--> benches/bench.rs:24:5
|
24 | / fn highbd_v_predictor(dst: *mut u16, stride: libc::ptrdiff_t, bw: libc::c_int,
25 | | bh: libc::c_int, above: *const u16,
26 | | left: *const u16, bd: libc::c_int);
| |___________________________________________^

warning: function is never used: pred_h_4x4
--> benches/bench.rs:37:1
|
37 | fn pred_h_4x4(output: &mut [u16], stride: usize, above: &[u16], left: &[u16]) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: function is never used: pred_v_4x4
--> benches/bench.rs:44:1
|
44 | fn pred_v_4x4(output: &mut [u16], stride: usize, above: &[u16], left: &[u16]) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Finished release [optimized] target(s) in 3.83 secs
 Running target/release/deps/rav1e-c60027f9b9bd002f

running 6 tests
test ec::test::booleans ... ignored
test ec::test::cdf ... ignored
test ec::test::mixed ... ignored
test predict::test::pred_matches ... ignored
test predict::test::pred_max ... ignored
test predict::test::pred_same ... ignored

test result: ok. 0 passed; 0 failed; 6 ignored; 0 measured; 0 filtered out

 Running target/release/deps/rav1e-ab1af7a55ae80597

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

 Running target/release/deps/rav1repl-b79447a2b246d724

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

 Running target/release/deps/bench-741fd4a6e67fa1d0

running 4 tests
test aom ... bench: 1,188,882 ns/iter (+/- 38,736)
test native ... bench: 975,183 ns/iter (+/- 59,961)
test native_trait ... bench: 269,857 ns/iter (+/- 10,470)
test write_b_bench ... bench: 123,071 ns/iter (+/- 6,586)

test result: ok. 0 passed; 0 failed; 0 ignored; 4 measured

yushin@maui:~/workspace/rav1e$

cmake-building is unreliable

  • a manual cargo clean is needed when the libaom code gets updated
  • on some platforms there is no way to avoid the wxwindows dependency
  • the encoding-decoding test is not present yet

Reverting #99 would be an improvement.

Figure out why cargo rebuilds everything unnecessarily.

cargo run --bin rav1e --release
   Compiling rav1e v0.1.0 (file:///Users/.../Workspace/rav1e)
    Finished release [optimized] target(s) in 6.98 secs
     Running `target/release/rav1e`

7s is too long to wait if the code hasn't changed.

Decoded output not cropped for non-integer multiple of SB size input

To reproduce, encode akiyo_qcif.y4m. (176x144)

Reconstructed output:
rec

Decoded output:
dec

We need to skip non-visible blocks in write_sb (done), change the dimensions that we write in write_uncompressed_header (done), change how partitions are coded on the edges of the frame (not started), get all sizes of intra-predictors (not needed since we force 4x4 everywhere).

Encoding 720p park_joy results in garbled decode.

I encoded park_joy_420_720p50.y4m, and then decoded it using the specific git checkout of aom listed in the README. It resulted in this (after being piped to ffmpeg to dump PNGs):

https://themayhaks.com/~gideon/test-av1-png/

IVF file is here (about 88MB):

https://themayhaks.com/~gideon/test.ivf

I'm not sure if this is just a result of me not resizing to 1280x768 before feeding it to rav1e, but it didn't complain and it seems to have converted it to 1280x768 during the encoding process.

Add integration tests

That is another lovely built-in feature of Rust. Let's use it asap, and not writing hassle separate unit-tests programs.

Add support for currently disabled experiments.

Currently a number of experiments are disabled in the decoder. To update the decoder to the final AV1 bitstream, we must enable them. A number of these are quite easy - they simply add a bit to the uncompressed header indicating whether they are used or not, so you must simply add that bit, then remove the flag from the decoder's configuration. Experiments that have simple changes to the header:

--disable-aom_qm
--disable-ext-intra
--disable-ext_partition
--disable-loopfilter_level
--disable-cfl (requires look up table changes)
--disable-kf-ctx
--disable-striped_loop_restoration
--disable-max_tile
--disable-ext-intra-mod
--disable-frame_size
--disable-simplify_tx_mode
--disable-obu (more complex, but still only header changes)

Add lv-map support.

Steps:

  • Understand LV_MAP_MULTI (multi symbol version of Level Map) algorithm and code in libaom.
  • Force partition level skip, enable lv-map, make sure image decodes. (i.e. all changes are self contained in write_coeffs)
  • Force lv-map level skip, don't desync.
  • Code a +/-1 DC coefficient, don't desync within a superblock.
  • Code arbitrary coefficients within a superblock.
  • Code all superblocks without desyncing.

LV_Map slides
https://docs.google.com/presentation/d/1nbplj5yuq2OTNQFMbymfASRsfg58GLZjvzWE3MtoZWg/edit#slide=id.g245e1ced9c_1_5

More slides (improvements)
https://docs.google.com/presentation/d/1GcCv543QV10uIehWAaoM9xjJvJkXP-MbLV_Z6GVvIq8/edit#slide=id.p

Paper
https://usercontent.irccloud-cdn.com/file/KUIqFjBi/level_map.pdf

Remove experimental flag of LV_MAP_MULTI
78f7bb98558f513ab69b7d871bf45bf119b1fd5b
https://aomedia.googlesource.com/aom/+/78f7bb98558f513ab69b7d871bf45bf119b1fd5b

Remove experimental flag of LV_MAP
cad5ebce76b50cb413b980a17748941621a747e3
https://aomedia.googlesource.com/aom/+/cad5ebce76b50cb413b980a17748941621a747e3

Support skip mode.

  • This task includes:
  1. Need to add reset_skip_context() if a partition is skipped.

Add unit test for skips

Test can be like:

  1. Random skip of partitions.
  2. Skip odd rows, skip even rows
  3. Skip odd columns, skip even rows

Add CDEF support.

For now, set a constant CDEF level, and simply call the C CDEF implementation.

Support all partitions types

Rename the existing task #127 as "Support Minimum Partition types" then create new task with old name from #127, "Support all partitions types".
As explained in #127, supporting all partition types does not seem essential and not meaningful w/o "ROD based block size decision", so I assume it is not part of MVP.

Basic speed level based on minimum partition block size

Speed level decides the minimum partition block size, where recursive quadri-sect splitting stops at.
0(slowest) : BLOCK_4X4
1 : BLOCK_8X8
2 : BLOCK_16X16
3 : BLOCK_32X32
4~10(fastest) : BLOCK_64X64

Encoder option : "--speed=[0..10]" or "-s [0..10]".

Exception: SuperBlock(SB)s on right or bottom frame borders always split down to BLOCK_4X4.

In the future, min partition block size may be controlled by separate encoder option.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.