Thursday, July 12, 2007

Looking for IJG specialists

When I added the support of JPEg to VLIV, I tried to follow the "large images" philosophy, that is I am creating virtual tiles (in fact virtual strips), so only visible part of the file needs to be loaded.

Unfortunately the IJG library does not allow as is arbitrary positioning in the image, so I have to decompress the complete image up to the strip start position.

I subdivide the image in 256 pixels strips.

This is quite costly, as for example the more you go to towards the end, the more you have to decode "for nothing".
Imagine you have a 10000x10000 pixels image and a 1000x1000 display, and you want to display the bottom of the image.

This corresponds to 4 (or 5) strips, each requiring between 9000 and 10000 lines decoding
"for nothing", only to go to beginning of strip, so that while the memory used is much lower than storing the complete image, the CPU used is like 5 times the CPU used for loading the complete image.

There is clearly room for improvement.

Here is my code (repeated for each virtual strip):


// reading up to strip start, discarding results
for (idx = 0; idx < stripstarty; ++idx)
jpeg_read_scanlines(&cinfo, &dstptr, 1);
// reading stripheight
for (idx = 0; idx < stripheight && idxt < imageheight ; ++idx)
jpeg_read_scanlines(&cinfo, &dstptr, 1);


So if you are aware of any method that would speed up the first loop, that would be incredibly useful, and very large JPEG loading would be MUCH faster.

Or of course if you know a JPEG (preferably free) library that supports arbitrary region decoding, feel free to contact me.

No comments: