Does UIC support partially decode for ultra-high resolution JPEG ?

Does UIC support partially decode for ultra-high resolution JPEG ?


I'm trying to decode a 8k x 6k JPEG in 16bits color depth and then make the color channels from RGB to BGRA, but I can NOT allocate a large continuous memory space for it, it's about 366 MB= 274 MB(RGB,16bit)+92 MB(A,16bits). And I want to divide them into seperated memory blocks inside the process(x32) virtual space.

I knew and tried that WIC(window image component) has the ability to decode image by specifiying a WICRect (x,y,width,height). 

So I traced the UIC source code (uic_jpeg_dec.cpp, jpeg.cpp, jpegdec.cpp, etc...), It looks like that I can do what I want by setting a ROI information in ImageSamplingGeometry.

Sad thing was, it failed for me. No matter how I config the origin in geometry.RefGridRect(), I can only got the result buffer starting from (0, 0) even I set the origin to (0, 1000) for example.

Here's my calling procedure. (To decode 8k x 6k jpeg)

1. I allocate 8k * 1k memory space (so in this case, I will need to do ROI decode six times for different y position)

2. Attach this memory block to a CIppImage and pass this CIppImage instance to ReadImageJPEG(BaseStreamInput& in, PARAMS_JPEG& param, CIppImage& image) in jpeg.cpp

3. Set the target decode ROI information (0, 1000, 8k, 1k) to a (ImageSamplingGeometry)variable, called geometry.

4. Then attached the input buffer(CIppImage) to a (UIC.Image) imageCn by calling this imageCn.Buffer().Attach(&dataPtr,dataOrder,geometry);

5. And jpegdec.ReadData(imageCn.Buffer().DataPtr(),dataOrder) is performed.

My Question is ...

1. Does UIC support ROI decode?  I didn't found any code refering to the input origin.

2. If UIC supports, what do I miss in the procedure above ?

Great thanks in advance.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

If by 16-bit you men per channel then that is your problem. As far as I know UIC does not support such bit depth. I have successfully decoded larger images than yours so the size should not be a problem.

By the way, 32-bit process should be able to allocate that much contiguous memory. If you cannot, then check the base addresses of all DLLs loaded by your application and make sure they are not fragmenting your process address space. You can rebase your own DLLs (and even the ones you will redistribute) but in order for that to work you need to disable ASLR.

Yes, UIC by design is not capable to process encoding/decoding using ROIs (or slices). It may the problem, because the size of images is growing quickly. We'll look of what can be done in this direction.
16-bit pixels in UIC can be used in JPEG lossless mode only.

Leave a Comment

Please sign in to add a comment. Not a member? Join today