tags:

views:

2171

answers:

7

Hi, anyone know of a free open-source jpeg encoding library for C/C++? Currently I'm using ImageMagick, which is easy to use, but it's pretty slow. I compared it to an evaluation of Intel Performance Primitives and the speed of IPP is insane. Unfortunately it also costs 200$, and I don't need 99% of the IPP). Also it will only work fast on Intel.

Anyone do any tests? Any other good libraries out there faster than ImageMagick?

Edit: I was using 8 bit version of ImageMagick which is supposed to be faster.

+1  A: 

If you look around you might find an old version of the Intel JPEG Library. It's not opensource but it is fast. It was fast enough to get 25fps on a 733MHz P-III.

graham.reeds
Unfortunately I can't. Everyone refers to Intel which of course doesn't provide it any more. If you have a link, I'd like to have it.
Budric
+3  A: 

I believe that GIL, which is a library in Boost, contains a way to save image data in JPEG format. I don't know the speed of it, though. Given that the library is sponsored by Adobe, I would expect that it's pretty well done.

Kaz Dragon
Thanks, I missed that one even though I use boost.
Budric
i am not sure but, GIL uses libjpeg for decoding and encoding JPEG, so what matters here is libjpeg's performance..
Qubeuc
GIL is a generic image manipulation library, it does not implement any I/O and compression natively. Instead, as Qubeuc mentioned, it relies on third party libraries. Currently, GIL IO extensions have been implemented for JPEG using libjpeg and PNG using libpng. Perhaps TIFF (libtiff) is also available, I'm not sure.
mloskot
+2  A: 

AMD offers Framewave, an open sourced alternative to IPP.

Tobiesque
From briefly looking at the API it seems they provide JPEG fundamentals like DCT transform, but I don't see an actual write function that will give me a valid JPEG image. Have you used it? Can you point me to the right function?
Budric
Tobiesque
+1  A: 

There's also the Independent JPEG Group which is fairly old and I can't vouch for it's speed. But it should be stable.

Found through this page.

graham.reeds
That's what we use. It works just fine for what we use it for.
David Thornley
+1  A: 

ImageMagick uses libjpeg (a.k.a Independent JPEG Group library). If you improve the speed of libjpeg, ImageMagick JPEG speed will increase.

There are a few options:

  1. Compile an optimized libjpeg. If you have a modern gcc and at least a Pentium 4, you can try -O3 -msse2 and see if it can boost your speed. Then you can use LD_LIBRARY_PATH or some other way to load your libjpeg instead of the system one.
  2. Try out libjpeg-mmx. It is unmaintained, and supposedly buggy and with security flaws, but it may give a speed boost in your case.
Adam Goode
+1  A: 

I did some timing encoding a 512x512 jpeg using 100% quality (I know 100% is not lossless). Basically ImageMagick was only slightly slower than libjpeg. For 100 images the difference was on the order of 10th of a seconds. I then got libjpeg with SIMD extension (http://cetus.sakura.ne.jp/softlab/jpeg-x86simd/jpegsimd.html#source) and that thing 6-10 times faster. Note it really depends on the type of image. Images with lots of black are really fast, images with detail everywhere are really slow - I believe it's the encoding algorithm. I may have to give libjpeg-mmx a try because it looks more maintained than the japanese version I got that I don't even know what the license is.

I've also tried to get Framewave to work and couldn't even get it off the ground. The header files are missing definition of some structure and the forums provide absolutely no support. I can't believe it's "sponsored by AMD."

Budric
+2  A: 

Check out libjpeg/SIMD, in the trunk of TigerVNC (http://www.tigervnc.com). We have optimized 64-bit and 32-bit versions which are almost as fast as IPP at compressing/decompressing baseline JPEG:

http://www.mail-archive.com/[email protected]/msg00403.html

DRC
Thanks, I will.
Budric
I added an article to my wiki about how to build it for various architectures:http://www.virtualgl.org/DeveloperInfo/Libjpeg
DRC
Note that it is now available as a standalone SDK, renamed to libjpeg-turbo:http://libjpeg-turbo.virtualgl.org/
DRC