Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plan to support for custom encoder like rav1e instead of aom ? #8

Closed
dreampiggy opened this issue Aug 21, 2019 · 5 comments
Closed

Comments

@dreampiggy
Copy link

Hi. I'm a user who previouslly use the libavif 0.1.x version.

Recently I found that this library supports two decoder codec, aom and dav1d, and the test performance of the dav1d is better than the aom.

Is there any plan to support another AVIF encoder implementation rav1e ?

Just a little curious about the plan for the massive AV1 codec...

@joedrago
Copy link
Collaborator

I don't have any specific plans right now to add any codecs, but I'm certainly not against it.

The pattern I put in place when I added dav1d would translate well to an encoder-only codec; I would just make it so that enabling it would override the encoding role from libaom, and if enabled in conjunction with dav1d, would avoid aom entirely.

@joedrago
Copy link
Collaborator

joedrago commented Oct 29, 2019

I implemented basic rav1e support today. If you read/execute rav1e.cmd in ext/, you should be able to build with -DAVIF_CODEC_RAV1E=1 -DAVIF_LOCAL_RAV1E=1 and it'll find the library and link against it.

I've only tested on windows-msvc (2017) and macOS Catalina.

@AurelC2G
Copy link
Contributor

Thanks for working on this!

I noticed a small issue with how you pass quantizer values to rav1e:

    int minQuantizer = AVIF_CLAMP(encoder->minQuantizer, 0, 63);
    int maxQuantizer = AVIF_CLAMP(encoder->maxQuantizer, 0, 63);
    if (alpha) {
        minQuantizer = AVIF_QUANTIZER_LOSSLESS;
        maxQuantizer = AVIF_QUANTIZER_LOSSLESS;
    }
    if (rav1e_config_parse_int(rav1eConfig, "min_quantizer", minQuantizer) == -1) {
        goto cleanup;
    }
    if (rav1e_config_parse_int(rav1eConfig, "quantizer", maxQuantizer) == -1) {
        goto cleanup;
    }

Values for min/max quantizer in libavif are in the [0, 63] range, but in rav1e they are in [0, 255] (see https://github.com/xiph/rav1e/blob/master/src/capi.rs#L490), so clamping like you are here restricts the encoder to a small range of quantizer values.

@dreampiggy
Copy link
Author

dreampiggy commented Oct 30, 2019

I've have a test on current ra1ve and aom on macOS 10.15. It seems rav1e encoding AVIF for this kids_720p.avif is 50 times faster 🤣 (aom need 1 minutes with 200% CPU Core, rav1e need just 2 seconds with just 100% CPU Core).

It's now really acceptable to make it possible for Client-User side program to integrate this. Previously my test programe just disable the AVIF encoding :)

@joedrago
Copy link
Collaborator

Excellent catch on the QP, I believe I've fixed it here:

0abf3b3

And yes, I was pleasantly surprised at rav1e's speed as well. If someone builds colorist (a tool of mine that uses libavif) with both rav1e and aom, I choose rav1e for encoding if aom isn't explicitly specified.

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

No branches or pull requests

3 participants