Hi everybody,
I've been running some lossless compression tests (to see how FLIF does w.r.t. the other formats), and I noticed a weird performance issue that might be worth investigating.
In general, WebP encoding is pretty fast, but it seems to be quite image-dependent.
I was testing on these images:
https://sourceforge.net/projects/testimages/files/PATTERNS/8BIT/GRAY/4096x2560_8BIT_GRAY.tar.bz2/downloadThese are all simple geometric patterns that usually compress very well because they are very repetitive. WebP does a very good job at compressing them. But sometimes it is extremely slow. All the images are the same dimensions (4096x2560). On some images, it took only ~0.15 seconds to encode them (on my laptop), which is very fast. On some other images, however, it took several minutes (!). The slowest ones take more than 1000 times longer than the fastest ones. I did my testing with "-m 6 -q 100" and cwebp 0.5.0 but the behavior seems to be the same with default options and older versions of cwebp.
It seems to be the 'fast' images are the horizontal ones (e.g. *_bars_horizontal_*) while the 'slow' ones have vertical patterns (e.g. *_bars_vertical_*).
Maybe this asymmetry between horizontal and vertical patterns is inherent to the WebP algorithm (the scanlines are horizontal after all), but I still have the feeling that there might be a performance bug here. In any case, in some use cases it can be quite problematic to have such wildly varying encode times (3 orders of magnitude for images that are essentially the same up to 90 degree rotation), so I would be interested in learning more about what causes this behavior and what can perhaps be done to predict or avoid the long encode times.
Best,
-Jon.