Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

ippiWTInv Maximum Image Size?

Joshua_K_
Beginner
401 Views

I am trying to use ippiWTFwd and ippiWTInv to compute the haar transform of an image.  The image is already in a size that is powers of 2, so I don't have to worry about replication or extending the image border.  When I call my function on a 256x256 image up to a 1024x1024 image it doesn't cause a problem.  If I try an image that is 2048x2048 or larger, my function will crash in ippiWTInv and return a read access violation at 0x0.

Here is the function I am using, which I pass the image data and the image width/height.

[cpp]

Ipp32f* haarIppi(Ipp32f* inputBuffer, int width, int height)
{
IppiWTFwdSpec_32f_C1R* pSpec;
IppiWTInvSpec_32f_C1R* pSpecInv;
Ipp32f pTapsLow[2] = {0.7071067811865475f,0.7071067811865475f};
Ipp32f pTapsHigh[2] = {0.7071067811865475f,-0.7071067811865475f};
int lenLow = 2;
int anchorLow = 1;
int lenHigh = 2;
int anchorHigh = 1;

int srcStep = width*sizeof(Ipp32f);
Ipp32f* pDetailXDst = new Ipp32f[width*height/4];
Ipp32f* pDetailYDst= new Ipp32f[width*height/4];
Ipp32f* pDetailXYDst = new Ipp32f[width*height/4];
Ipp32f* pApproxDst = new Ipp32f[width*height/4];
IppiSize dstRoiSize = {width/2, height/2};
int bufSize, bufSizeInv;
Ipp8u* pBuffer;
Ipp8u* pBufferInv;
Ipp32f* pDstInv = new Ipp32f[width*height];

IppiSize roiInvSize = {width/2, height/2};
int stepDstInv = width*sizeof(Ipp32f);
int approxStep, detailXStep, detailYStep, detailXYStep;
approxStep = detailXStep = detailYStep = detailXYStep = width/2*sizeof(Ipp32f);

//perform forward wavelet transform
ippiWTFwdInitAlloc_32f_C1R ( &pSpec, pTapsLow, lenLow, anchorLow, pTapsHigh, lenHigh, anchorHigh);
ippiWTFwdGetBufSize_C1R(pSpec, &bufSize);
pBuffer = ippsMalloc_8u(bufSize);
IppStatus forward = ippiWTFwd_32f_C1R (inputBuffer, srcStep, pApproxDst, approxStep, pDetailXDst,
detailXStep, pDetailYDst, detailYStep, pDetailXYDst, detailXYStep,
dstRoiSize, pSpec, pBuffer);
if(forward!=0)
qDebug() << "something failed in forward Xform";


//initialize inverse specs
ippiWTInvInitAlloc_32f_C1R (&pSpecInv, pTapsLow, lenLow, anchorLow, pTapsHigh, lenHigh, anchorHigh);
ippiWTInvGetBufSize_C1R(pSpecInv, &bufSizeInv);
pBufferInv = ippsMalloc_8u(bufSizeInv);

//perform inverse wavelet transform
ippiWTInv_32f_C1R( pApproxDst, approxStep, pDetailXDst, detailXStep, pDetailYDst, detailYStep, pDetailXYDst,
detailXYStep, roiInvSize, pDstInv, stepDstInv, pSpecInv, pBufferInv);
ippiWTInvFree_32f_C1R (pSpecInv);
ippiWTFwdFree_32f_C1R (pSpec);

return pDstInv;
}

[/cpp]

0 Kudos
6 Replies
Joshua_K_
Beginner
401 Views

I want to note that it only seems to crash when the image width > 1024.  I can run the code on images which are 8192x1024 etc., but if I try something like 2048x2048 or 1024x8192, it will get an invalid acess error in the inverse function.

0 Kudos
SergeyKostrov
Valued Contributor II
401 Views
Joshua, Thank you for the test case. Now, could you take a look how much memory is allocated on your platform just before the crash happens? ( look at the Task Manager if you're using Windows, or another memory viewing utility if on Non WIndows ). I would like to know Memory Usage ( physical ) and VM Size ( virtual ) numbers when the image size is greater than 2048 by 2048 ( 16MB ).
0 Kudos
Joshua_K_
Beginner
401 Views

It looks like the process uses ~70MB of memory when running on a 1024x1024 image, ~130MB when (crashing) to use a 2048x2048 image and ~300MB for a 8196x1024 image which does not crash.  I attached the task manager memory details for each scenario.  If there is a hidden buffer limit with the inverse WT function, then I may just split my large image  into smaller sections for processing.

0 Kudos
SergeyKostrov
Valued Contributor II
401 Views
>>... If there is a hidden buffer limit... There are two more memory related things: - Stack Reserve and Commit values ( look at Linker Settings ) - Virtual Memory Min and Max values ( look at System applet in Control Panel )
0 Kudos
Joshua_K_
Beginner
401 Views

For virtual memory Min and Max, I have Min as 16MB and Max as 6135MB.

I am unsure about the stack reserve/commit, but I am using qMake with QT Creator to do the linking and I believe the default stack size is set with /Zm200.

0 Kudos
SergeyKostrov
Valued Contributor II
401 Views
>>For virtual memory Min and Max, I have Min as 16MB and Max as 6135MB... Min value is too low. Could you try to set: Initial size (MB): 2048 ( that is 2GB ) Maximum size (MB): 8192 ( that is 8GB ) in System applet. >>...I am unsure about the stack reserve/commit, but I am using qMake with QT Creator to do the linking and >>I believe the default stack size is set with /Zm200. What C++ compiler ( or IDE ) do you use?
0 Kudos
Reply