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.