Kagami / go-avif

:art: Go AVIF library
Creative Commons Zero v1.0 Universal
314 stars 22 forks source link

Increase performance of YCbCr and RGBA encoding #16

Open evanoberholster opened 2 years ago

evanoberholster commented 2 years ago

Increase performance of YCbCr and RGBA encoding.

Benchmarks encoding a 500px YCbCr Image.

Benchmark/AVIF-12                  2     579077742 ns/op        1528 B/op        139 allocs/op

Compare Old and New implementation

name        old time/op    new time/op    delta
AVIF-12     591ms ± 1%     588ms ± 3%   -0.57%  (p=0.002 n=17+19)

name        old alloc/op   new alloc/op   delta
AVIF-12     536kB ± 0%       2kB ± 0%  -99.71%  (p=0.000 n=16+20)

name        old allocs/op  new allocs/op  delta
AVIF-12      167k ± 0%        0k ± 0%  -99.92%  (p=0.000 n=20+20)
Kagami commented 2 years ago

1st and 3rd cases seem to be the same? Also, I don't particularly like that the whole loop is duplicated...

For best performance both decoding and colorformat conversion should be done with SIMD and passed as raw bytes to the AV1 encoding library. Though AVIF encoding is so slow and it doesn't matter that much.