Replace libjpeg with libjpeg-turbo for PHP 8.1+ on Windows

May 9, 2021 15:04 cmbecker69@gmx.de ("Christoph M. Becker")
Hi all,

I suggest to replace libjpeg[1] with libjpeg-turbo[2] for future PHP
releases on Windows, starting with PHP 8.1.  The main reason is that
libjpeg-turbo offers better performance, because it uses SIMD
instructions on supported platforms (Windows x86 and x64 are supported).
 Note that many (all?) Linux distributions also support libjpeg-turbo.

To my knowlege libjpeg-turbo can be used as compatible drop-in
replacement for libjpeg.  However, Windows builds are currently using
libjeg 9c, for which there is no compat layer in libjpeg-turbo due to
the controversial new color transform for the "Lossless SmartScale"
format introduced in libjpeg 9.  Besides that SmartScale is a non
standard format, the chosen implementation introduces an ABI break.
Anyhow, SmartScale is not used by ext/gd which is the most important
client of libjpeg (I'm not sure if there other extensions which use
libjpeg directly).

I've pushed libjpeg-turbo to a feature branch in the winlibs repo[3],
including the usual winlibs.mak.  To build it, NASM or YASM is required.
 I did not test the latter, though.  I also uploaded packages to
windows.php.net[4] (libjpeg-turbo-2.1.0-vs16-x(64|86).zip).  Whether you
build yourself or use the prebuilt packages, you can just unzip into the
deps/ folder of your build tree.

I've got the same test results for ext/gd/tests with libjpeg-9c and
libjpeg-turbo-2.1.0.

Thoughts?  Objections?

[1] <http://ijg.org/>
[2] <https://libjpeg-turbo.org/>
[3] <https://github.com/winlibs/libjpeg/tree/libjpeg-turbo>
[4] <https://windows.php.net/downloads/pecl/deps/>

--
Christoph M. Becker
May 9, 2021 15:45 Danack@basereality.com (Dan Ackroyd)
On Sun, 9 May 2021 at 16:04, Christoph M. Becker <cmbecker69@gmx.de> wrote:
> > I suggest to replace libjpeg[1] with libjpeg-turbo[2] for future PHP > releases on Windows, starting with PHP 8.1. > > Thoughts? Objections?
So the ABI break would only affect people who have some C code that is dependent on the new version of the data structure? If that's the case, then it sounds like either they can compile their own version of PHP for Windows, or complain about it during the release candidate process. But switching to the faster library sounds good. cheers Dan Ack
July 14, 2021 21:42 cmbecker69@gmx.de ("Christoph M. Becker")
On 09.05.2021 at 17:45, Dan Ackroyd wrote:

> On Sun, 9 May 2021 at 16:04, Christoph M. Becker <cmbecker69@gmx.de> wrote: >> >> I suggest to replace libjpeg[1] with libjpeg-turbo[2] for future PHP >> releases on Windows, starting with PHP 8.1. >> >> Thoughts? Objections? > > So the ABI break would only affect people who have some C code that is > dependent on the new version of the data structure?
Right. And I doubt that this is even used at all, since it is not compatible with common decoders.
> If that's the case, then it sounds like either they can compile their > own version of PHP for Windows, or complain about it during the > release candidate process. > > But switching to the faster library sounds good.
Great. I'm going to roll out libjpeg-turbo for php-src/master builds right away. Christoph