Is it better to use jpeg_write_scanlines with multiple scan lines at once?

Using libjpeg (or libjpeg-turbo) for JPEG encoding, I was wondering if there were any improvements providing multiple lines of scan for the jpeg_write_scanlines function at once. I did some tests on 720x288 images, but only get 0.5% when processing the entire image at the same time.

I assume that this increase is only due to the removal of overhead call stacks, but I expected a bit more, at least with libjpeg-turbo.

A performance test was run with Callgrind (in Valgrind), so maybe I missed something. Or I really misunderstood how a JPEG encoder works.

+4
source share
1 answer

JPEG has a minimum line height called MCU height. These are 8 lines in images without subsampling (4: 4: 4 mode) or 16 lines if the color is a subsample (4: 2: 0 mode).

If you feed libjpeg to these 8 or 16 lines, it will be able to process the entire line at a time. Otherwise, this will require additional bookkeeping or buffering.

Writing multiple MCU heights at a time or the entire image will not hurt.

+3
source

Source: https://habr.com/ru/post/1500670/


All Articles