-
-
Notifications
You must be signed in to change notification settings - Fork 354
Description
While running benchmarks for still-image AVIF encoding using libheif + SVT-AV1, I noticed that the memory usage is significantly higher than when using SVT-AV1 directly. It appears that libheif does not forward the SVT encoder parameter --avif 1, even when explicitly specified using svt:avif=1.
According to the SVT-AV1 logs, enabling avif=1 activates optimizations for still images (reduced parallel picture sets, different rate-control mode, etc.).
Below is a reproducible example.
1. Encoding via libheif (high RAM usage, SVT warning shown)
Command:
/usr/bin/time -v heif-enc --avif -p "threads=1" -p "speed=9" --quality=44 -o test.avif parrot-jpg.jpgRelevant log:
Svt[info]: Number of PPCS 42
...
Svt[info]: BRC mode / rate factor : CRF / 35
...
Svt[info]: Only a single picture was passed in. Consider setting avif=1 for improved efficiency and reduced memory usage.
...
... some more /usr/bin/time logs
...
Percent of CPU this job got: 100%
Maximum resident set size (kbytes): 82856
2. Encoding via SVT-AV1 directly (much lower RAM usage)
Equivalent parameters using ffmpeg + SvtAv1EncApp:
bash -c "ffmpeg -y -i parrot-jpg.jpg -pix_fmt yuv420p -f yuv4mpegpipe - | /usr/bin/time -v SvtAv1EncApp -i stdin --preset 9 --crf 35 --lp 1 --avif 1 -b testsvt.avif"Relevant log:
...
Svt[info]: Number of PPCS 2
Svt[info]: BRC mode / CQP Assignment : CQP / 35
...
... some more /usr/bin/time logs
...
Percent of CPU this job got: 65%
Maximum resident set size (kbytes): 34216
In summary being able to pass --avif 1 to SVT is helping reduce RAM and CPU usage, the resulting image is smaller in size, and the encoding time is also lower. avif=1 is a documented SVT-AV1 parameter intended specifically for still-image encoding.
Given the above benefits it would be very helpful if libheif exposed a way to pass avif=1 to SVT-AV1, e.g.:
-p svt:avif=1
or simply enable it automatically when encoding a single image with --avif.
If this change aligns with libheif’s design goals, I’m happy to prepare a PR.
Additional info
In the above example I'm using the following image but I am able to reproduce RAM and CPU usage differences with any image:
And here is SVT's documentation for avif parameters.