PDA

View Full Version : heads up on libjpeg optimization



konichiwa
11-01-2009, 11:20 PM
just wanted to let you guys know, i need to use libjpeg in a project and was having some problems, so i decided to plug in the clanlib precompiled static non-debug multi-threaded libjpeg from here:

http://clanlib.org/download-binaries-win32-vc80.html

http://clanlib.org/download/binaries-win32-vc90/all-2.0-external-libs-msvc90.zip

which helped a lot in solving my problem, because i knew the bug (probably) wasn't in the library.

BUT after solving the problem, i went back to the libjpeg i had been compiling in my own visual studio solution (2008), and was able to compare the performance. in my own compile of libjpeg, i turned on every optimization i could, including link-time optimization (whole program optimization), and the difference was huge, based on a rough measure: using the clanlib version, the program was taking up 30 percent of my CPU to decompress jpegs for use in an animation. using the optimized version i compiled myself, it was taking up 3 to 5 percent.

so ClanLib might want to check the optimizatioin settings you're using on your non-debug version of libjpeg.

Magnus Norddahl
11-02-2009, 01:01 AM
Did you also enable fast floating point math in your version? If you did and this made a huge difference, odds are that you are using the float version of idct instead of the fast integer idct in your application.

Regarding whole program optimization, that part has been deliberately disabled in our precompiled libraries. This is because whole program optimization only works within the same service pack of the compiler and we do not have the resources to recompile and offer the libraries in 4 different versions (VS2005, VS2005+SP1, VS2008, VS2008+SP1).

If the speed of JPEG decompression is very important for you, I have a SSE2 version of the float idct routine in libjpeg that uses compiler instrinsics. Only catch is that there's something slightly wrong with it, so it may require some debugging to get it to work 100%. I think the problem is somehow related to an error in the rounding rules but I never managed to figure it out fully. :) I'll post the code if you're interested.