Content-Length: 554640 | pFad | http://github.com/opencv/opencv/commit/c48dad1d9d92d1bd1b5ba12730feb4a637670371

C2 Merge pull request #27324 from eplankin:warp_hal_4x · opencv/opencv@c48dad1 · GitHub
Skip to content

Commit c48dad1

Browse files
eplankinvictorget
andauthored
Merge pull request #27324 from eplankin:warp_hal_4x
* Moved IPP impl of warpAffine to HAL Co-authored-by: victorget <victor.getmanskiy@intel.com>
1 parent d5f1a5d commit c48dad1

File tree

7 files changed

+470
-377
lines changed

7 files changed

+470
-377
lines changed

hal/ipp/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set(IPP_HAL_LIBRARIES "ipphal" CACHE INTERNAL "")
55
set(IPP_HAL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/include" CACHE INTERNAL "")
66
set(IPP_HAL_HEADERS
77
"${CMAKE_CURRENT_SOURCE_DIR}/include/ipp_hal_core.hpp"
8+
"${CMAKE_CURRENT_SOURCE_DIR}/include/ipp_hal_imgproc.hpp"
89
CACHE INTERNAL "")
910

1011
add_library(ipphal STATIC
@@ -13,6 +14,7 @@ add_library(ipphal STATIC
1314
"${CMAKE_CURRENT_SOURCE_DIR}/src/norm_ipp.cpp"
1415
"${CMAKE_CURRENT_SOURCE_DIR}/src/cart_polar_ipp.cpp"
1516
"${CMAKE_CURRENT_SOURCE_DIR}/src/transforms_ipp.cpp"
17+
"${CMAKE_CURRENT_SOURCE_DIR}/src/warp_ipp.cpp"
1618
"${CMAKE_CURRENT_SOURCE_DIR}/src/sum_ipp.cpp"
1719
)
1820

@@ -34,6 +36,7 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-suggest-override)
3436
target_include_directories(ipphal PRIVATE
3537
"${CMAKE_CURRENT_SOURCE_DIR}/src"
3638
${CMAKE_SOURCE_DIR}/modules/core/include
39+
${CMAKE_SOURCE_DIR}/modules/imgproc/include
3740
${IPP_INCLUDE_DIRS}
3841
)
3942

hal/ipp/include/ipp_hal_imgproc.hpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html
4+
5+
#ifndef __IPP_HAL_IMGPROC_HPP__
6+
#define __IPP_HAL_IMGPROC_HPP__
7+
8+
#include <opencv2/core/base.hpp>
9+
#include "ipp_utils.hpp"
10+
11+
#ifdef HAVE_IPP_IW
12+
13+
int ipp_hal_warpAffine(int src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width,
14+
int dst_height, const double M[6], int interpolation, int borderType, const double borderValue[4]);
15+
16+
#undef cv_hal_warpAffine
17+
#define cv_hal_warpAffine ipp_hal_warpAffine
18+
#endif
19+
20+
#if IPP_VERSION_X100 >= 810
21+
int ipp_hal_warpPerspective(int src_type, const uchar *src_data, size_t src_step, int src_width, int src_height, uchar *dst_data, size_t dst_step, int dst_width,
22+
int dst_height, const double M[9], int interpolation, int borderType, const double borderValue[4]);
23+
#undef cv_hal_warpPerspective
24+
#define cv_hal_warpPerspective ipp_hal_warpPerspective
25+
#endif
26+
27+
#endif //__IPP_HAL_IMGPROC_HPP__

hal/ipp/src/precomp_ipp.hpp

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// This file is part of OpenCV project.
2+
// It is subject to the license terms in the LICENSE file found in the top-level directory
3+
// of this distribution and at http://opencv.org/license.html
4+
5+
#ifndef __PRECOMP_IPP_HPP__
6+
#define __PRECOMP_IPP_HPP__
7+
8+
#include <opencv2/imgproc.hpp>
9+
10+
#ifdef HAVE_IPP_IW
11+
#include "iw++/iw.hpp"
12+
#endif
13+
14+
static inline IppDataType ippiGetDataType(int depth)
15+
{
16+
depth = CV_MAT_DEPTH(depth);
17+
return depth == CV_8U ? ipp8u :
18+
depth == CV_8S ? ipp8s :
19+
depth == CV_16U ? ipp16u :
20+
depth == CV_16S ? ipp16s :
21+
depth == CV_32S ? ipp32s :
22+
depth == CV_32F ? ipp32f :
23+
depth == CV_64F ? ipp64f :
24+
(IppDataType)-1;
25+
}
26+
27+
static inline IppiInterpolationType ippiGetInterpolation(int inter)
28+
{
29+
inter &= cv::InterpolationFlags::INTER_MAX;
30+
return inter == cv::InterpolationFlags::INTER_NEAREST ? ippNearest :
31+
inter == cv::InterpolationFlags::INTER_LINEAR ? ippLinear :
32+
inter == cv::InterpolationFlags::INTER_CUBIC ? ippCubic :
33+
inter == cv::InterpolationFlags::INTER_LANCZOS4 ? ippLanczos :
34+
inter == cv::InterpolationFlags::INTER_AREA ? ippSuper :
35+
(IppiInterpolationType)-1;
36+
}
37+
38+
static inline IppiBorderType ippiGetBorderType(int borderTypeNI)
39+
{
40+
return borderTypeNI == cv::BorderTypes::BORDER_CONSTANT ? ippBorderConst :
41+
borderTypeNI == cv::BorderTypes::BORDER_TRANSPARENT ? ippBorderTransp :
42+
borderTypeNI == cv::BorderTypes::BORDER_REPLICATE ? ippBorderRepl :
43+
(IppiBorderType)-1;
44+
}
45+
46+
static inline int ippiSuggestThreadsNum(size_t width, size_t height, size_t elemSize, double multiplier)
47+
{
48+
int threads = cv::getNumThreads();
49+
if(threads > 1 && height >= 64)
50+
{
51+
size_t opMemory = (int)(width*height*elemSize*multiplier);
52+
int l2cache = 0;
53+
#if IPP_VERSION_X100 >= 201700
54+
ippGetL2CacheSize(&l2cache);
55+
#endif
56+
if(!l2cache)
57+
l2cache = 1 << 18;
58+
59+
return IPP_MAX(1, (IPP_MIN((int)(opMemory/l2cache), threads)));
60+
}
61+
return 1;
62+
}
63+
64+
#ifdef HAVE_IPP_IW
65+
static inline int ippiSuggestThreadsNum(const ::ipp::IwiImage &image, double multiplier)
66+
{
67+
return ippiSuggestThreadsNum(image.m_size.width, image.m_size.height, image.m_typeSize*image.m_channels, multiplier);
68+
}
69+
#endif
70+
71+
#endif //__PRECOMP_IPP_HPP__

hal/ipp/src/transforms_ipp.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// of this distribution and at http://opencv.org/license.html
44

55
#include "ipp_hal_core.hpp"
6+
#include "precomp_ipp.hpp"
67

78
#include <opencv2/core.hpp>
89
#include <opencv2/core/base.hpp>
@@ -72,19 +73,6 @@ int ipp_hal_transpose2d(const uchar* src_data, size_t src_step, uchar* dst_data,
7273

7374
#ifdef HAVE_IPP_IW
7475

75-
static inline IppDataType ippiGetDataType(int depth)
76-
{
77-
depth = CV_MAT_DEPTH(depth);
78-
return depth == CV_8U ? ipp8u :
79-
depth == CV_8S ? ipp8s :
80-
depth == CV_16U ? ipp16u :
81-
depth == CV_16S ? ipp16s :
82-
depth == CV_32S ? ipp32s :
83-
depth == CV_32F ? ipp32f :
84-
depth == CV_64F ? ipp64f :
85-
(IppDataType)-1;
86-
}
87-
8876
static inline ::ipp::IwiImage ippiGetImage(int src_type, const uchar* src_data, size_t src_step, int src_width, int src_height)
8977
{
9078
::ipp::IwiImage dst;

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/opencv/opencv/commit/c48dad1d9d92d1bd1b5ba12730feb4a637670371

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy