multi-threading with libjpeg

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Locked
phireph0x

multi-threading with libjpeg

Post by phireph0x »

we're developing a network app using the Magick++ interface that reads several *.jpg images from disk from multiple separate threads. Even though ImageMagick has been compiled statically with multi-threading support on Win32, we notice when we step through the code that threading is being disabled for JPEGs (libjpeg), so the images are being read from disk in a non-threaded fashion. Is this intentional, or should libjpeg be thread-safe?

perusing the ImageMagick site docs, it seems that the claim is made that ImageMagick is thread-safe with the exception of a few select pixel cache related functions, which we don't use in our code..

Is ImageMagick thread-safe for libjpeg, or is multi-threading disabled because of thread-safety issues with libjpeg?

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: multi-threading with libjpeg

Post by magick »

ImageMagick is thread safe, the JPEG delegate library is not. You can enable thread support by editing coders/jpeg.c and changing the thread support member to this:
  • entry->thread_support=DecoderThreadSupport | EncoderThreadSupport;
in the RegisterJPEGImage() method.

phireph0x

Re: multi-threading with libjpeg

Post by phireph0x »

thanks for the info.

if the delegate library, libjpeg, is not thread-safe, then i'd rather not enable threading, overriding the defaults, if the results will be unstable.

is there an alternative delegate library for the jpeg coder, or is no multi-threading support simply a fact of life when dealing with JPEGs and ImageMagick?

Locked