123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- #ifndef OPENCV_CORE_IPPASYNC_HPP
- #define OPENCV_CORE_IPPASYNC_HPP
- #ifdef HAVE_IPP_A
- #include "opencv2/core.hpp"
- #include <ipp_async_op.h>
- #include <ipp_async_accel.h>
- namespace cv
- {
- namespace hpp
- {
-
- inline int toHppType(const int cvType)
- {
- int depth = CV_MAT_DEPTH(cvType);
- int hppType = depth == CV_8U ? HPP_DATA_TYPE_8U :
- depth == CV_16U ? HPP_DATA_TYPE_16U :
- depth == CV_16S ? HPP_DATA_TYPE_16S :
- depth == CV_32S ? HPP_DATA_TYPE_32S :
- depth == CV_32F ? HPP_DATA_TYPE_32F :
- depth == CV_64F ? HPP_DATA_TYPE_64F : -1;
- CV_Assert( hppType >= 0 );
- return hppType;
- }
-
- inline int toCvType(const int hppType)
- {
- int cvType = hppType == HPP_DATA_TYPE_8U ? CV_8U :
- hppType == HPP_DATA_TYPE_16U ? CV_16U :
- hppType == HPP_DATA_TYPE_16S ? CV_16S :
- hppType == HPP_DATA_TYPE_32S ? CV_32S :
- hppType == HPP_DATA_TYPE_32F ? CV_32F :
- hppType == HPP_DATA_TYPE_64F ? CV_64F : -1;
- CV_Assert( cvType >= 0 );
- return cvType;
- }
-
- inline void copyHppToMat(hppiMatrix* src, Mat& dst, hppAccel accel, int cn)
- {
- hppDataType type;
- hpp32u width, height;
- hppStatus sts;
- if (src == NULL)
- return dst.release();
- sts = hppiInquireMatrix(src, &type, &width, &height);
- CV_Assert( sts == HPP_STATUS_NO_ERROR);
- int matType = CV_MAKETYPE(toCvType(type), cn);
- CV_Assert(width%cn == 0);
- width /= cn;
- dst.create((int)height, (int)width, (int)matType);
- size_t newSize = (size_t)(height*(hpp32u)(dst.step));
- sts = hppiGetMatrixData(accel,src,(hpp32u)(dst.step),dst.data,&newSize);
- CV_Assert( sts == HPP_STATUS_NO_ERROR);
- }
-
- inline Mat getMat(hppiMatrix* src, hppAccel accel, int cn)
- {
- Mat dst;
- copyHppToMat(src, dst, accel, cn);
- return dst;
- }
-
- inline hppiMatrix* getHpp(const Mat& src, hppAccel accel)
- {
- int htype = toHppType(src.type());
- int cn = src.channels();
- CV_Assert(src.data);
- hppAccelType accelType = hppQueryAccelType(accel);
- if (accelType!=HPP_ACCEL_TYPE_CPU)
- {
- hpp32u pitch, size;
- hppQueryMatrixAllocParams(accel, src.cols*cn, src.rows, htype, &pitch, &size);
- if (pitch!=0 && size!=0)
- if ((int)(src.data)%4096==0 && pitch==(hpp32u)(src.step))
- {
- return hppiCreateSharedMatrix(htype, src.cols*cn, src.rows, src.data, pitch, size);
- }
- }
- return hppiCreateMatrix(htype, src.cols*cn, src.rows, src.data, (hpp32s)(src.step));;
- }
- }}
- #endif
- #endif
|