Esempio n. 1
0
void CHistogram::AllocateVectors()
{
   FreeVectors();
   for (int i=0; i < m_numChannels; i++) {
      m_pLevels[i] = (Ipp32f*)ippMalloc(m_nLevels[i]*4);
      m_pHist[i]   = (Ipp32f*)ippMalloc(m_nLevels[i]*4);
   }
}
Esempio n. 2
0
int CIppImage::Alloc(IppiSize roi, int nchannels, int precision, int align)
{
  int size;
  int du      = (((precision & 255)+7)/8);
  int newStep = roi.width * nchannels * du;

  if(align)
    newStep += BYTES_PAD(roi.width, nchannels,du);

  if( isAllocated() && Height() == roi.height && Step() == newStep )
  {
    m_roi        = roi;
    m_nchannels  = nchannels;
    m_precision  = precision;
    m_step       = newStep;
    return 0;
  }

  Free();

  m_roi        = roi;
  m_nchannels  = nchannels;
  m_precision  = precision;
  m_step       = newStep;

  size = m_step * roi.height;
  m_imageData = (Ipp8u*)ippMalloc(size);
  m_allocated = m_imageData != 0;

  return m_imageData ? 0 : -1;
} // CIppImage::Alloc()
Esempio n. 3
0
static void createTmpVectors(Ipp32f** dst, Ipp32s** src, int* len, int num)
{
   for (int i=0; i<num; i++) {
      dst[i] = (Ipp32f*)ippMalloc(len[i]*4);
      ippsConvert_32s32f(src[i], dst[i], len[i]);
   }
}
Esempio n. 4
0
BOOL CRunCVFilterRow::BeforeCall()
{
   m_ppDst = (void**)ippMalloc(roiSize.height*sizeof(void*));
   Ipp8u* pLine = (Ipp8u*)pDst;
   int step = m_pDocDst->GetImage()->Step();
   for (int i=0; i<roiSize.height; i++) {
      m_ppDst[i] = pLine;
      pLine += step;
   }

   IppStatus status = CallGetBufSize(m_GetBufSizeName);
   IppErrorMessage(m_GetBufSizeName, status);
   if (status < 0) return FALSE;
   m_pBuffer = (Ipp8u*)ippMalloc(m_bufSize);
   if (!m_pBuffer) return FALSE;

   return TRUE;
}
Esempio n. 5
0
BOOL CRunCVFlood::BeforeCall()
{
   int bufferSize;
   IppStatus status = CV_CALL(ippiFloodFillGetSize,(roiSize, &bufferSize));
   IppErrorMessage("ippiFloodFillGetSize", status);
   if (status < 0) return FALSE;
   if (bufferSize) m_pBuffer = (Ipp8u*)ippMalloc(bufferSize);
   return TRUE;
}
Esempio n. 6
0
int CIppImage::ReduceBits16(Ipp8u* pDst, int dstStep, IppiSize roi) const
{
  IppStatus status;

  if(m_precision <= 8 || m_precision > 16)
    return -1;

  if(m_format == IF_UNSIGNED)
  {
    Ipp16u*   p1 = (Ipp16u*)m_imageData;
    Ipp16u*   pTmpRow = 0;
    Ipp16u    maxval[4];
    Ipp32u    val[4];
    Ipp8u*    dst = pDst;
    IppiSize  sz = {roi.width, 1};
    int       nBits;
    int       i;

    switch(m_nchannels)
    {
    case 1:
      status = ippiMax_16u_C1R(p1, m_step, roi, &maxval[0]); break;
    case 3:
      status = ippiMax_16u_C3R(p1, m_step, roi, maxval); break;
    case 4:
      status = ippiMax_16u_C4R(p1, m_step, roi, maxval); break;
    default:
      return -1;
    }

    if(ippStsNoErr != status)
      return -1;

    for(i = 0; i < m_nchannels; i++)
    {
      nBits = 0;

      while(maxval[i])
      {
        maxval[i] = maxval[i] >> 1;
        nBits++;
      }
      val[i] = 16 - nBits;
    }

    pTmpRow = (Ipp16u*)ippMalloc(m_step);
    if(0 == pTmpRow)
      return -1;

    for(i = 0; i < roi.height; i++)
    {
      switch(m_nchannels)
      {
      case 1:
        status = ippiLShiftC_16u_C1R(p1,m_step,val[0],pTmpRow,m_step,sz); break;
      case 3:
        status = ippiLShiftC_16u_C3R(p1,m_step,val,pTmpRow,m_step,sz); break;
      case 4:
        status = ippiLShiftC_16u_C4R(p1,m_step,val,pTmpRow,m_step,sz); break;
      default:
        ippFree(pTmpRow);
        return -1;
      }
      if(ippStsNoErr != status)
      {
        ippFree(pTmpRow);
        return -1;
      }

      switch(m_nchannels)
      {
      case 1:
        status = ippiReduceBits_16u8u_C1R(pTmpRow,m_step,dst,dstStep,sz,0,ippDitherNone,255); break;
      case 3:
        status = ippiReduceBits_16u8u_C3R(pTmpRow,m_step,dst,dstStep,sz,0,ippDitherNone,255); break;
      case 4:
        status = ippiReduceBits_16u8u_C4R(pTmpRow,m_step,dst,dstStep,sz,0,ippDitherNone,255); break;
      default:
        ippFree(pTmpRow);
        return -1;
      }
      if(ippStsNoErr != status)
      {
        ippFree(pTmpRow);
        return -1;
      }

      p1 = (Ipp16u*)((Ipp8u*)p1 + m_step);
      dst += dstStep;
    }
  }
Esempio n. 7
0
 T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; }
    // assign memory to descriptor
    Status Alloc(size_t s_Size, Ipp32s s_Alignment)
    {
        if(!CanReuse(s_Size, s_Alignment))
        {
            // can't reuse
            pMemory = ippMalloc((Ipp32s)s_Size+s_Alignment);
            if(pMemory == 0)
                return UMC_ERR_ALLOC;

            Size = s_Size+s_Alignment; // align to be done on Lock() call
        }
        Alignment       = s_Alignment;
        LocksCount      = 0;
        InvalidatedFlag = 0;

        return UMC_OK;
    }