Quantcast
Channel: Intel® Integrated Performance Primitives
Viewing all articles
Browse latest Browse all 1294

AccessViolation exception in using ippiHistogram_32f_C1R

$
0
0

Hi,

We are getting AccessViolationException in a call to ippiHistogram_32f_C1R every now and then, and it leads to a crash in our application. 

We're using Ipp 2019 Update 1, and here is the code (the line in bold leads to AccessViolationException). 

  • In HandleReturnValue, we check if the return value is different than 0, and if so we throw the proper exception.
  • img.Step is generated by a call to ippiMalloc_32f_C1. 

Could you point us to where the error might be?

public static uint[] Histogram(VMImage img, int band, float[] levels)
{
    short ippStatus = 0;
    int[] nLevels = { levels.Length };
    int sizeHistObj, sizeBuffer;
    IppiHistogramSpec* histSpec = null;
    byte* histBuffer = null;
    uint[] hist = new uint[levels.Length - 1];

    fixed (uint* pHist = &hist[0])
    {
        fixed (float* pLevels0 = &levels[0])
        {
            float*[] pLevels = { pLevels0 };
            fixed (float** ppLevels = &pLevels[0])
            {
                // Get sizes for spec and buffer
                ippStatus = ippiHistogramGetBufferSize(IppDataType.ipp32f, img.GetRoiSize(), nLevels, 1/*nChan*/, 0/*user step*/, &sizeHistObj, &sizeBuffer);
                HandleReturnValue(ippStatus);
                // Allocation of buffers
                histSpec = (IppiHistogramSpec*)ippsMalloc_8u(sizeHistObj);
                histBuffer = (byte*)ippsMalloc_8u(sizeBuffer);
                // Initialize spec
                ippStatus = ippiHistogramInit(IppDataType.ipp32f, ppLevels, nLevels, 1/*nChan*/, histSpec);
                HandleReturnValue(ippStatus);
                // Calculate histogram
                ippStatus = ippiHistogram_32f_C1R((float*)img.GetRoiPointer(band), img.Step, img.GetRoiSize(), pHist, histSpec, histBuffer);
                HandleReturnValue(ippStatus);
            }
        }
    }

    // CleanUp
    if (histSpec != null)
    {
        ippsFree(histSpec);
    }
    if (histBuffer != null)
    {
        ippsFree(histBuffer);
    }

    return hist;
}
 


Viewing all articles
Browse latest Browse all 1294

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>