JpegDec - Fast JPEG Decoder for Delphi

JpegDec is an open source JPEG decoder for Delphi originally written by Dr Manhattan: and modified for use with Delphi by Arnaud Bouchez:

Unfortunately, the original Delphi library was not thread safe, so I've modified the library to allow for full use in multithreaded applications.

The actual changes required were quite minor and I'm surprised that no one else had done them before - I'm guessing that there just aren't that many Delphi programmers that understand assembler.

The original code wasn't thread safe because it used a global variable to store a value - trying to use the code from multiple threads caused an exception. I've modified the assembler code to instead store the value on the stack.

Some performance statistics:

CPU: Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz
Core Count: 4
Thread Count: 8
Iterations: 1000
Thread Count: 8

Single Threaded Performance: 138 images per second
Multithreaded Performance:   439 images per second
Relative Performance: 318%

Single Threaded Performance: 117 images per second
Multithreaded Performance:   131 images per second
Relative Performance: 112%

Standard Delphi: 
Single Threaded Performance: 26 images per second
Multithreaded Performance:   151 images per second
Relative Performance: 581%

As you can see above, on an Intel Core i7, the modification allows for over 3 times the throughput compared to a single thread!

It's interesting to note that even when using a single thread, JpegDec is still faster than SynGdiPlus - SynGdiPlus sees very little improvement from multithreading.

The standard JPEG code that comes with Delphi sees a huge improvement with multithreading, however even when using 8 threads, it's still only marginally quicker than JpegDec on a single thread!

Downloads: Modified Source Code - my copy. Modified Source Code - on - may be more recent.

JpegDecSample.exe Sample program to test performance on your own systems.
Sample.jpg Sample Image used for the above testing. Source code for the above sample program, including Sample.jpg Written with Delphi 10.1 Berlin.

If you know of a faster JPEG decoding library for Delphi or would otherwise like to contact me, you can do so at:


You may also be interested in:

Flexible Rostering Software.

NetTime - Network Time Synchronizer.

POP3Filter - An Advanced Bayesian Spam Filter