go-avif
go-avif copied to clipboard
Increase performance of YCbCr and RGBA encoding
Increase performance of YCbCr and RGBA encoding.
- Reduced allocations due to using Image.Image interface on known Image types.
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)
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.