summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2018-09-07 10:19:00 -0700
committerKhem Raj <raj.khem@gmail.com>2018-09-09 10:46:29 -0700
commit7b9f86ca792852e69a921b284fffaa1f942df96d (patch)
tree302b9e96fb7c891f8b10ae97fe3dcbc4c527b94a
parent806c4d981d8703faa34b5f073c5f47f770e6ef19 (diff)
downloadmeta-openembedded-7b9f86ca792852e69a921b284fffaa1f942df96d.tar.gz
opencv: Update to 3.4.3
* Drop backported patches * Update versions of external submodules Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch26
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-build-workaround-GCC-7.1.1-compilation-issue-with-sa.patch127
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0001-carotene-don-t-use-__asm__-with-aarch64.patch1250
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0002-Do-not-enable-asm-with-clang.patch993
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0002-imgcodecs-refactoring-improve-code-quality.patch656
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch49
-rw-r--r--meta-oe/recipes-support/opencv/opencv/0003-imgproc-test-add-checks-for-remove-call.patch186
-rw-r--r--meta-oe/recipes-support/opencv/opencv/CVE-2017-14136.patch288
-rw-r--r--meta-oe/recipes-support/opencv/opencv/already-exists.patch394
-rw-r--r--meta-oe/recipes-support/opencv/opencv/fixpkgconfig.patch21
-rw-r--r--meta-oe/recipes-support/opencv/opencv/javagen.patch16
-rw-r--r--meta-oe/recipes-support/opencv/opencv/protobuf.patch57
-rw-r--r--meta-oe/recipes-support/opencv/opencv/tinydnn.patch34
-rw-r--r--meta-oe/recipes-support/opencv/opencv_3.4.3.bb (renamed from meta-oe/recipes-support/opencv/opencv_3.3.bb)39
14 files changed, 42 insertions, 4094 deletions
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch b/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
deleted file mode 100644
index 6dd48fcdc..000000000
--- a/meta-oe/recipes-support/opencv/opencv/0001-Dont-use-isystem.patch
+++ /dev/null
@@ -1,26 +0,0 @@
1From 2bc6bb9831d07f035fea74ea745cea43dd5f9ef9 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 9 Sep 2017 23:48:31 -0700
4Subject: [PATCH] Dont use isystem
5
6Signed-off-by: Khem Raj <raj.khem@gmail.com>
7---
8Upstream-Status: Pending
9
10 cmake/OpenCVPCHSupport.cmake | 10 ++++------
11 1 file changed, 4 insertions(+), 6 deletions(-)
12
13Index: git/cmake/OpenCVPCHSupport.cmake
14===================================================================
15--- git.orig/cmake/OpenCVPCHSupport.cmake
16+++ git/cmake/OpenCVPCHSupport.cmake
17@@ -17,7 +17,8 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
18 IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2.0")
19 SET(PCHSupport_FOUND TRUE)
20 ENDIF()
21-
22+ SET(CMAKE_INCLUDE_SYSTEM_FLAG_C "-I")
23+ SET(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-I")
24 SET(_PCH_include_prefix "-I")
25 SET(_PCH_isystem_prefix "-isystem")
26 SET(_PCH_define_prefix "-D")
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-build-workaround-GCC-7.1.1-compilation-issue-with-sa.patch b/meta-oe/recipes-support/opencv/opencv/0001-build-workaround-GCC-7.1.1-compilation-issue-with-sa.patch
deleted file mode 100644
index 0140633db..000000000
--- a/meta-oe/recipes-support/opencv/opencv/0001-build-workaround-GCC-7.1.1-compilation-issue-with-sa.patch
+++ /dev/null
@@ -1,127 +0,0 @@
1Upstream-Status: Backport [https://github.com/opencv/opencv/pull/9376/commits/0d854db361106dfcb055231fd0112c5b85ef2287]
2
3Fix CVEs for opencv 3.3.
4
5* CVE-2017-12597
6* CVE-2017-12598
7* CVE-2017-12599
8* CVE-2017-12600
9* CVE-2017-12601
10* CVE-2017-12602
11* CVE-2017-12603
12* CVE-2017-12604
13* CVE-2017-12605
14* CVE-2017-12606
15* CVE-2017-12862
16* CVE-2017-12863
17* CVE-2017-12864
18
19Signed-off-by: Kai Kang <kai.kang@windriver.com>
20---
21From 0d854db361106dfcb055231fd0112c5b85ef2287 Mon Sep 17 00:00:00 2001
22From: Alexander Alekhin <alexander.a.alekhin@gmail.com>
23Date: Tue, 15 Aug 2017 21:45:05 +0000
24Subject: [PATCH 1/3] build: workaround GCC 7.1.1 compilation issue with
25 sanitize flags
26
27Version: gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3)
28Flags: -fsanitize=address,undefined
29---
30 modules/ts/src/cuda_test.cpp | 56 ++++++++++++++++++++++++++------------------
31 1 file changed, 33 insertions(+), 23 deletions(-)
32
33diff --git a/modules/ts/src/cuda_test.cpp b/modules/ts/src/cuda_test.cpp
34index a48e0a087..eb4cee136 100644
35--- a/modules/ts/src/cuda_test.cpp
36+++ b/modules/ts/src/cuda_test.cpp
37@@ -322,16 +322,20 @@ namespace cvtest
38
39 if (m1.size() != m2.size())
40 {
41- return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
42- << expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
43- << expr2 << "\" [" << PrintToString(m2.size()) << "]";
44+ std::stringstream msg;
45+ msg << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different sizes : \""
46+ << expr1 << "\" [" << PrintToString(m1.size()) << "] vs \""
47+ << expr2 << "\" [" << PrintToString(m2.size()) << "]";
48+ return AssertionFailure() << msg.str();
49 }
50
51 if (m1.type() != m2.type())
52 {
53- return AssertionFailure() << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
54- << expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
55- << expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
56+ std::stringstream msg;
57+ msg << "Matrices \"" << expr1 << "\" and \"" << expr2 << "\" have different types : \""
58+ << expr1 << "\" [" << PrintToString(MatType(m1.type())) << "] vs \""
59+ << expr2 << "\" [" << PrintToString(MatType(m2.type())) << "]";
60+ return AssertionFailure() << msg.str();
61 }
62
63 Mat diff;
64@@ -343,12 +347,14 @@ namespace cvtest
65
66 if (maxVal > eps)
67 {
68- return AssertionFailure() << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
69- << "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
70- << ", which exceeds \"" << eps_expr << "\", where \""
71- << expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
72- << expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
73- << eps_expr << "\" evaluates to " << eps;
74+ std::stringstream msg;
75+ msg << "The max difference between matrices \"" << expr1 << "\" and \"" << expr2
76+ << "\" is " << maxVal << " at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ")"
77+ << ", which exceeds \"" << eps_expr << "\", where \""
78+ << expr1 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m1, maxLoc) << ", \""
79+ << expr2 << "\" at (" << maxLoc.y << ", " << maxLoc.x / m1.channels() << ") evaluates to " << printMatVal(m2, maxLoc) << ", \""
80+ << eps_expr << "\" evaluates to " << eps;
81+ return AssertionFailure() << msg.str();
82 }
83
84 return AssertionSuccess();
85@@ -469,9 +475,11 @@ namespace cvtest
86 {
87 if (gold.size() != actual.size())
88 {
89- return testing::AssertionFailure() << "KeyPoints size mistmach\n"
90- << "\"" << gold_expr << "\" : " << gold.size() << "\n"
91- << "\"" << actual_expr << "\" : " << actual.size();
92+ std::stringstream msg;
93+ msg << "KeyPoints size mistmach\n"
94+ << "\"" << gold_expr << "\" : " << gold.size() << "\n"
95+ << "\"" << actual_expr << "\" : " << actual.size();
96+ return AssertionFailure() << msg.str();
97 }
98
99 std::sort(actual.begin(), actual.end(), KeyPointLess());
100@@ -484,14 +492,16 @@ namespace cvtest
101
102 if (!keyPointsEquals(p1, p2))
103 {
104- return testing::AssertionFailure() << "KeyPoints differ at " << i << "\n"
105- << "\"" << gold_expr << "\" vs \"" << actual_expr << "\" : \n"
106- << "pt : " << testing::PrintToString(p1.pt) << " vs " << testing::PrintToString(p2.pt) << "\n"
107- << "size : " << p1.size << " vs " << p2.size << "\n"
108- << "angle : " << p1.angle << " vs " << p2.angle << "\n"
109- << "response : " << p1.response << " vs " << p2.response << "\n"
110- << "octave : " << p1.octave << " vs " << p2.octave << "\n"
111- << "class_id : " << p1.class_id << " vs " << p2.class_id;
112+ std::stringstream msg;
113+ msg << "KeyPoints differ at " << i << "\n"
114+ << "\"" << gold_expr << "\" vs \"" << actual_expr << "\" : \n"
115+ << "pt : " << testing::PrintToString(p1.pt) << " vs " << testing::PrintToString(p2.pt) << "\n"
116+ << "size : " << p1.size << " vs " << p2.size << "\n"
117+ << "angle : " << p1.angle << " vs " << p2.angle << "\n"
118+ << "response : " << p1.response << " vs " << p2.response << "\n"
119+ << "octave : " << p1.octave << " vs " << p2.octave << "\n"
120+ << "class_id : " << p1.class_id << " vs " << p2.class_id;
121+ return AssertionFailure() << msg.str();
122 }
123 }
124
125--
1262.14.1
127
diff --git a/meta-oe/recipes-support/opencv/opencv/0001-carotene-don-t-use-__asm__-with-aarch64.patch b/meta-oe/recipes-support/opencv/opencv/0001-carotene-don-t-use-__asm__-with-aarch64.patch
deleted file mode 100644
index a1a56e0e4..000000000
--- a/meta-oe/recipes-support/opencv/opencv/0001-carotene-don-t-use-__asm__-with-aarch64.patch
+++ /dev/null
@@ -1,1250 +0,0 @@
1From 353fc92618ce0dc6bab4a3e8bff1c13c3b613110 Mon Sep 17 00:00:00 2001
2From: Alexander Alekhin <alexander.alekhin@intel.com>
3Date: Wed, 23 Aug 2017 17:41:23 +0300
4Subject: [PATCH 1/2] carotene: don't use __asm__ with aarch64
5
6---
7Upstream-Status: Backport
8
9 3rdparty/carotene/src/channel_extract.cpp | 4 +-
10 3rdparty/carotene/src/channels_combine.cpp | 2 +-
11 3rdparty/carotene/src/colorconvert.cpp | 104 ++++++++++++++---------------
12 3rdparty/carotene/src/convert.cpp | 54 +++++++--------
13 3rdparty/carotene/src/convert_scale.cpp | 72 ++++++++++----------
14 3rdparty/carotene/src/gaussian_blur.cpp | 6 +-
15 3rdparty/carotene/src/pyramid.cpp | 20 +++---
16 3rdparty/carotene/src/scharr.cpp | 4 +-
17 8 files changed, 133 insertions(+), 133 deletions(-)
18
19diff --git a/3rdparty/carotene/src/channel_extract.cpp b/3rdparty/carotene/src/channel_extract.cpp
20index f663bc6005..8238a3ece8 100644
21--- a/3rdparty/carotene/src/channel_extract.cpp
22+++ b/3rdparty/carotene/src/channel_extract.cpp
23@@ -231,7 +231,7 @@ void extract4(const Size2D &size,
24 srcStride == dst2Stride && \
25 srcStride == dst3Stride &&
26
27-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
28+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
29
30 #define SPLIT_ASM2(sgn, bits) __asm__ ( \
31 "vld2." #bits " {d0, d2}, [%[in0]] \n\t" \
32@@ -351,7 +351,7 @@ void extract4(const Size2D &size,
33 } \
34 }
35
36-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
37+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
38
39 #define ALPHA_QUAD(sgn, bits) { \
40 internal::prefetch(src + sj); \
41diff --git a/3rdparty/carotene/src/channels_combine.cpp b/3rdparty/carotene/src/channels_combine.cpp
42index 157c8b8121..fc98fb9181 100644
43--- a/3rdparty/carotene/src/channels_combine.cpp
44+++ b/3rdparty/carotene/src/channels_combine.cpp
45@@ -77,7 +77,7 @@ namespace CAROTENE_NS {
46 dstStride == src2Stride && \
47 dstStride == src3Stride &&
48
49-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
50+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
51
52 #define MERGE_ASM2(sgn, bits) __asm__ ( \
53 "vld1." #bits " {d0-d1}, [%[in0]] \n\t" \
54diff --git a/3rdparty/carotene/src/colorconvert.cpp b/3rdparty/carotene/src/colorconvert.cpp
55index 3037fe672a..26ae54b15c 100644
56--- a/3rdparty/carotene/src/colorconvert.cpp
57+++ b/3rdparty/carotene/src/colorconvert.cpp
58@@ -97,7 +97,7 @@ void rgb2gray(const Size2D &size, COLOR_SPACE color_space,
59 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
60 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
61
62-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
63+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
64 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
65 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
66 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
67@@ -116,7 +116,7 @@ void rgb2gray(const Size2D &size, COLOR_SPACE color_space,
68 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
69 size_t sj = 0u, dj = 0u;
70
71-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
72+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
73 for (; dj < roiw8; sj += 24, dj += 8)
74 {
75 internal::prefetch(src + sj);
76@@ -198,7 +198,7 @@ void rgbx2gray(const Size2D &size, COLOR_SPACE color_space,
77 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
78 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
79
80-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
81+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
82 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
83 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
84 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
85@@ -217,7 +217,7 @@ void rgbx2gray(const Size2D &size, COLOR_SPACE color_space,
86 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
87 size_t sj = 0u, dj = 0u;
88
89-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
90+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
91 for (; dj < roiw8; sj += 32, dj += 8)
92 {
93 internal::prefetch(src + sj);
94@@ -300,7 +300,7 @@ void bgr2gray(const Size2D &size, COLOR_SPACE color_space,
95 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
96 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
97
98-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
99+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
100 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
101 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
102 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
103@@ -319,7 +319,7 @@ void bgr2gray(const Size2D &size, COLOR_SPACE color_space,
104 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
105 size_t sj = 0u, dj = 0u;
106
107-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
108+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
109 for (; dj < roiw8; sj += 24, dj += 8)
110 {
111 internal::prefetch(src + sj);
112@@ -402,7 +402,7 @@ void bgrx2gray(const Size2D &size, COLOR_SPACE color_space,
113 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
114 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
115
116-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
117+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
118 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
119 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
120 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
121@@ -421,7 +421,7 @@ void bgrx2gray(const Size2D &size, COLOR_SPACE color_space,
122 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
123 size_t sj = 0u, dj = 0u;
124
125-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
126+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
127 for (; dj < roiw8; sj += 32, dj += 8)
128 {
129 internal::prefetch(src + sj);
130@@ -512,7 +512,7 @@ void gray2rgb(const Size2D &size,
131 for (; sj < roiw16; sj += 16, dj += 48)
132 {
133 internal::prefetch(src + sj);
134-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
135+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
136 __asm__ (
137 "vld1.8 {d0-d1}, [%[in0]] \n\t"
138 "vmov.8 q1, q0 \n\t"
139@@ -538,7 +538,7 @@ void gray2rgb(const Size2D &size,
140
141 if (sj < roiw8)
142 {
143-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
144+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
145 __asm__ (
146 "vld1.8 {d0}, [%[in]] \n\t"
147 "vmov.8 d1, d0 \n\t"
148@@ -584,7 +584,7 @@ void gray2rgbx(const Size2D &size,
149 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
150 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
151
152-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
153+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
154 register uint8x16_t vc255 asm ("q4") = vmovq_n_u8(255);
155 #else
156 uint8x16x4_t vRgba;
157@@ -602,7 +602,7 @@ void gray2rgbx(const Size2D &size,
158 for (; sj < roiw16; sj += 16, dj += 64)
159 {
160 internal::prefetch(src + sj);
161-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
162+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
163 __asm__ (
164 "vld1.8 {d0-d1}, [%[in0]] \n\t"
165 "vmov.8 q1, q0 \n\t"
166@@ -628,7 +628,7 @@ void gray2rgbx(const Size2D &size,
167
168 if (sj < roiw8)
169 {
170-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
171+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
172 __asm__ (
173 "vld1.8 {d5}, [%[in]] \n\t"
174 "vmov.8 d6, d5 \n\t"
175@@ -672,7 +672,7 @@ void rgb2rgbx(const Size2D &size,
176 internal::assertSupportedConfiguration();
177 #ifdef CAROTENE_NEON
178 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
179-#if defined(__GNUC__) && defined(__arm__)
180+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
181 register uint8x8_t vc255_0 asm ("d3") = vmov_n_u8(255);
182 #else
183 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
184@@ -688,7 +688,7 @@ void rgb2rgbx(const Size2D &size,
185 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
186 size_t sj = 0u, dj = 0u, j = 0u;
187
188-#if defined(__GNUC__) && defined(__arm__)
189+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
190 for (; j < roiw8; sj += 24, dj += 32, j += 8)
191 {
192 internal::prefetch(src + sj);
193@@ -742,7 +742,7 @@ void rgbx2rgb(const Size2D &size,
194 internal::assertSupportedConfiguration();
195 #ifdef CAROTENE_NEON
196 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
197-#if !defined(__GNUC__) || !defined(__arm__)
198+#if !(!defined(__aarch64__) && defined(__GNUC__) && defined(__arm__))
199 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
200 union { uint8x16x4_t v4; uint8x16x3_t v3; } v_dst0;
201 union { uint8x8x4_t v4; uint8x8x3_t v3; } v_dst;
202@@ -754,7 +754,7 @@ void rgbx2rgb(const Size2D &size,
203 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
204 size_t sj = 0u, dj = 0u, j = 0u;
205
206-#if defined(__GNUC__) && defined(__arm__)
207+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
208 for (; j < roiw8; sj += 32, dj += 24, j += 8)
209 {
210 internal::prefetch(src + sj);
211@@ -805,7 +805,7 @@ void rgb2bgr(const Size2D &size,
212 {
213 internal::assertSupportedConfiguration();
214 #ifdef CAROTENE_NEON
215-#if !defined(__GNUC__) || !defined(__arm__)
216+#if !(!defined(__aarch64__) && defined(__GNUC__) && defined(__arm__))
217 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
218 #endif
219 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
220@@ -817,7 +817,7 @@ void rgb2bgr(const Size2D &size,
221 size_t sj = 0u, dj = 0u, j = 0u;
222
223
224-#if defined(__GNUC__) && defined(__arm__)
225+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
226 for (; j < roiw8; sj += 24, dj += 24, j += 8)
227 {
228 internal::prefetch(src + sj);
229@@ -874,7 +874,7 @@ void rgbx2bgrx(const Size2D &size,
230 {
231 internal::assertSupportedConfiguration();
232 #ifdef CAROTENE_NEON
233-#if !defined(__GNUC__) || !defined(__arm__)
234+#if !(!defined(__aarch64__) && defined(__GNUC__) && defined(__arm__))
235 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
236 #endif
237 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
238@@ -885,7 +885,7 @@ void rgbx2bgrx(const Size2D &size,
239 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
240 size_t sj = 0u, dj = 0u, j = 0u;
241
242-#if defined(__GNUC__) && defined(__arm__)
243+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
244 for (; j < roiw8; sj += 32, dj += 32, j += 8)
245 {
246 internal::prefetch(src + sj);
247@@ -943,7 +943,7 @@ void rgbx2bgr(const Size2D &size,
248 {
249 internal::assertSupportedConfiguration();
250 #ifdef CAROTENE_NEON
251-#if !defined(__GNUC__) || !defined(__arm__)
252+#if !(!defined(__aarch64__) && defined(__GNUC__) && defined(__arm__))
253 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
254 #endif
255 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
256@@ -954,7 +954,7 @@ void rgbx2bgr(const Size2D &size,
257 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
258 size_t sj = 0u, dj = 0u, j = 0u;
259
260-#if defined(__GNUC__) && defined(__arm__)
261+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
262 for (; j < roiw8; sj += 32, dj += 24, j += 8)
263 {
264 internal::prefetch(src + sj);
265@@ -1010,7 +1010,7 @@ void rgb2bgrx(const Size2D &size,
266 {
267 internal::assertSupportedConfiguration();
268 #ifdef CAROTENE_NEON
269-#if defined(__GNUC__) && defined(__arm__)
270+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
271 register uint8x8_t vc255 asm ("d3") = vmov_n_u8(255);
272 #else
273 union { uint8x16x4_t v4; uint8x16x3_t v3; } vals0;
274@@ -1019,7 +1019,7 @@ void rgb2bgrx(const Size2D &size,
275 vals8.v4.val[3] = vmov_n_u8(255);
276 #endif
277
278-#if !defined(__GNUC__) || !defined(__arm__)
279+#if !(!defined(__aarch64__) && defined(__GNUC__) && defined(__arm__))
280 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
281 #endif
282 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
283@@ -1030,7 +1030,7 @@ void rgb2bgrx(const Size2D &size,
284 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
285 size_t sj = 0u, dj = 0u, j = 0u;
286
287-#if defined(__GNUC__) && defined(__arm__)
288+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
289 for (; j < roiw8; sj += 24, dj += 32, j += 8)
290 {
291 internal::prefetch(src + sj);
292@@ -1409,7 +1409,7 @@ inline void convertToHSV(const s32 r, const s32 g, const s32 b,
293 "d24","d25","d26","d27","d28","d29","d30","d31" \
294 );
295
296-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
297+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
298
299 #define YCRCB_CONSTS \
300 register int16x4_t vcYR asm ("d31") = vmov_n_s16(4899); \
301@@ -1555,7 +1555,7 @@ inline uint8x8x3_t convertToYCrCb( const int16x8_t& vR, const int16x8_t& vG, con
302 #define COEFF_G ( 8663)
303 #define COEFF_B (-17705)
304
305-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
306+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
307 #define YUV420ALPHA3_CONST
308 #define YUV420ALPHA4_CONST register uint8x16_t c255 asm ("q13") = vmovq_n_u8(255);
309 #define YUV420ALPHA3_CONVERT
310@@ -1852,7 +1852,7 @@ void rgb2hsv(const Size2D &size,
311 #ifdef CAROTENE_NEON
312 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
313 const s32 hsv_shift = 12;
314-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
315+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
316 register const f32 vsdiv_table = f32(255 << hsv_shift);
317 register f32 vhdiv_table = f32(hrange << hsv_shift);
318 register const s32 vhrange = hrange;
319@@ -1871,7 +1871,7 @@ void rgb2hsv(const Size2D &size,
320 for (; j < roiw8; sj += 24, dj += 24, j += 8)
321 {
322 internal::prefetch(src + sj);
323-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
324+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
325 CONVERT_TO_HSV_ASM(vld3.8 {d0-d2}, d0, d2)
326 #else
327 uint8x8x3_t vRgb = vld3_u8(src + sj);
328@@ -1904,7 +1904,7 @@ void rgbx2hsv(const Size2D &size,
329 #ifdef CAROTENE_NEON
330 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
331 const s32 hsv_shift = 12;
332-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
333+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
334 register const f32 vsdiv_table = f32(255 << hsv_shift);
335 register f32 vhdiv_table = f32(hrange << hsv_shift);
336 register const s32 vhrange = hrange;
337@@ -1923,7 +1923,7 @@ void rgbx2hsv(const Size2D &size,
338 for (; j < roiw8; sj += 32, dj += 24, j += 8)
339 {
340 internal::prefetch(src + sj);
341-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
342+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
343 CONVERT_TO_HSV_ASM(vld4.8 {d0-d3}, d0, d2)
344 #else
345 uint8x8x4_t vRgb = vld4_u8(src + sj);
346@@ -1956,7 +1956,7 @@ void bgr2hsv(const Size2D &size,
347 #ifdef CAROTENE_NEON
348 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
349 const s32 hsv_shift = 12;
350-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
351+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
352 register const f32 vsdiv_table = f32(255 << hsv_shift);
353 register f32 vhdiv_table = f32(hrange << hsv_shift);
354 register const s32 vhrange = hrange;
355@@ -1975,7 +1975,7 @@ void bgr2hsv(const Size2D &size,
356 for (; j < roiw8; sj += 24, dj += 24, j += 8)
357 {
358 internal::prefetch(src + sj);
359-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
360+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
361 CONVERT_TO_HSV_ASM(vld3.8 {d0-d2}, d2, d0)
362 #else
363 uint8x8x3_t vRgb = vld3_u8(src + sj);
364@@ -2008,7 +2008,7 @@ void bgrx2hsv(const Size2D &size,
365 #ifdef CAROTENE_NEON
366 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
367 const s32 hsv_shift = 12;
368-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
369+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
370 register const f32 vsdiv_table = f32(255 << hsv_shift);
371 register f32 vhdiv_table = f32(hrange << hsv_shift);
372 register const s32 vhrange = hrange;
373@@ -2027,7 +2027,7 @@ void bgrx2hsv(const Size2D &size,
374 for (; j < roiw8; sj += 32, dj += 24, j += 8)
375 {
376 internal::prefetch(src + sj);
377-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
378+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
379 CONVERT_TO_HSV_ASM(vld4.8 {d0-d3}, d2, d0)
380 #else
381 uint8x8x4_t vRgb = vld4_u8(src + sj);
382@@ -2068,7 +2068,7 @@ void rgbx2bgr565(const Size2D &size,
383 for (; j < roiw16; sj += 64, dj += 32, j += 16)
384 {
385 internal::prefetch(src + sj);
386-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
387+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
388 __asm__ (
389 "vld4.8 {d2, d4, d6, d8}, [%[in0]] @ q0 q1 q2 q3 q4 \n\t"
390 "vld4.8 {d3, d5, d7, d9}, [%[in1]] @ xxxxxxxx rrrrRRRR ggggGGGG bbbbBBBB xxxxxxxx \n\t"
391@@ -2122,7 +2122,7 @@ void rgb2bgr565(const Size2D &size,
392 for (; j < roiw16; sj += 48, dj += 32, j += 16)
393 {
394 internal::prefetch(src + sj);
395-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
396+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
397 __asm__ (
398 "vld3.8 {d2, d4, d6}, [%[in0]] @ q0 q1 q2 q3 q4 \n\t"
399 "vld3.8 {d3, d5, d7}, [%[in1]] @ xxxxxxxx rrrrRRRR ggggGGGG bbbbBBBB xxxxxxxx \n\t"
400@@ -2176,7 +2176,7 @@ void rgbx2rgb565(const Size2D &size,
401 for (; j < roiw16; sj += 64, dj += 32, j += 16)
402 {
403 internal::prefetch(src + sj);
404-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
405+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
406 __asm__ (
407 "vld4.8 {d0, d2, d4, d6}, [%[in0]] @ q0 q1 q2 q3 \n\t"
408 "vld4.8 {d1, d3, d5, d7}, [%[in1]] @ rrrrRRRR ggggGGGG bbbbBBBB aaaaAAAA \n\t"
409@@ -2230,7 +2230,7 @@ void rgb2rgb565(const Size2D &size,
410 for (; j < roiw16; sj += 48, dj += 32, j += 16)
411 {
412 internal::prefetch(src + sj);
413-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
414+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
415 __asm__ (
416 "vld3.8 {d0, d2, d4}, [%[in0]] @ q0 q1 q2 q3 \n\t"
417 "vld3.8 {d1, d3, d5}, [%[in1]] @ rrrrRRRR ggggGGGG bbbbBBBB xxxxxxxx \n\t"
418@@ -2285,7 +2285,7 @@ void rgb2ycrcb(const Size2D &size,
419 for (; j < roiw8; sj += 24, dj += 24, j += 8)
420 {
421 internal::prefetch(src + sj);
422-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
423+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
424 CONVERTTOYCRCB(vld3.8 {d0-d2}, d0, d1, d2)
425 #else
426 uint8x8x3_t vRgb = vld3_u8(src + sj);
427@@ -2329,7 +2329,7 @@ void rgbx2ycrcb(const Size2D &size,
428 for (; j < roiw8; sj += 32, dj += 24, j += 8)
429 {
430 internal::prefetch(src + sj);
431-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
432+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
433 CONVERTTOYCRCB(vld4.8 {d0-d3}, d0, d1, d2)
434 #else
435 uint8x8x4_t vRgba = vld4_u8(src + sj);
436@@ -2373,7 +2373,7 @@ void bgr2ycrcb(const Size2D &size,
437 for (; j < roiw8; sj += 24, dj += 24, j += 8)
438 {
439 internal::prefetch(src + sj);
440-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
441+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
442 CONVERTTOYCRCB(vld3.8 {d0-d2}, d2, d1, d0)
443 #else
444 uint8x8x3_t vBgr = vld3_u8(src + sj);
445@@ -2417,7 +2417,7 @@ void bgrx2ycrcb(const Size2D &size,
446 for (; j < roiw8; sj += 32, dj += 24, j += 8)
447 {
448 internal::prefetch(src + sj);
449-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
450+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
451 CONVERTTOYCRCB(vld4.8 {d0-d3}, d2, d1, d0)
452 #else
453 uint8x8x4_t vBgra = vld4_u8(src + sj);
454@@ -2499,7 +2499,7 @@ void yuv420sp2rgb(const Size2D &size,
455 internal::prefetch(uv + j);
456 internal::prefetch(y1 + j);
457 internal::prefetch(y2 + j);
458-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
459+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
460 CONVERTYUV420TORGB(3, d1, d0, q5, q6)
461 #else
462 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
463@@ -2545,7 +2545,7 @@ void yuv420sp2rgbx(const Size2D &size,
464 internal::prefetch(uv + j);
465 internal::prefetch(y1 + j);
466 internal::prefetch(y2 + j);
467-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
468+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
469 CONVERTYUV420TORGB(4, d1, d0, q5, q6)
470 #else
471 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
472@@ -2591,7 +2591,7 @@ void yuv420i2rgb(const Size2D &size,
473 internal::prefetch(uv + j);
474 internal::prefetch(y1 + j);
475 internal::prefetch(y2 + j);
476-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
477+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
478 CONVERTYUV420TORGB(3, d0, d1, q5, q6)
479 #else
480 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
481@@ -2637,7 +2637,7 @@ void yuv420i2rgbx(const Size2D &size,
482 internal::prefetch(uv + j);
483 internal::prefetch(y1 + j);
484 internal::prefetch(y2 + j);
485-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
486+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
487 CONVERTYUV420TORGB(4, d0, d1, q5, q6)
488 #else
489 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
490@@ -2683,7 +2683,7 @@ void yuv420sp2bgr(const Size2D &size,
491 internal::prefetch(uv + j);
492 internal::prefetch(y1 + j);
493 internal::prefetch(y2 + j);
494-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
495+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
496 CONVERTYUV420TORGB(3, d1, d0, q6, q5)
497 #else
498 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
499@@ -2729,7 +2729,7 @@ void yuv420sp2bgrx(const Size2D &size,
500 internal::prefetch(uv + j);
501 internal::prefetch(y1 + j);
502 internal::prefetch(y2 + j);
503-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
504+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
505 CONVERTYUV420TORGB(4, d1, d0, q6, q5)
506 #else
507 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
508@@ -2775,7 +2775,7 @@ void yuv420i2bgr(const Size2D &size,
509 internal::prefetch(uv + j);
510 internal::prefetch(y1 + j);
511 internal::prefetch(y2 + j);
512-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
513+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
514 CONVERTYUV420TORGB(3, d0, d1, q6, q5)
515 #else
516 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
517@@ -2821,7 +2821,7 @@ void yuv420i2bgrx(const Size2D &size,
518 internal::prefetch(uv + j);
519 internal::prefetch(y1 + j);
520 internal::prefetch(y2 + j);
521-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
522+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
523 CONVERTYUV420TORGB(4, d0, d1, q6, q5)
524 #else
525 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
526diff --git a/3rdparty/carotene/src/convert.cpp b/3rdparty/carotene/src/convert.cpp
527index 403f16d86a..64b6db78ab 100644
528--- a/3rdparty/carotene/src/convert.cpp
529+++ b/3rdparty/carotene/src/convert.cpp
530@@ -101,7 +101,7 @@ CVT_FUNC(u8, s8, 16,
531 }
532 })
533
534-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
535+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
536 CVT_FUNC(u8, u16, 16,
537 register uint8x16_t zero0 asm ("q1") = vmovq_n_u8(0);,
538 {
539@@ -135,7 +135,7 @@ CVT_FUNC(u8, u16, 16,
540 })
541 #endif
542
543-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
544+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
545 CVT_FUNC(u8, s32, 16,
546 register uint8x16_t zero0 asm ("q1") = vmovq_n_u8(0);
547 register uint8x16_t zero1 asm ("q2") = vmovq_n_u8(0);
548@@ -173,7 +173,7 @@ CVT_FUNC(u8, s32, 16,
549 })
550 #endif
551
552-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
553+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
554 CVT_FUNC(u8, f32, 16,
555 ,
556 {
557@@ -248,7 +248,7 @@ CVT_FUNC(s8, u8, 16,
558 }
559 })
560
561-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
562+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
563 CVT_FUNC(s8, u16, 16,
564 register uint8x16_t zero0 asm ("q1") = vmovq_n_u8(0);,
565 {
566@@ -284,7 +284,7 @@ CVT_FUNC(s8, u16, 16,
567 })
568 #endif
569
570-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
571+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
572 CVT_FUNC(s8, s16, 16,
573 ,
574 {
575@@ -323,7 +323,7 @@ CVT_FUNC(s8, s16, 16,
576 })
577 #endif
578
579-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
580+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
581 CVT_FUNC(s8, s32, 16,
582 ,
583 {
584@@ -377,7 +377,7 @@ CVT_FUNC(s8, s32, 16,
585 })
586 #endif
587
588-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
589+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
590 CVT_FUNC(s8, f32, 16,
591 ,
592 {
593@@ -440,7 +440,7 @@ CVT_FUNC(s8, f32, 16,
594 })
595 #endif
596
597-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
598+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
599 CVT_FUNC(u16, u8, 16,
600 ,
601 {
602@@ -479,7 +479,7 @@ CVT_FUNC(u16, u8, 16,
603 })
604 #endif
605
606-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
607+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
608 CVT_FUNC(u16, s8, 16,
609 register uint8x16_t v127 asm ("q4") = vmovq_n_u8(127);,
610 {
611@@ -522,7 +522,7 @@ CVT_FUNC(u16, s8, 16,
612 })
613 #endif
614
615-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
616+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
617 CVT_FUNC(u16, s16, 8,
618 register uint16x8_t v32767 asm ("q4") = vmovq_n_u16(0x7FFF);,
619 {
620@@ -555,7 +555,7 @@ CVT_FUNC(u16, s16, 8,
621 })
622 #endif
623
624-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
625+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
626 CVT_FUNC(u16, s32, 8,
627 register uint16x8_t zero0 asm ("q1") = vmovq_n_u16(0);,
628 {
629@@ -589,7 +589,7 @@ CVT_FUNC(u16, s32, 8,
630 })
631 #endif
632
633-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
634+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
635 CVT_FUNC(u16, f32, 8,
636 ,
637 {
638@@ -633,7 +633,7 @@ CVT_FUNC(u16, f32, 8,
639 })
640 #endif
641
642-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
643+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
644 CVT_FUNC(s16, u8, 16,
645 ,
646 {
647@@ -672,7 +672,7 @@ CVT_FUNC(s16, u8, 16,
648 })
649 #endif
650
651-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
652+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
653 CVT_FUNC(s16, s8, 16,
654 ,
655 {
656@@ -711,7 +711,7 @@ CVT_FUNC(s16, s8, 16,
657 })
658 #endif
659
660-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
661+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
662 CVT_FUNC(s16, u16, 8,
663 register int16x8_t vZero asm ("q4") = vmovq_n_s16(0);,
664 {
665@@ -747,7 +747,7 @@ CVT_FUNC(s16, u16, 8,
666 })
667 #endif
668
669-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
670+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
671 CVT_FUNC(s16, s32, 8,
672 ,
673 {
674@@ -786,7 +786,7 @@ CVT_FUNC(s16, s32, 8,
675 })
676 #endif
677
678-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
679+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
680 CVT_FUNC(s16, f32, 8,
681 ,
682 {
683@@ -829,7 +829,7 @@ CVT_FUNC(s16, f32, 8,
684 })
685 #endif
686
687-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
688+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
689 CVT_FUNC(s32, u8, 8,
690 ,
691 {
692@@ -870,7 +870,7 @@ CVT_FUNC(s32, u8, 8,
693 })
694 #endif
695
696-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
697+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
698 CVT_FUNC(s32, s8, 8,
699 ,
700 {
701@@ -911,7 +911,7 @@ CVT_FUNC(s32, s8, 8,
702 })
703 #endif
704
705-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
706+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
707 CVT_FUNC(s32, u16, 8,
708 ,
709 {
710@@ -950,7 +950,7 @@ CVT_FUNC(s32, u16, 8,
711 })
712 #endif
713
714-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
715+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
716 CVT_FUNC(s32, s16, 8,
717 ,
718 {
719@@ -989,7 +989,7 @@ CVT_FUNC(s32, s16, 8,
720 })
721 #endif
722
723-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
724+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
725 CVT_FUNC(s32, f32, 8,
726 ,
727 {
728@@ -1034,7 +1034,7 @@ CVT_FUNC(s32, f32, 8,
729 })
730 #endif
731
732-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
733+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
734 CVT_FUNC(f32, u8, 8,
735 register float32x4_t vmult asm ("q0") = vdupq_n_f32((float)(1 << 16));
736 register uint32x4_t vmask asm ("q1") = vdupq_n_u32(1<<16);,
737@@ -1101,7 +1101,7 @@ CVT_FUNC(f32, u8, 8,
738 })
739 #endif
740
741-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
742+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
743 CVT_FUNC(f32, s8, 8,
744 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
745 {
746@@ -1153,7 +1153,7 @@ CVT_FUNC(f32, s8, 8,
747 })
748 #endif
749
750-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
751+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
752 CVT_FUNC(f32, u16, 8,
753 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
754 {
755@@ -1212,7 +1212,7 @@ CVT_FUNC(f32, u16, 8,
756 })
757 #endif
758
759-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
760+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
761 CVT_FUNC(f32, s16, 8,
762 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
763 {
764@@ -1271,7 +1271,7 @@ CVT_FUNC(f32, s16, 8,
765 })
766 #endif
767
768-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
769+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
770 CVT_FUNC(f32, s32, 8,
771 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
772 {
773diff --git a/3rdparty/carotene/src/convert_scale.cpp b/3rdparty/carotene/src/convert_scale.cpp
774index 0a14a8035c..ae41a985c8 100644
775--- a/3rdparty/carotene/src/convert_scale.cpp
776+++ b/3rdparty/carotene/src/convert_scale.cpp
777@@ -135,7 +135,7 @@ namespace CAROTENE_NS {
778
779 #endif
780
781-#if defined(__GNUC__) && defined(__arm__)
782+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
783 CVTS_FUNC1(u8, 16,
784 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
785 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
786@@ -220,7 +220,7 @@ CVTS_FUNC1(u8, 16,
787 })
788 #endif
789
790-#if defined(__GNUC__) && defined(__arm__)
791+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
792 CVTS_FUNC(u8, s8, 16,
793 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
794 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
795@@ -305,7 +305,7 @@ CVTS_FUNC(u8, s8, 16,
796 })
797 #endif
798
799-#if defined(__GNUC__) && defined(__arm__)
800+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
801 CVTS_FUNC(u8, u16, 16,
802 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
803 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
804@@ -389,7 +389,7 @@ CVTS_FUNC(u8, u16, 16,
805 })
806 #endif
807
808-#if defined(__GNUC__) && defined(__arm__)
809+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
810 CVTS_FUNC(u8, s16, 16,
811 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
812 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
813@@ -473,7 +473,7 @@ CVTS_FUNC(u8, s16, 16,
814 })
815 #endif
816
817-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
818+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
819 CVTS_FUNC(u8, s32, 16,
820 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
821 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
822@@ -562,7 +562,7 @@ CVTS_FUNC(u8, s32, 16,
823 })
824 #endif
825
826-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
827+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
828 CVTS_FUNC(u8, f32, 16,
829 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
830 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
831@@ -643,7 +643,7 @@ CVTS_FUNC(u8, f32, 16,
832 })
833 #endif
834
835-#if defined(__GNUC__) && defined(__arm__)
836+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
837 CVTS_FUNC(s8, u8, 16,
838 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
839 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
840@@ -728,7 +728,7 @@ CVTS_FUNC(s8, u8, 16,
841 })
842 #endif
843
844-#if defined(__GNUC__) && defined(__arm__)
845+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
846 CVTS_FUNC1(s8, 16,
847 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
848 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
849@@ -813,7 +813,7 @@ CVTS_FUNC1(s8, 16,
850 })
851 #endif
852
853-#if defined(__GNUC__) && defined(__arm__)
854+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
855 CVTS_FUNC(s8, u16, 16,
856 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
857 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
858@@ -899,7 +899,7 @@ CVTS_FUNC(s8, u16, 16,
859 })
860 #endif
861
862-#if defined(__GNUC__) && defined(__arm__)
863+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
864 CVTS_FUNC(s8, s16, 16,
865 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
866 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
867@@ -985,7 +985,7 @@ CVTS_FUNC(s8, s16, 16,
868 })
869 #endif
870
871-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
872+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
873 CVTS_FUNC(s8, s32, 16,
874 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
875 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
876@@ -1074,7 +1074,7 @@ CVTS_FUNC(s8, s32, 16,
877 })
878 #endif
879
880-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
881+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
882 CVTS_FUNC(s8, f32, 16,
883 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
884 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
885@@ -1155,7 +1155,7 @@ CVTS_FUNC(s8, f32, 16,
886 })
887 #endif
888
889-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
890+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
891 CVTS_FUNC(u16, u8, 16,
892 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
893 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
894@@ -1214,7 +1214,7 @@ CVTS_FUNC(u16, u8, 16,
895 })
896 #endif
897
898-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
899+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
900 CVTS_FUNC(u16, s8, 16,
901 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
902 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
903@@ -1273,7 +1273,7 @@ CVTS_FUNC(u16, s8, 16,
904 })
905 #endif
906
907-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
908+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
909 CVTS_FUNC1(u16, 16,
910 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
911 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
912@@ -1330,7 +1330,7 @@ CVTS_FUNC1(u16, 16,
913 })
914 #endif
915
916-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
917+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
918 CVTS_FUNC(u16, s16, 8,
919 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
920 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
921@@ -1387,7 +1387,7 @@ CVTS_FUNC(u16, s16, 8,
922 })
923 #endif
924
925-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
926+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
927 CVTS_FUNC(u16, s32, 8,
928 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
929 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
930@@ -1443,7 +1443,7 @@ CVTS_FUNC(u16, s32, 8,
931 })
932 #endif
933
934-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
935+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
936 CVTS_FUNC(u16, f32, 8,
937 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
938 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
939@@ -1495,7 +1495,7 @@ CVTS_FUNC(u16, f32, 8,
940 })
941 #endif
942
943-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
944+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
945 CVTS_FUNC(s16, u8, 16,
946 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
947 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
948@@ -1554,7 +1554,7 @@ CVTS_FUNC(s16, u8, 16,
949 })
950 #endif
951
952-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
953+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
954 CVTS_FUNC(s16, s8, 16,
955 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
956 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
957@@ -1613,7 +1613,7 @@ CVTS_FUNC(s16, s8, 16,
958 })
959 #endif
960
961-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
962+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
963 CVTS_FUNC(s16, u16, 8,
964 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
965 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
966@@ -1670,7 +1670,7 @@ CVTS_FUNC(s16, u16, 8,
967 })
968 #endif
969
970-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
971+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
972 CVTS_FUNC1(s16, 16,
973 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
974 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
975@@ -1727,7 +1727,7 @@ CVTS_FUNC1(s16, 16,
976 })
977 #endif
978
979-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
980+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
981 CVTS_FUNC(s16, s32, 8,
982 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
983 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
984@@ -1783,7 +1783,7 @@ CVTS_FUNC(s16, s32, 8,
985 })
986 #endif
987
988-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
989+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
990 CVTS_FUNC(s16, f32, 8,
991 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
992 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
993@@ -1835,7 +1835,7 @@ CVTS_FUNC(s16, f32, 8,
994 })
995 #endif
996
997-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
998+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
999 CVTS_FUNC(s32, u8, 8,
1000 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1001 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1002@@ -1893,7 +1893,7 @@ CVTS_FUNC(s32, u8, 8,
1003 })
1004 #endif
1005
1006-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1007+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1008 CVTS_FUNC(s32, s8, 8,
1009 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1010 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1011@@ -1951,7 +1951,7 @@ CVTS_FUNC(s32, s8, 8,
1012 })
1013 #endif
1014
1015-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1016+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1017 CVTS_FUNC(s32, u16, 8,
1018 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1019 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1020@@ -2007,7 +2007,7 @@ CVTS_FUNC(s32, u16, 8,
1021 })
1022 #endif
1023
1024-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1025+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1026 CVTS_FUNC(s32, s16, 8,
1027 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1028 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1029@@ -2063,7 +2063,7 @@ CVTS_FUNC(s32, s16, 8,
1030 })
1031 #endif
1032
1033-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1034+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1035 CVTS_FUNC1(s32, 8,
1036 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1037 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1038@@ -2118,7 +2118,7 @@ CVTS_FUNC1(s32, 8,
1039 })
1040 #endif
1041
1042-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1043+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1044 CVTS_FUNC(s32, f32, 8,
1045 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1046 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
1047@@ -2169,7 +2169,7 @@ CVTS_FUNC(s32, f32, 8,
1048 })
1049 #endif
1050
1051-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1052+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1053 CVTS_FUNC(f32, u8, 8,
1054 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)((1 << 16)*alpha));
1055 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)((1 << 16)*beta));
1056@@ -2239,7 +2239,7 @@ CVTS_FUNC(f32, u8, 8,
1057 })
1058 #endif
1059
1060-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1061+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1062 CVTS_FUNC(f32, s8, 8,
1063 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1064 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1065@@ -2293,7 +2293,7 @@ CVTS_FUNC(f32, s8, 8,
1066 })
1067 #endif
1068
1069-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1070+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1071 CVTS_FUNC(f32, u16, 8,
1072 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1073 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1074@@ -2345,7 +2345,7 @@ CVTS_FUNC(f32, u16, 8,
1075 })
1076 #endif
1077
1078-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1079+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1080 CVTS_FUNC(f32, s16, 8,
1081 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1082 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1083@@ -2397,7 +2397,7 @@ CVTS_FUNC(f32, s16, 8,
1084 })
1085 #endif
1086
1087-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1088+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1089 CVTS_FUNC(f32, s32, 8,
1090 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1091 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
1092@@ -2448,7 +2448,7 @@ CVTS_FUNC(f32, s32, 8,
1093 })
1094 #endif
1095
1096-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1097+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1098 CVTS_FUNC1(f32, 8,
1099 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
1100 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
1101diff --git a/3rdparty/carotene/src/gaussian_blur.cpp b/3rdparty/carotene/src/gaussian_blur.cpp
1102index 1b5399436f..f7b5f18d79 100644
1103--- a/3rdparty/carotene/src/gaussian_blur.cpp
1104+++ b/3rdparty/carotene/src/gaussian_blur.cpp
1105@@ -327,7 +327,7 @@ void gaussianBlur5x5(const Size2D &size, s32 cn,
1106 u16* lidx1 = lane + x - 1*2;
1107 u16* lidx3 = lane + x + 1*2;
1108 u16* lidx4 = lane + x + 2*2;
1109-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1110+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1111 __asm__ __volatile__ (
1112 "vld2.16 {d0, d2}, [%[in0]]! \n\t"
1113 "vld2.16 {d1, d3}, [%[in0]] \n\t"
1114@@ -398,7 +398,7 @@ void gaussianBlur5x5(const Size2D &size, s32 cn,
1115 u16* lidx1 = lane + x - 1*3;
1116 u16* lidx3 = lane + x + 1*3;
1117 u16* lidx4 = lane + x + 2*3;
1118-#if defined(__GNUC__) && defined(__arm__)
1119+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1120 __asm__ __volatile__ (
1121 "vld3.16 {d0, d2, d4}, [%[in0]]! \n\t"
1122 "vld3.16 {d1, d3, d5}, [%[in0]] \n\t"
1123@@ -482,7 +482,7 @@ void gaussianBlur5x5(const Size2D &size, s32 cn,
1124 u16* lidx1 = lane + x - 1*4;
1125 u16* lidx3 = lane + x + 1*4;
1126 u16* lidx4 = lane + x + 2*4;
1127-#if defined(__GNUC__) && defined(__arm__)
1128+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1129 __asm__ __volatile__ (
1130 "vld4.16 {d0, d2, d4, d6}, [%[in0]]! \n\t"
1131 "vld4.16 {d1, d3, d5, d7}, [%[in0]] \n\t"
1132diff --git a/3rdparty/carotene/src/pyramid.cpp b/3rdparty/carotene/src/pyramid.cpp
1133index 8ef1268933..232ccf3efd 100644
1134--- a/3rdparty/carotene/src/pyramid.cpp
1135+++ b/3rdparty/carotene/src/pyramid.cpp
1136@@ -331,7 +331,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
1137 for (; x < roiw8; x += 8)
1138 {
1139 internal::prefetch(lane + 2 * x);
1140-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1141+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1142 __asm__ (
1143 "vld2.16 {d0-d3}, [%[in0]] \n\t"
1144 "vld2.16 {d4-d7}, [%[in4]] \n\t"
1145@@ -538,7 +538,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
1146 for (; x < roiw4; x += 4)
1147 {
1148 internal::prefetch(lane + 2 * x);
1149-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1150+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1151 __asm__ (
1152 "vld2.32 {d0-d3}, [%[in0]] \n\t"
1153 "vld2.32 {d4-d7}, [%[in4]] \n\t"
1154@@ -672,7 +672,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
1155 std::vector<f32> _buf(cn*(srcSize.width + 4) + 32/sizeof(f32));
1156 f32* lane = internal::alignPtr(&_buf[2*cn], 32);
1157
1158-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1159+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1160 register float32x4_t vc6d4f32 asm ("q11") = vmovq_n_f32(1.5f); // 6/4
1161 register float32x4_t vc1d4f32 asm ("q12") = vmovq_n_f32(0.25f); // 1/4
1162
1163@@ -739,7 +739,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
1164 for (; x < roiw4; x += 4)
1165 {
1166 internal::prefetch(lane + 2 * x);
1167-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1168+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1169 __asm__ __volatile__ (
1170 "vld2.32 {d0-d3}, [%[in0]] \n\t"
1171 "vld2.32 {d8-d11}, [%[in4]] \n\t"
1172@@ -932,7 +932,7 @@ pyrUp8uHorizontalConvolution:
1173 for (; x < lim; x += 8)
1174 {
1175 internal::prefetch(lane + x);
1176-#if defined(__GNUC__) && defined(__arm__)
1177+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1178 __asm__ (
1179 "vld1.16 {d0-d1}, [%[in0]] /*q0 = v0*/ \n\t"
1180 "vld1.16 {d2-d3}, [%[in2]] /*q1 = v2*/ \n\t"
1181@@ -973,7 +973,7 @@ pyrUp8uHorizontalConvolution:
1182 for (; x < lim; x += 24)
1183 {
1184 internal::prefetch(lane + x);
1185-#if defined(__GNUC__) && defined(__arm__)
1186+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1187 __asm__ (
1188 "vmov.u16 q9, #6 \n\t"
1189 "vld3.16 {d0, d2, d4}, [%[in0]] /*v0*/ \n\t"
1190@@ -1064,7 +1064,7 @@ pyrUp8uHorizontalConvolution:
1191 for (; x < lim; x += 8)
1192 {
1193 internal::prefetch(lane + x);
1194-#if defined(__GNUC__) && defined(__arm__)
1195+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1196 __asm__ (
1197 "vld1.16 {d0-d1}, [%[in0]] /*q0 = v0*/ \n\t"
1198 "vld1.16 {d2-d3}, [%[in2]] /*q1 = v2*/ \n\t"
1199@@ -1210,7 +1210,7 @@ pyrUp16sHorizontalConvolution:
1200 for (; x < lim; x += 4)
1201 {
1202 internal::prefetch(lane + x);
1203-#if defined(__GNUC__) && defined(__arm__)
1204+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1205 __asm__ (
1206 "vld1.32 {d0-d1}, [%[in0]] /*q0 = v0*/ \n\t"
1207 "vld1.32 {d2-d3}, [%[in2]] /*q1 = v2*/ \n\t"
1208@@ -1251,7 +1251,7 @@ pyrUp16sHorizontalConvolution:
1209 for (; x < lim; x += 12)
1210 {
1211 internal::prefetch(lane + x + 3);
1212-#if defined(__GNUC__) && defined(__arm__)
1213+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1214 __asm__ (
1215 "vmov.s32 q9, #6 \n\t"
1216 "vld3.32 {d0, d2, d4}, [%[in0]] /*v0*/ \n\t"
1217@@ -1343,7 +1343,7 @@ pyrUp16sHorizontalConvolution:
1218 for (; x < lim; x += 4)
1219 {
1220 internal::prefetch(lane + x);
1221-#if defined(__GNUC__) && defined(__arm__)
1222+#if !defined(__aarch64__) && defined(__GNUC__) && defined(__arm__)
1223 __asm__ (
1224 "vld1.32 {d0-d1}, [%[in0]] /*q0 = v0*/ \n\t"
1225 "vld1.32 {d2-d3}, [%[in2]] /*q1 = v2*/ \n\t"
1226diff --git a/3rdparty/carotene/src/scharr.cpp b/3rdparty/carotene/src/scharr.cpp
1227index 5695804fe4..8d3b6328b1 100644
1228--- a/3rdparty/carotene/src/scharr.cpp
1229+++ b/3rdparty/carotene/src/scharr.cpp
1230@@ -109,7 +109,7 @@ void ScharrDeriv(const Size2D &size, s32 cn,
1231 internal::prefetch(srow0 + x);
1232 internal::prefetch(srow1 + x);
1233 internal::prefetch(srow2 + x);
1234-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1235+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
1236 __asm__ (
1237 "vld1.8 {d0}, [%[src0]] \n\t"
1238 "vld1.8 {d2}, [%[src2]] \n\t"
1239@@ -161,7 +161,7 @@ void ScharrDeriv(const Size2D &size, s32 cn,
1240 x = 0;
1241 for( ; x < roiw8; x += 8 )
1242 {
1243-#if defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
1244+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
1245 __asm__ (
1246 "vld1.16 {d4-d5}, [%[s2ptr]] \n\t"
1247 "vld1.16 {d8-d9}, [%[s4ptr]] \n\t"
1248--
12492.14.1
1250
diff --git a/meta-oe/recipes-support/opencv/opencv/0002-Do-not-enable-asm-with-clang.patch b/meta-oe/recipes-support/opencv/opencv/0002-Do-not-enable-asm-with-clang.patch
deleted file mode 100644
index 22e868a03..000000000
--- a/meta-oe/recipes-support/opencv/opencv/0002-Do-not-enable-asm-with-clang.patch
+++ /dev/null
@@ -1,993 +0,0 @@
1From 333f60165b6737588eb975a5e4393d847011a1cd Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 19 Sep 2017 18:07:35 -0700
4Subject: [PATCH 2/2] Do not enable asm with clang
5
6clang pretends to be gcc 4.2.0 which means we will
7use inline asm for no reason, instead of builtins
8on clang when possible.
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12Upstream-Status: Submitted
13 3rdparty/carotene/src/channel_extract.cpp | 4 +-
14 3rdparty/carotene/src/channels_combine.cpp | 2 +-
15 3rdparty/carotene/src/colorconvert.cpp | 78 +++++++++++++++---------------
16 3rdparty/carotene/src/convert.cpp | 54 ++++++++++-----------
17 3rdparty/carotene/src/convert_scale.cpp | 56 ++++++++++-----------
18 3rdparty/carotene/src/gaussian_blur.cpp | 2 +-
19 3rdparty/carotene/src/pyramid.cpp | 8 +--
20 3rdparty/carotene/src/scharr.cpp | 4 +-
21 8 files changed, 104 insertions(+), 104 deletions(-)
22
23diff --git a/3rdparty/carotene/src/channel_extract.cpp b/3rdparty/carotene/src/channel_extract.cpp
24index 8238a3ece8..ff4fb3770c 100644
25--- a/3rdparty/carotene/src/channel_extract.cpp
26+++ b/3rdparty/carotene/src/channel_extract.cpp
27@@ -231,7 +231,7 @@ void extract4(const Size2D &size,
28 srcStride == dst2Stride && \
29 srcStride == dst3Stride &&
30
31-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
32+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
33
34 #define SPLIT_ASM2(sgn, bits) __asm__ ( \
35 "vld2." #bits " {d0, d2}, [%[in0]] \n\t" \
36@@ -351,7 +351,7 @@ void extract4(const Size2D &size,
37 } \
38 }
39
40-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
41+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
42
43 #define ALPHA_QUAD(sgn, bits) { \
44 internal::prefetch(src + sj); \
45diff --git a/3rdparty/carotene/src/channels_combine.cpp b/3rdparty/carotene/src/channels_combine.cpp
46index fc98fb9181..5d9251d51c 100644
47--- a/3rdparty/carotene/src/channels_combine.cpp
48+++ b/3rdparty/carotene/src/channels_combine.cpp
49@@ -77,7 +77,7 @@ namespace CAROTENE_NS {
50 dstStride == src2Stride && \
51 dstStride == src3Stride &&
52
53-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
54+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
55
56 #define MERGE_ASM2(sgn, bits) __asm__ ( \
57 "vld1." #bits " {d0-d1}, [%[in0]] \n\t" \
58diff --git a/3rdparty/carotene/src/colorconvert.cpp b/3rdparty/carotene/src/colorconvert.cpp
59index 26ae54b15c..d3a40fe64e 100644
60--- a/3rdparty/carotene/src/colorconvert.cpp
61+++ b/3rdparty/carotene/src/colorconvert.cpp
62@@ -97,7 +97,7 @@ void rgb2gray(const Size2D &size, COLOR_SPACE color_space,
63 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
64 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
65
66-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
67+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
68 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
69 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
70 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
71@@ -116,7 +116,7 @@ void rgb2gray(const Size2D &size, COLOR_SPACE color_space,
72 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
73 size_t sj = 0u, dj = 0u;
74
75-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
76+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
77 for (; dj < roiw8; sj += 24, dj += 8)
78 {
79 internal::prefetch(src + sj);
80@@ -198,7 +198,7 @@ void rgbx2gray(const Size2D &size, COLOR_SPACE color_space,
81 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
82 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
83
84-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
85+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
86 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
87 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
88 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
89@@ -217,7 +217,7 @@ void rgbx2gray(const Size2D &size, COLOR_SPACE color_space,
90 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
91 size_t sj = 0u, dj = 0u;
92
93-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
94+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
95 for (; dj < roiw8; sj += 32, dj += 8)
96 {
97 internal::prefetch(src + sj);
98@@ -300,7 +300,7 @@ void bgr2gray(const Size2D &size, COLOR_SPACE color_space,
99 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
100 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
101
102-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
103+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
104 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
105 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
106 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
107@@ -319,7 +319,7 @@ void bgr2gray(const Size2D &size, COLOR_SPACE color_space,
108 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
109 size_t sj = 0u, dj = 0u;
110
111-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
112+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
113 for (; dj < roiw8; sj += 24, dj += 8)
114 {
115 internal::prefetch(src + sj);
116@@ -402,7 +402,7 @@ void bgrx2gray(const Size2D &size, COLOR_SPACE color_space,
117 const u32 G2Y = color_space == COLOR_SPACE_BT601 ? G2Y_BT601 : G2Y_BT709;
118 const u32 B2Y = color_space == COLOR_SPACE_BT601 ? B2Y_BT601 : B2Y_BT709;
119
120-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
121+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
122 register int16x4_t v_r2y asm ("d31") = vmov_n_s16(R2Y);
123 register int16x4_t v_g2y asm ("d30") = vmov_n_s16(G2Y);
124 register int16x4_t v_b2y asm ("d29") = vmov_n_s16(B2Y);
125@@ -421,7 +421,7 @@ void bgrx2gray(const Size2D &size, COLOR_SPACE color_space,
126 u8 * dst = internal::getRowPtr(dstBase, dstStride, i);
127 size_t sj = 0u, dj = 0u;
128
129-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
130+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
131 for (; dj < roiw8; sj += 32, dj += 8)
132 {
133 internal::prefetch(src + sj);
134@@ -512,7 +512,7 @@ void gray2rgb(const Size2D &size,
135 for (; sj < roiw16; sj += 16, dj += 48)
136 {
137 internal::prefetch(src + sj);
138-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
139+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
140 __asm__ (
141 "vld1.8 {d0-d1}, [%[in0]] \n\t"
142 "vmov.8 q1, q0 \n\t"
143@@ -538,7 +538,7 @@ void gray2rgb(const Size2D &size,
144
145 if (sj < roiw8)
146 {
147-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
148+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
149 __asm__ (
150 "vld1.8 {d0}, [%[in]] \n\t"
151 "vmov.8 d1, d0 \n\t"
152@@ -584,7 +584,7 @@ void gray2rgbx(const Size2D &size,
153 size_t roiw16 = size.width >= 15 ? size.width - 15 : 0;
154 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
155
156-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
157+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
158 register uint8x16_t vc255 asm ("q4") = vmovq_n_u8(255);
159 #else
160 uint8x16x4_t vRgba;
161@@ -602,7 +602,7 @@ void gray2rgbx(const Size2D &size,
162 for (; sj < roiw16; sj += 16, dj += 64)
163 {
164 internal::prefetch(src + sj);
165-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
166+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
167 __asm__ (
168 "vld1.8 {d0-d1}, [%[in0]] \n\t"
169 "vmov.8 q1, q0 \n\t"
170@@ -628,7 +628,7 @@ void gray2rgbx(const Size2D &size,
171
172 if (sj < roiw8)
173 {
174-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
175+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
176 __asm__ (
177 "vld1.8 {d5}, [%[in]] \n\t"
178 "vmov.8 d6, d5 \n\t"
179@@ -1409,7 +1409,7 @@ inline void convertToHSV(const s32 r, const s32 g, const s32 b,
180 "d24","d25","d26","d27","d28","d29","d30","d31" \
181 );
182
183-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
184+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
185
186 #define YCRCB_CONSTS \
187 register int16x4_t vcYR asm ("d31") = vmov_n_s16(4899); \
188@@ -1555,7 +1555,7 @@ inline uint8x8x3_t convertToYCrCb( const int16x8_t& vR, const int16x8_t& vG, con
189 #define COEFF_G ( 8663)
190 #define COEFF_B (-17705)
191
192-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
193+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
194 #define YUV420ALPHA3_CONST
195 #define YUV420ALPHA4_CONST register uint8x16_t c255 asm ("q13") = vmovq_n_u8(255);
196 #define YUV420ALPHA3_CONVERT
197@@ -1852,7 +1852,7 @@ void rgb2hsv(const Size2D &size,
198 #ifdef CAROTENE_NEON
199 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
200 const s32 hsv_shift = 12;
201-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
202+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
203 register const f32 vsdiv_table = f32(255 << hsv_shift);
204 register f32 vhdiv_table = f32(hrange << hsv_shift);
205 register const s32 vhrange = hrange;
206@@ -1871,7 +1871,7 @@ void rgb2hsv(const Size2D &size,
207 for (; j < roiw8; sj += 24, dj += 24, j += 8)
208 {
209 internal::prefetch(src + sj);
210-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
211+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
212 CONVERT_TO_HSV_ASM(vld3.8 {d0-d2}, d0, d2)
213 #else
214 uint8x8x3_t vRgb = vld3_u8(src + sj);
215@@ -1904,7 +1904,7 @@ void rgbx2hsv(const Size2D &size,
216 #ifdef CAROTENE_NEON
217 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
218 const s32 hsv_shift = 12;
219-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
220+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
221 register const f32 vsdiv_table = f32(255 << hsv_shift);
222 register f32 vhdiv_table = f32(hrange << hsv_shift);
223 register const s32 vhrange = hrange;
224@@ -1923,7 +1923,7 @@ void rgbx2hsv(const Size2D &size,
225 for (; j < roiw8; sj += 32, dj += 24, j += 8)
226 {
227 internal::prefetch(src + sj);
228-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
229+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
230 CONVERT_TO_HSV_ASM(vld4.8 {d0-d3}, d0, d2)
231 #else
232 uint8x8x4_t vRgb = vld4_u8(src + sj);
233@@ -1956,7 +1956,7 @@ void bgr2hsv(const Size2D &size,
234 #ifdef CAROTENE_NEON
235 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
236 const s32 hsv_shift = 12;
237-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
238+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
239 register const f32 vsdiv_table = f32(255 << hsv_shift);
240 register f32 vhdiv_table = f32(hrange << hsv_shift);
241 register const s32 vhrange = hrange;
242@@ -1975,7 +1975,7 @@ void bgr2hsv(const Size2D &size,
243 for (; j < roiw8; sj += 24, dj += 24, j += 8)
244 {
245 internal::prefetch(src + sj);
246-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
247+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
248 CONVERT_TO_HSV_ASM(vld3.8 {d0-d2}, d2, d0)
249 #else
250 uint8x8x3_t vRgb = vld3_u8(src + sj);
251@@ -2008,7 +2008,7 @@ void bgrx2hsv(const Size2D &size,
252 #ifdef CAROTENE_NEON
253 size_t roiw8 = size.width >= 7 ? size.width - 7 : 0;
254 const s32 hsv_shift = 12;
255-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
256+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
257 register const f32 vsdiv_table = f32(255 << hsv_shift);
258 register f32 vhdiv_table = f32(hrange << hsv_shift);
259 register const s32 vhrange = hrange;
260@@ -2027,7 +2027,7 @@ void bgrx2hsv(const Size2D &size,
261 for (; j < roiw8; sj += 32, dj += 24, j += 8)
262 {
263 internal::prefetch(src + sj);
264-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
265+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
266 CONVERT_TO_HSV_ASM(vld4.8 {d0-d3}, d2, d0)
267 #else
268 uint8x8x4_t vRgb = vld4_u8(src + sj);
269@@ -2068,7 +2068,7 @@ void rgbx2bgr565(const Size2D &size,
270 for (; j < roiw16; sj += 64, dj += 32, j += 16)
271 {
272 internal::prefetch(src + sj);
273-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
274+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
275 __asm__ (
276 "vld4.8 {d2, d4, d6, d8}, [%[in0]] @ q0 q1 q2 q3 q4 \n\t"
277 "vld4.8 {d3, d5, d7, d9}, [%[in1]] @ xxxxxxxx rrrrRRRR ggggGGGG bbbbBBBB xxxxxxxx \n\t"
278@@ -2122,7 +2122,7 @@ void rgb2bgr565(const Size2D &size,
279 for (; j < roiw16; sj += 48, dj += 32, j += 16)
280 {
281 internal::prefetch(src + sj);
282-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
283+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
284 __asm__ (
285 "vld3.8 {d2, d4, d6}, [%[in0]] @ q0 q1 q2 q3 q4 \n\t"
286 "vld3.8 {d3, d5, d7}, [%[in1]] @ xxxxxxxx rrrrRRRR ggggGGGG bbbbBBBB xxxxxxxx \n\t"
287@@ -2176,7 +2176,7 @@ void rgbx2rgb565(const Size2D &size,
288 for (; j < roiw16; sj += 64, dj += 32, j += 16)
289 {
290 internal::prefetch(src + sj);
291-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
292+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
293 __asm__ (
294 "vld4.8 {d0, d2, d4, d6}, [%[in0]] @ q0 q1 q2 q3 \n\t"
295 "vld4.8 {d1, d3, d5, d7}, [%[in1]] @ rrrrRRRR ggggGGGG bbbbBBBB aaaaAAAA \n\t"
296@@ -2230,7 +2230,7 @@ void rgb2rgb565(const Size2D &size,
297 for (; j < roiw16; sj += 48, dj += 32, j += 16)
298 {
299 internal::prefetch(src + sj);
300-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
301+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
302 __asm__ (
303 "vld3.8 {d0, d2, d4}, [%[in0]] @ q0 q1 q2 q3 \n\t"
304 "vld3.8 {d1, d3, d5}, [%[in1]] @ rrrrRRRR ggggGGGG bbbbBBBB xxxxxxxx \n\t"
305@@ -2285,7 +2285,7 @@ void rgb2ycrcb(const Size2D &size,
306 for (; j < roiw8; sj += 24, dj += 24, j += 8)
307 {
308 internal::prefetch(src + sj);
309-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
310+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
311 CONVERTTOYCRCB(vld3.8 {d0-d2}, d0, d1, d2)
312 #else
313 uint8x8x3_t vRgb = vld3_u8(src + sj);
314@@ -2329,7 +2329,7 @@ void rgbx2ycrcb(const Size2D &size,
315 for (; j < roiw8; sj += 32, dj += 24, j += 8)
316 {
317 internal::prefetch(src + sj);
318-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
319+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
320 CONVERTTOYCRCB(vld4.8 {d0-d3}, d0, d1, d2)
321 #else
322 uint8x8x4_t vRgba = vld4_u8(src + sj);
323@@ -2373,7 +2373,7 @@ void bgr2ycrcb(const Size2D &size,
324 for (; j < roiw8; sj += 24, dj += 24, j += 8)
325 {
326 internal::prefetch(src + sj);
327-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
328+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
329 CONVERTTOYCRCB(vld3.8 {d0-d2}, d2, d1, d0)
330 #else
331 uint8x8x3_t vBgr = vld3_u8(src + sj);
332@@ -2417,7 +2417,7 @@ void bgrx2ycrcb(const Size2D &size,
333 for (; j < roiw8; sj += 32, dj += 24, j += 8)
334 {
335 internal::prefetch(src + sj);
336-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
337+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
338 CONVERTTOYCRCB(vld4.8 {d0-d3}, d2, d1, d0)
339 #else
340 uint8x8x4_t vBgra = vld4_u8(src + sj);
341@@ -2499,7 +2499,7 @@ void yuv420sp2rgb(const Size2D &size,
342 internal::prefetch(uv + j);
343 internal::prefetch(y1 + j);
344 internal::prefetch(y2 + j);
345-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
346+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
347 CONVERTYUV420TORGB(3, d1, d0, q5, q6)
348 #else
349 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
350@@ -2545,7 +2545,7 @@ void yuv420sp2rgbx(const Size2D &size,
351 internal::prefetch(uv + j);
352 internal::prefetch(y1 + j);
353 internal::prefetch(y2 + j);
354-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
355+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
356 CONVERTYUV420TORGB(4, d1, d0, q5, q6)
357 #else
358 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
359@@ -2591,7 +2591,7 @@ void yuv420i2rgb(const Size2D &size,
360 internal::prefetch(uv + j);
361 internal::prefetch(y1 + j);
362 internal::prefetch(y2 + j);
363-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
364+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
365 CONVERTYUV420TORGB(3, d0, d1, q5, q6)
366 #else
367 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
368@@ -2637,7 +2637,7 @@ void yuv420i2rgbx(const Size2D &size,
369 internal::prefetch(uv + j);
370 internal::prefetch(y1 + j);
371 internal::prefetch(y2 + j);
372-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
373+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
374 CONVERTYUV420TORGB(4, d0, d1, q5, q6)
375 #else
376 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
377@@ -2683,7 +2683,7 @@ void yuv420sp2bgr(const Size2D &size,
378 internal::prefetch(uv + j);
379 internal::prefetch(y1 + j);
380 internal::prefetch(y2 + j);
381-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
382+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
383 CONVERTYUV420TORGB(3, d1, d0, q6, q5)
384 #else
385 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
386@@ -2729,7 +2729,7 @@ void yuv420sp2bgrx(const Size2D &size,
387 internal::prefetch(uv + j);
388 internal::prefetch(y1 + j);
389 internal::prefetch(y2 + j);
390-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
391+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
392 CONVERTYUV420TORGB(4, d1, d0, q6, q5)
393 #else
394 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
395@@ -2775,7 +2775,7 @@ void yuv420i2bgr(const Size2D &size,
396 internal::prefetch(uv + j);
397 internal::prefetch(y1 + j);
398 internal::prefetch(y2 + j);
399-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
400+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
401 CONVERTYUV420TORGB(3, d0, d1, q6, q5)
402 #else
403 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
404@@ -2821,7 +2821,7 @@ void yuv420i2bgrx(const Size2D &size,
405 internal::prefetch(uv + j);
406 internal::prefetch(y1 + j);
407 internal::prefetch(y2 + j);
408-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
409+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
410 CONVERTYUV420TORGB(4, d0, d1, q6, q5)
411 #else
412 convertYUV420.ToRGB(y1 + j, y2 + j, uv + j, dst1 + dj, dst2 + dj);
413diff --git a/3rdparty/carotene/src/convert.cpp b/3rdparty/carotene/src/convert.cpp
414index 64b6db78ab..f0c2d153f2 100644
415--- a/3rdparty/carotene/src/convert.cpp
416+++ b/3rdparty/carotene/src/convert.cpp
417@@ -101,7 +101,7 @@ CVT_FUNC(u8, s8, 16,
418 }
419 })
420
421-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
422+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
423 CVT_FUNC(u8, u16, 16,
424 register uint8x16_t zero0 asm ("q1") = vmovq_n_u8(0);,
425 {
426@@ -135,7 +135,7 @@ CVT_FUNC(u8, u16, 16,
427 })
428 #endif
429
430-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
431+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
432 CVT_FUNC(u8, s32, 16,
433 register uint8x16_t zero0 asm ("q1") = vmovq_n_u8(0);
434 register uint8x16_t zero1 asm ("q2") = vmovq_n_u8(0);
435@@ -173,7 +173,7 @@ CVT_FUNC(u8, s32, 16,
436 })
437 #endif
438
439-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
440+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
441 CVT_FUNC(u8, f32, 16,
442 ,
443 {
444@@ -248,7 +248,7 @@ CVT_FUNC(s8, u8, 16,
445 }
446 })
447
448-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
449+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
450 CVT_FUNC(s8, u16, 16,
451 register uint8x16_t zero0 asm ("q1") = vmovq_n_u8(0);,
452 {
453@@ -284,7 +284,7 @@ CVT_FUNC(s8, u16, 16,
454 })
455 #endif
456
457-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
458+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
459 CVT_FUNC(s8, s16, 16,
460 ,
461 {
462@@ -323,7 +323,7 @@ CVT_FUNC(s8, s16, 16,
463 })
464 #endif
465
466-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
467+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
468 CVT_FUNC(s8, s32, 16,
469 ,
470 {
471@@ -377,7 +377,7 @@ CVT_FUNC(s8, s32, 16,
472 })
473 #endif
474
475-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
476+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
477 CVT_FUNC(s8, f32, 16,
478 ,
479 {
480@@ -440,7 +440,7 @@ CVT_FUNC(s8, f32, 16,
481 })
482 #endif
483
484-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
485+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
486 CVT_FUNC(u16, u8, 16,
487 ,
488 {
489@@ -479,7 +479,7 @@ CVT_FUNC(u16, u8, 16,
490 })
491 #endif
492
493-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
494+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
495 CVT_FUNC(u16, s8, 16,
496 register uint8x16_t v127 asm ("q4") = vmovq_n_u8(127);,
497 {
498@@ -522,7 +522,7 @@ CVT_FUNC(u16, s8, 16,
499 })
500 #endif
501
502-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
503+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
504 CVT_FUNC(u16, s16, 8,
505 register uint16x8_t v32767 asm ("q4") = vmovq_n_u16(0x7FFF);,
506 {
507@@ -555,7 +555,7 @@ CVT_FUNC(u16, s16, 8,
508 })
509 #endif
510
511-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
512+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
513 CVT_FUNC(u16, s32, 8,
514 register uint16x8_t zero0 asm ("q1") = vmovq_n_u16(0);,
515 {
516@@ -589,7 +589,7 @@ CVT_FUNC(u16, s32, 8,
517 })
518 #endif
519
520-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
521+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
522 CVT_FUNC(u16, f32, 8,
523 ,
524 {
525@@ -633,7 +633,7 @@ CVT_FUNC(u16, f32, 8,
526 })
527 #endif
528
529-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
530+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
531 CVT_FUNC(s16, u8, 16,
532 ,
533 {
534@@ -672,7 +672,7 @@ CVT_FUNC(s16, u8, 16,
535 })
536 #endif
537
538-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
539+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
540 CVT_FUNC(s16, s8, 16,
541 ,
542 {
543@@ -711,7 +711,7 @@ CVT_FUNC(s16, s8, 16,
544 })
545 #endif
546
547-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
548+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
549 CVT_FUNC(s16, u16, 8,
550 register int16x8_t vZero asm ("q4") = vmovq_n_s16(0);,
551 {
552@@ -747,7 +747,7 @@ CVT_FUNC(s16, u16, 8,
553 })
554 #endif
555
556-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
557+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
558 CVT_FUNC(s16, s32, 8,
559 ,
560 {
561@@ -786,7 +786,7 @@ CVT_FUNC(s16, s32, 8,
562 })
563 #endif
564
565-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
566+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
567 CVT_FUNC(s16, f32, 8,
568 ,
569 {
570@@ -829,7 +829,7 @@ CVT_FUNC(s16, f32, 8,
571 })
572 #endif
573
574-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
575+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
576 CVT_FUNC(s32, u8, 8,
577 ,
578 {
579@@ -870,7 +870,7 @@ CVT_FUNC(s32, u8, 8,
580 })
581 #endif
582
583-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
584+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
585 CVT_FUNC(s32, s8, 8,
586 ,
587 {
588@@ -911,7 +911,7 @@ CVT_FUNC(s32, s8, 8,
589 })
590 #endif
591
592-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
593+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
594 CVT_FUNC(s32, u16, 8,
595 ,
596 {
597@@ -950,7 +950,7 @@ CVT_FUNC(s32, u16, 8,
598 })
599 #endif
600
601-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
602+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
603 CVT_FUNC(s32, s16, 8,
604 ,
605 {
606@@ -989,7 +989,7 @@ CVT_FUNC(s32, s16, 8,
607 })
608 #endif
609
610-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
611+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
612 CVT_FUNC(s32, f32, 8,
613 ,
614 {
615@@ -1034,7 +1034,7 @@ CVT_FUNC(s32, f32, 8,
616 })
617 #endif
618
619-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
620+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
621 CVT_FUNC(f32, u8, 8,
622 register float32x4_t vmult asm ("q0") = vdupq_n_f32((float)(1 << 16));
623 register uint32x4_t vmask asm ("q1") = vdupq_n_u32(1<<16);,
624@@ -1101,7 +1101,7 @@ CVT_FUNC(f32, u8, 8,
625 })
626 #endif
627
628-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
629+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
630 CVT_FUNC(f32, s8, 8,
631 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
632 {
633@@ -1153,7 +1153,7 @@ CVT_FUNC(f32, s8, 8,
634 })
635 #endif
636
637-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
638+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
639 CVT_FUNC(f32, u16, 8,
640 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
641 {
642@@ -1212,7 +1212,7 @@ CVT_FUNC(f32, u16, 8,
643 })
644 #endif
645
646-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
647+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
648 CVT_FUNC(f32, s16, 8,
649 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
650 {
651@@ -1271,7 +1271,7 @@ CVT_FUNC(f32, s16, 8,
652 })
653 #endif
654
655-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
656+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
657 CVT_FUNC(f32, s32, 8,
658 register float32x4_t vhalf asm ("q0") = vdupq_n_f32(0.5f);,
659 {
660diff --git a/3rdparty/carotene/src/convert_scale.cpp b/3rdparty/carotene/src/convert_scale.cpp
661index ae41a985c8..d599d24c1e 100644
662--- a/3rdparty/carotene/src/convert_scale.cpp
663+++ b/3rdparty/carotene/src/convert_scale.cpp
664@@ -473,7 +473,7 @@ CVTS_FUNC(u8, s16, 16,
665 })
666 #endif
667
668-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
669+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
670 CVTS_FUNC(u8, s32, 16,
671 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
672 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
673@@ -562,7 +562,7 @@ CVTS_FUNC(u8, s32, 16,
674 })
675 #endif
676
677-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
678+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
679 CVTS_FUNC(u8, f32, 16,
680 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
681 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
682@@ -985,7 +985,7 @@ CVTS_FUNC(s8, s16, 16,
683 })
684 #endif
685
686-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
687+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
688 CVTS_FUNC(s8, s32, 16,
689 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
690 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
691@@ -1074,7 +1074,7 @@ CVTS_FUNC(s8, s32, 16,
692 })
693 #endif
694
695-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
696+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
697 CVTS_FUNC(s8, f32, 16,
698 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
699 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
700@@ -1155,7 +1155,7 @@ CVTS_FUNC(s8, f32, 16,
701 })
702 #endif
703
704-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
705+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
706 CVTS_FUNC(u16, u8, 16,
707 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
708 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
709@@ -1214,7 +1214,7 @@ CVTS_FUNC(u16, u8, 16,
710 })
711 #endif
712
713-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
714+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
715 CVTS_FUNC(u16, s8, 16,
716 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
717 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
718@@ -1273,7 +1273,7 @@ CVTS_FUNC(u16, s8, 16,
719 })
720 #endif
721
722-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
723+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
724 CVTS_FUNC1(u16, 16,
725 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
726 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
727@@ -1330,7 +1330,7 @@ CVTS_FUNC1(u16, 16,
728 })
729 #endif
730
731-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
732+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
733 CVTS_FUNC(u16, s16, 8,
734 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
735 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
736@@ -1387,7 +1387,7 @@ CVTS_FUNC(u16, s16, 8,
737 })
738 #endif
739
740-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
741+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
742 CVTS_FUNC(u16, s32, 8,
743 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
744 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
745@@ -1443,7 +1443,7 @@ CVTS_FUNC(u16, s32, 8,
746 })
747 #endif
748
749-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
750+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
751 CVTS_FUNC(u16, f32, 8,
752 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
753 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
754@@ -1495,7 +1495,7 @@ CVTS_FUNC(u16, f32, 8,
755 })
756 #endif
757
758-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
759+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
760 CVTS_FUNC(s16, u8, 16,
761 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
762 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
763@@ -1554,7 +1554,7 @@ CVTS_FUNC(s16, u8, 16,
764 })
765 #endif
766
767-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
768+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
769 CVTS_FUNC(s16, s8, 16,
770 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
771 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
772@@ -1613,7 +1613,7 @@ CVTS_FUNC(s16, s8, 16,
773 })
774 #endif
775
776-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
777+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
778 CVTS_FUNC(s16, u16, 8,
779 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
780 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
781@@ -1670,7 +1670,7 @@ CVTS_FUNC(s16, u16, 8,
782 })
783 #endif
784
785-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
786+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
787 CVTS_FUNC1(s16, 16,
788 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
789 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
790@@ -1727,7 +1727,7 @@ CVTS_FUNC1(s16, 16,
791 })
792 #endif
793
794-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
795+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
796 CVTS_FUNC(s16, s32, 8,
797 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
798 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
799@@ -1783,7 +1783,7 @@ CVTS_FUNC(s16, s32, 8,
800 })
801 #endif
802
803-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
804+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
805 CVTS_FUNC(s16, f32, 8,
806 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
807 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
808@@ -1835,7 +1835,7 @@ CVTS_FUNC(s16, f32, 8,
809 })
810 #endif
811
812-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
813+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
814 CVTS_FUNC(s32, u8, 8,
815 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
816 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
817@@ -1893,7 +1893,7 @@ CVTS_FUNC(s32, u8, 8,
818 })
819 #endif
820
821-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
822+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
823 CVTS_FUNC(s32, s8, 8,
824 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
825 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
826@@ -1951,7 +1951,7 @@ CVTS_FUNC(s32, s8, 8,
827 })
828 #endif
829
830-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
831+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
832 CVTS_FUNC(s32, u16, 8,
833 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
834 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
835@@ -2007,7 +2007,7 @@ CVTS_FUNC(s32, u16, 8,
836 })
837 #endif
838
839-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
840+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
841 CVTS_FUNC(s32, s16, 8,
842 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
843 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
844@@ -2063,7 +2063,7 @@ CVTS_FUNC(s32, s16, 8,
845 })
846 #endif
847
848-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
849+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
850 CVTS_FUNC1(s32, 8,
851 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
852 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
853@@ -2118,7 +2118,7 @@ CVTS_FUNC1(s32, 8,
854 })
855 #endif
856
857-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
858+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
859 CVTS_FUNC(s32, f32, 8,
860 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
861 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
862@@ -2169,7 +2169,7 @@ CVTS_FUNC(s32, f32, 8,
863 })
864 #endif
865
866-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
867+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
868 CVTS_FUNC(f32, u8, 8,
869 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)((1 << 16)*alpha));
870 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)((1 << 16)*beta));
871@@ -2239,7 +2239,7 @@ CVTS_FUNC(f32, u8, 8,
872 })
873 #endif
874
875-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
876+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
877 CVTS_FUNC(f32, s8, 8,
878 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
879 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
880@@ -2293,7 +2293,7 @@ CVTS_FUNC(f32, s8, 8,
881 })
882 #endif
883
884-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
885+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
886 CVTS_FUNC(f32, u16, 8,
887 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
888 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
889@@ -2345,7 +2345,7 @@ CVTS_FUNC(f32, u16, 8,
890 })
891 #endif
892
893-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
894+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
895 CVTS_FUNC(f32, s16, 8,
896 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
897 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
898@@ -2397,7 +2397,7 @@ CVTS_FUNC(f32, s16, 8,
899 })
900 #endif
901
902-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
903+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
904 CVTS_FUNC(f32, s32, 8,
905 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
906 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta + 0.5f);,
907@@ -2448,7 +2448,7 @@ CVTS_FUNC(f32, s32, 8,
908 })
909 #endif
910
911-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
912+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
913 CVTS_FUNC1(f32, 8,
914 register float32x4_t vscale asm ("q0") = vdupq_n_f32((f32)alpha);
915 register float32x4_t vshift asm ("q1") = vdupq_n_f32((f32)beta);,
916diff --git a/3rdparty/carotene/src/gaussian_blur.cpp b/3rdparty/carotene/src/gaussian_blur.cpp
917index f7b5f18d79..e5aa8fc75b 100644
918--- a/3rdparty/carotene/src/gaussian_blur.cpp
919+++ b/3rdparty/carotene/src/gaussian_blur.cpp
920@@ -327,7 +327,7 @@ void gaussianBlur5x5(const Size2D &size, s32 cn,
921 u16* lidx1 = lane + x - 1*2;
922 u16* lidx3 = lane + x + 1*2;
923 u16* lidx4 = lane + x + 2*2;
924-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
925+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
926 __asm__ __volatile__ (
927 "vld2.16 {d0, d2}, [%[in0]]! \n\t"
928 "vld2.16 {d1, d3}, [%[in0]] \n\t"
929diff --git a/3rdparty/carotene/src/pyramid.cpp b/3rdparty/carotene/src/pyramid.cpp
930index 232ccf3efd..d4e32ea50f 100644
931--- a/3rdparty/carotene/src/pyramid.cpp
932+++ b/3rdparty/carotene/src/pyramid.cpp
933@@ -331,7 +331,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
934 for (; x < roiw8; x += 8)
935 {
936 internal::prefetch(lane + 2 * x);
937-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
938+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
939 __asm__ (
940 "vld2.16 {d0-d3}, [%[in0]] \n\t"
941 "vld2.16 {d4-d7}, [%[in4]] \n\t"
942@@ -538,7 +538,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
943 for (; x < roiw4; x += 4)
944 {
945 internal::prefetch(lane + 2 * x);
946-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
947+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
948 __asm__ (
949 "vld2.32 {d0-d3}, [%[in0]] \n\t"
950 "vld2.32 {d4-d7}, [%[in4]] \n\t"
951@@ -672,7 +672,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
952 std::vector<f32> _buf(cn*(srcSize.width + 4) + 32/sizeof(f32));
953 f32* lane = internal::alignPtr(&_buf[2*cn], 32);
954
955-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
956+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
957 register float32x4_t vc6d4f32 asm ("q11") = vmovq_n_f32(1.5f); // 6/4
958 register float32x4_t vc1d4f32 asm ("q12") = vmovq_n_f32(0.25f); // 1/4
959
960@@ -739,7 +739,7 @@ void gaussianPyramidDown(const Size2D &srcSize,
961 for (; x < roiw4; x += 4)
962 {
963 internal::prefetch(lane + 2 * x);
964-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
965+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
966 __asm__ __volatile__ (
967 "vld2.32 {d0-d3}, [%[in0]] \n\t"
968 "vld2.32 {d8-d11}, [%[in4]] \n\t"
969diff --git a/3rdparty/carotene/src/scharr.cpp b/3rdparty/carotene/src/scharr.cpp
970index 8d3b6328b1..36f6b2276e 100644
971--- a/3rdparty/carotene/src/scharr.cpp
972+++ b/3rdparty/carotene/src/scharr.cpp
973@@ -109,7 +109,7 @@ void ScharrDeriv(const Size2D &size, s32 cn,
974 internal::prefetch(srow0 + x);
975 internal::prefetch(srow1 + x);
976 internal::prefetch(srow2 + x);
977-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7
978+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7 && !defined(__clang__)
979 __asm__ (
980 "vld1.8 {d0}, [%[src0]] \n\t"
981 "vld1.8 {d2}, [%[src2]] \n\t"
982@@ -161,7 +161,7 @@ void ScharrDeriv(const Size2D &size, s32 cn,
983 x = 0;
984 for( ; x < roiw8; x += 8 )
985 {
986-#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6
987+#if !defined(__aarch64__) && defined(__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ < 6 && !defined(__clang__)
988 __asm__ (
989 "vld1.16 {d4-d5}, [%[s2ptr]] \n\t"
990 "vld1.16 {d8-d9}, [%[s4ptr]] \n\t"
991--
9922.14.1
993
diff --git a/meta-oe/recipes-support/opencv/opencv/0002-imgcodecs-refactoring-improve-code-quality.patch b/meta-oe/recipes-support/opencv/opencv/0002-imgcodecs-refactoring-improve-code-quality.patch
deleted file mode 100644
index 39f33af9d..000000000
--- a/meta-oe/recipes-support/opencv/opencv/0002-imgcodecs-refactoring-improve-code-quality.patch
+++ /dev/null
@@ -1,656 +0,0 @@
1Upstream-Status: Backport [https://github.com/opencv/opencv/pull/9376/commits/999f41fb4f4aa94a0cb47256919ae8b5c29ca5f3]
2
3Fix CVEs for opencv 3.3:
4
5* CVE-2017-12597
6* CVE-2017-12598
7* CVE-2017-12599
8* CVE-2017-12600
9* CVE-2017-12601
10* CVE-2017-12602
11* CVE-2017-12603
12* CVE-2017-12604
13* CVE-2017-12605
14* CVE-2017-12606
15* CVE-2017-12862
16* CVE-2017-12863
17* CVE-2017-12864
18
19Signed-off-by: Kai Kang <kai.kang@windriver.com>
20---
21From 999f41fb4f4aa94a0cb47256919ae8b5c29ca5f3 Mon Sep 17 00:00:00 2001
22From: Alexander Alekhin <alexander.a.alekhin@gmail.com>
23Date: Tue, 15 Aug 2017 22:04:55 +0000
24Subject: [PATCH 2/3] imgcodecs: refactoring, improve code quality
25
26---
27 modules/imgcodecs/src/bitstrm.cpp | 2 +
28 modules/imgcodecs/src/bitstrm.hpp | 19 +++--
29 modules/imgcodecs/src/grfmt_bmp.cpp | 13 ++-
30 modules/imgcodecs/src/grfmt_pxm.cpp | 122 ++++++++++++++++-----------
31 modules/imgcodecs/src/loadsave.cpp | 164 +++++++++++++++++++++++++++++-------
32 5 files changed, 231 insertions(+), 89 deletions(-)
33
34diff --git a/modules/imgcodecs/src/bitstrm.cpp b/modules/imgcodecs/src/bitstrm.cpp
35index a7e187fa0..0a8941aec 100644
36--- a/modules/imgcodecs/src/bitstrm.cpp
37+++ b/modules/imgcodecs/src/bitstrm.cpp
38@@ -209,6 +209,8 @@ int RLByteStream::getByte()
39 current = m_current;
40 }
41
42+ CV_Assert(current < m_end);
43+
44 val = *((uchar*)current);
45 m_current = current + 1;
46 return val;
47diff --git a/modules/imgcodecs/src/bitstrm.hpp b/modules/imgcodecs/src/bitstrm.hpp
48index 465c0a847..26947971f 100644
49--- a/modules/imgcodecs/src/bitstrm.hpp
50+++ b/modules/imgcodecs/src/bitstrm.hpp
51@@ -48,13 +48,20 @@
52 namespace cv
53 {
54
55-enum
56-{
57- RBS_THROW_EOS=-123, // <end of stream> exception code
58- RBS_THROW_FORB=-124, // <forrbidden huffman code> exception code
59- RBS_HUFF_FORB=2047, // forrbidden huffman code "value"
60- RBS_BAD_HEADER=-125 // invalid header
61+#define DECLARE_RBS_EXCEPTION(name) \
62+class RBS_ ## name ## _Exception : public cv::Exception \
63+{ \
64+public: \
65+ RBS_ ## name ## _Exception(int code_, const String& err_, const String& func_, const String& file_, int line_) : \
66+ cv::Exception(code_, err_, func_, file_, line_) \
67+ {} \
68 };
69+DECLARE_RBS_EXCEPTION(THROW_EOS)
70+#define RBS_THROW_EOS RBS_THROW_EOS_Exception(cv::Error::StsError, "Unexpected end of input stream", CV_Func, __FILE__, __LINE__)
71+DECLARE_RBS_EXCEPTION(THROW_FORB)
72+#define RBS_THROW_FORB RBS_THROW_FORB_Exception(cv::Error::StsError, "Forrbidden huffman code", CV_Func, __FILE__, __LINE__)
73+DECLARE_RBS_EXCEPTION(BAD_HEADER)
74+#define RBS_BAD_HEADER RBS_BAD_HEADER_Exception(cv::Error::StsError, "Invalid header", CV_Func, __FILE__, __LINE__)
75
76 typedef unsigned long ulong;
77
78diff --git a/modules/imgcodecs/src/grfmt_bmp.cpp b/modules/imgcodecs/src/grfmt_bmp.cpp
79index 86cacd316..257f97c2d 100644
80--- a/modules/imgcodecs/src/grfmt_bmp.cpp
81+++ b/modules/imgcodecs/src/grfmt_bmp.cpp
82@@ -118,8 +118,9 @@ bool BmpDecoder::readHeader()
83
84 if( m_bpp <= 8 )
85 {
86- memset( m_palette, 0, sizeof(m_palette));
87- m_strm.getBytes( m_palette, (clrused == 0? 1<<m_bpp : clrused)*4 );
88+ CV_Assert(clrused < 256);
89+ memset(m_palette, 0, sizeof(m_palette));
90+ m_strm.getBytes(m_palette, (clrused == 0? 1<<m_bpp : clrused)*4 );
91 iscolor = IsColorPalette( m_palette, m_bpp );
92 }
93 else if( m_bpp == 16 && m_rle_code == BMP_BITFIELDS )
94@@ -290,7 +291,9 @@ bool BmpDecoder::readData( Mat& img )
95 else if( code > 2 ) // absolute mode
96 {
97 if( data + code*nch > line_end ) goto decode_rle4_bad;
98- m_strm.getBytes( src, (((code + 1)>>1) + 1) & -2 );
99+ int sz = (((code + 1)>>1) + 1) & (~1);
100+ CV_Assert((size_t)sz < _src.size());
101+ m_strm.getBytes(src, sz);
102 if( color )
103 data = FillColorRow4( data, src, code, m_palette );
104 else
105@@ -379,7 +382,9 @@ decode_rle4_bad: ;
106
107 if( data + code3 > line_end )
108 goto decode_rle8_bad;
109- m_strm.getBytes( src, (code + 1) & -2 );
110+ int sz = (code + 1) & (~1);
111+ CV_Assert((size_t)sz < _src.size());
112+ m_strm.getBytes(src, sz);
113 if( color )
114 data = FillColorRow8( data, src, code, m_palette );
115 else
116diff --git a/modules/imgcodecs/src/grfmt_pxm.cpp b/modules/imgcodecs/src/grfmt_pxm.cpp
117index 1750cb705..68bd8fd93 100644
118--- a/modules/imgcodecs/src/grfmt_pxm.cpp
119+++ b/modules/imgcodecs/src/grfmt_pxm.cpp
120@@ -43,50 +43,58 @@
121 #include "precomp.hpp"
122 #include "utils.hpp"
123 #include "grfmt_pxm.hpp"
124+#include <iostream>
125
126 namespace cv
127 {
128
129 ///////////////////////// P?M reader //////////////////////////////
130
131-static int ReadNumber( RLByteStream& strm, int maxdigits )
132+static int ReadNumber(RLByteStream& strm, int maxdigits = 0)
133 {
134 int code;
135- int val = 0;
136+ int64 val = 0;
137 int digits = 0;
138
139 code = strm.getByte();
140
141- if( !isdigit(code))
142+ while (!isdigit(code))
143 {
144- do
145+ if (code == '#' )
146 {
147- if( code == '#' )
148+ do
149 {
150- do
151- {
152- code = strm.getByte();
153- }
154- while( code != '\n' && code != '\r' );
155+ code = strm.getByte();
156 }
157-
158+ while (code != '\n' && code != '\r');
159 code = strm.getByte();
160-
161- while( isspace(code))
162+ }
163+ else if (isspace(code))
164+ {
165+ while (isspace(code))
166 code = strm.getByte();
167 }
168- while( !isdigit( code ));
169+ else
170+ {
171+#if 1
172+ CV_ErrorNoReturn_(Error::StsError, ("PXM: Unexpected code in ReadNumber(): 0x%x (%d)", code, code));
173+#else
174+ code = strm.getByte();
175+#endif
176+ }
177 }
178
179 do
180 {
181- val = val*10 + code - '0';
182- if( ++digits >= maxdigits ) break;
183+ val = val*10 + (code - '0');
184+ CV_Assert(val <= INT_MAX && "PXM: ReadNumber(): result is too large");
185+ digits++;
186+ if (maxdigits != 0 && digits >= maxdigits) break;
187 code = strm.getByte();
188 }
189- while( isdigit(code));
190+ while (isdigit(code));
191
192- return val;
193+ return (int)val;
194 }
195
196
197@@ -122,13 +130,13 @@ ImageDecoder PxMDecoder::newDecoder() const
198 return makePtr<PxMDecoder>();
199 }
200
201-void PxMDecoder::close()
202+void PxMDecoder::close()
203 {
204 m_strm.close();
205 }
206
207
208-bool PxMDecoder::readHeader()
209+bool PxMDecoder::readHeader()
210 {
211 bool result = false;
212
213@@ -158,10 +166,10 @@ bool PxMDecoder::readHeader()
214 m_binary = code >= '4';
215 m_type = m_bpp > 8 ? CV_8UC3 : CV_8UC1;
216
217- m_width = ReadNumber( m_strm, INT_MAX );
218- m_height = ReadNumber( m_strm, INT_MAX );
219+ m_width = ReadNumber(m_strm);
220+ m_height = ReadNumber(m_strm);
221
222- m_maxval = m_bpp == 1 ? 1 : ReadNumber( m_strm, INT_MAX );
223+ m_maxval = m_bpp == 1 ? 1 : ReadNumber(m_strm);
224 if( m_maxval > 65535 )
225 throw RBS_BAD_HEADER;
226
227@@ -175,8 +183,14 @@ bool PxMDecoder::readHeader()
228 result = true;
229 }
230 }
231- catch(...)
232+ catch (const cv::Exception&)
233+ {
234+ throw;
235+ }
236+ catch (...)
237 {
238+ std::cerr << "PXM::readHeader(): unknown C++ exception" << std::endl << std::flush;
239+ throw;
240 }
241
242 if( !result )
243@@ -189,33 +203,28 @@ bool PxMDecoder::readHeader()
244 }
245
246
247-bool PxMDecoder::readData( Mat& img )
248+bool PxMDecoder::readData( Mat& img )
249 {
250 int color = img.channels() > 1;
251 uchar* data = img.ptr();
252 PaletteEntry palette[256];
253 bool result = false;
254- int bit_depth = CV_ELEM_SIZE1(m_type)*8;
255- int src_pitch = (m_width*m_bpp*bit_depth/8 + 7)/8;
256+ const int bit_depth = CV_ELEM_SIZE1(m_type)*8;
257+ const int src_pitch = divUp(m_width*m_bpp*(bit_depth/8), 8);
258 int nch = CV_MAT_CN(m_type);
259 int width3 = m_width*nch;
260- int i, x, y;
261
262 if( m_offset < 0 || !m_strm.isOpened())
263 return false;
264
265- AutoBuffer<uchar> _src(src_pitch + 32);
266- uchar* src = _src;
267- AutoBuffer<uchar> _gray_palette;
268- uchar* gray_palette = _gray_palette;
269+ uchar gray_palette[256] = {0};
270
271 // create LUT for converting colors
272 if( bit_depth == 8 )
273 {
274- _gray_palette.allocate(m_maxval + 1);
275- gray_palette = _gray_palette;
276+ CV_Assert(m_maxval < 256);
277
278- for( i = 0; i <= m_maxval; i++ )
279+ for (int i = 0; i <= m_maxval; i++)
280 gray_palette[i] = (uchar)((i*255/m_maxval)^(m_bpp == 1 ? 255 : 0));
281
282 FillGrayPalette( palette, m_bpp==1 ? 1 : 8 , m_bpp == 1 );
283@@ -229,12 +238,16 @@ bool PxMDecoder::readData( Mat& img )
284 {
285 ////////////////////////// 1 BPP /////////////////////////
286 case 1:
287+ CV_Assert(CV_MAT_DEPTH(m_type) == CV_8U);
288 if( !m_binary )
289 {
290- for( y = 0; y < m_height; y++, data += img.step )
291+ AutoBuffer<uchar> _src(m_width);
292+ uchar* src = _src;
293+
294+ for (int y = 0; y < m_height; y++, data += img.step)
295 {
296- for( x = 0; x < m_width; x++ )
297- src[x] = ReadNumber( m_strm, 1 ) != 0;
298+ for (int x = 0; x < m_width; x++)
299+ src[x] = ReadNumber(m_strm, 1) != 0;
300
301 if( color )
302 FillColorRow8( data, src, m_width, palette );
303@@ -244,7 +257,10 @@ bool PxMDecoder::readData( Mat& img )
304 }
305 else
306 {
307- for( y = 0; y < m_height; y++, data += img.step )
308+ AutoBuffer<uchar> _src(src_pitch);
309+ uchar* src = _src;
310+
311+ for (int y = 0; y < m_height; y++, data += img.step)
312 {
313 m_strm.getBytes( src, src_pitch );
314
315@@ -260,13 +276,17 @@ bool PxMDecoder::readData( Mat& img )
316 ////////////////////////// 8 BPP /////////////////////////
317 case 8:
318 case 24:
319- for( y = 0; y < m_height; y++, data += img.step )
320+ {
321+ AutoBuffer<uchar> _src(std::max<size_t>(width3*2, src_pitch));
322+ uchar* src = _src;
323+
324+ for (int y = 0; y < m_height; y++, data += img.step)
325 {
326 if( !m_binary )
327 {
328- for( x = 0; x < width3; x++ )
329+ for (int x = 0; x < width3; x++)
330 {
331- int code = ReadNumber( m_strm, INT_MAX );
332+ int code = ReadNumber(m_strm);
333 if( (unsigned)code > (unsigned)m_maxval ) code = m_maxval;
334 if( bit_depth == 8 )
335 src[x] = gray_palette[code];
336@@ -279,7 +299,7 @@ bool PxMDecoder::readData( Mat& img )
337 m_strm.getBytes( src, src_pitch );
338 if( bit_depth == 16 && !isBigEndian() )
339 {
340- for( x = 0; x < width3; x++ )
341+ for (int x = 0; x < width3; x++)
342 {
343 uchar v = src[x * 2];
344 src[x * 2] = src[x * 2 + 1];
345@@ -290,7 +310,7 @@ bool PxMDecoder::readData( Mat& img )
346
347 if( img.depth() == CV_8U && bit_depth == 16 )
348 {
349- for( x = 0; x < width3; x++ )
350+ for (int x = 0; x < width3; x++)
351 {
352 int v = ((ushort *)src)[x];
353 src[x] = (uchar)(v >> 8);
354@@ -331,12 +351,19 @@ bool PxMDecoder::readData( Mat& img )
355 }
356 result = true;
357 break;
358+ }
359 default:
360- assert(0);
361+ CV_ErrorNoReturn(Error::StsError, "m_bpp is not supported");
362 }
363 }
364- catch(...)
365+ catch (const cv::Exception&)
366+ {
367+ throw;
368+ }
369+ catch (...)
370 {
371+ std::cerr << "PXM::readData(): unknown exception" << std::endl << std::flush;
372+ throw;
373 }
374
375 return result;
376@@ -412,8 +439,9 @@ bool PxMEncoder::write( const Mat& img, const std::vector<int>& params )
377 char* buffer = _buffer;
378
379 // write header;
380- sprintf( buffer, "P%c\n%d %d\n%d\n",
381+ sprintf( buffer, "P%c\n# Generated by OpenCV %s\n%d %d\n%d\n",
382 '2' + (channels > 1 ? 1 : 0) + (isBinary ? 3 : 0),
383+ CV_VERSION,
384 width, height, (1 << depth) - 1 );
385
386 strm.putBytes( buffer, (int)strlen(buffer) );
387diff --git a/modules/imgcodecs/src/loadsave.cpp b/modules/imgcodecs/src/loadsave.cpp
388index 3b2366217..5ee4ca354 100644
389--- a/modules/imgcodecs/src/loadsave.cpp
390+++ b/modules/imgcodecs/src/loadsave.cpp
391@@ -55,6 +55,27 @@
392 /****************************************************************************************\
393 * Image Codecs *
394 \****************************************************************************************/
395+
396+namespace cv {
397+
398+// TODO Add runtime configuration
399+#define CV_IO_MAX_IMAGE_PARAMS (50)
400+#define CV_IO_MAX_IMAGE_WIDTH (1<<20)
401+#define CV_IO_MAX_IMAGE_HEIGHT (1<<20)
402+#define CV_IO_MAX_IMAGE_PIXELS (1<<30) // 1 Gigapixel
403+
404+static Size validateInputImageSize(const Size& size)
405+{
406+ CV_Assert(size.width > 0);
407+ CV_Assert(size.width <= CV_IO_MAX_IMAGE_WIDTH);
408+ CV_Assert(size.height > 0);
409+ CV_Assert(size.height <= CV_IO_MAX_IMAGE_HEIGHT);
410+ uint64 pixels = (uint64)size.width * (uint64)size.height;
411+ CV_Assert(pixels <= CV_IO_MAX_IMAGE_PIXELS);
412+ return size;
413+}
414+
415+
416 namespace {
417
418 class ByteStreamBuffer: public std::streambuf
419@@ -94,9 +115,6 @@ protected:
420
421 }
422
423-namespace cv
424-{
425-
426 /**
427 * @struct ImageCodecInitializer
428 *
429@@ -408,14 +426,26 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
430 /// set the filename in the driver
431 decoder->setSource( filename );
432
433- // read the header to make sure it succeeds
434- if( !decoder->readHeader() )
435+ try
436+ {
437+ // read the header to make sure it succeeds
438+ if( !decoder->readHeader() )
439+ return 0;
440+ }
441+ catch (const cv::Exception& e)
442+ {
443+ std::cerr << "imread_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
444 return 0;
445+ }
446+ catch (...)
447+ {
448+ std::cerr << "imread_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
449+ return 0;
450+ }
451+
452
453 // established the required input image size
454- CvSize size;
455- size.width = decoder->width();
456- size.height = decoder->height();
457+ Size size = validateInputImageSize(Size(decoder->width(), decoder->height()));
458
459 // grab the decoded type
460 int type = decoder->type();
461@@ -451,7 +481,21 @@ imread_( const String& filename, int flags, int hdrtype, Mat* mat=0 )
462 }
463
464 // read the image data
465- if( !decoder->readData( *data ))
466+ bool success = false;
467+ try
468+ {
469+ if (decoder->readData(*data))
470+ success = true;
471+ }
472+ catch (const cv::Exception& e)
473+ {
474+ std::cerr << "imread_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
475+ }
476+ catch (...)
477+ {
478+ std::cerr << "imread_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
479+ }
480+ if (!success)
481 {
482 cvReleaseImage( &image );
483 cvReleaseMat( &matrix );
484@@ -504,8 +548,22 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
485 decoder->setSource(filename);
486
487 // read the header to make sure it succeeds
488- if (!decoder->readHeader())
489+ try
490+ {
491+ // read the header to make sure it succeeds
492+ if( !decoder->readHeader() )
493+ return 0;
494+ }
495+ catch (const cv::Exception& e)
496+ {
497+ std::cerr << "imreadmulti_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
498 return 0;
499+ }
500+ catch (...)
501+ {
502+ std::cerr << "imreadmulti_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
503+ return 0;
504+ }
505
506 for (;;)
507 {
508@@ -523,17 +581,32 @@ imreadmulti_(const String& filename, int flags, std::vector<Mat>& mats)
509 type = CV_MAKETYPE(CV_MAT_DEPTH(type), 1);
510 }
511
512+ // established the required input image size
513+ Size size = validateInputImageSize(Size(decoder->width(), decoder->height()));
514+
515 // read the image data
516- Mat mat(decoder->height(), decoder->width(), type);
517- if (!decoder->readData(mat))
518+ Mat mat(size.height, size.width, type);
519+ bool success = false;
520+ try
521 {
522- // optionally rotate the data if EXIF' orientation flag says so
523- if( (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
524- {
525- ApplyExifOrientation(filename, mat);
526- }
527-
528+ if (decoder->readData(mat))
529+ success = true;
530+ }
531+ catch (const cv::Exception& e)
532+ {
533+ std::cerr << "imreadmulti_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
534+ }
535+ catch (...)
536+ {
537+ std::cerr << "imreadmulti_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
538+ }
539+ if (!success)
540 break;
541+
542+ // optionally rotate the data if EXIF' orientation flag says so
543+ if( (flags & IMREAD_IGNORE_ORIENTATION) == 0 && flags != IMREAD_UNCHANGED )
544+ {
545+ ApplyExifOrientation(filename, mat);
546 }
547
548 mats.push_back(mat);
549@@ -616,6 +689,7 @@ static bool imwrite_( const String& filename, const Mat& image,
550 }
551
552 encoder->setDestination( filename );
553+ CV_Assert(params.size() <= CV_IO_MAX_IMAGE_PARAMS*2);
554 bool code = encoder->write( *pimage, params );
555
556 // CV_Assert( code );
557@@ -663,22 +737,35 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
558 decoder->setSource(filename);
559 }
560
561- if( !decoder->readHeader() )
562+ bool success = false;
563+ try
564+ {
565+ if (decoder->readHeader())
566+ success = true;
567+ }
568+ catch (const cv::Exception& e)
569+ {
570+ std::cerr << "imdecode_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
571+ }
572+ catch (...)
573+ {
574+ std::cerr << "imdecode_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
575+ }
576+ if (!success)
577 {
578 decoder.release();
579- if ( !filename.empty() )
580+ if (!filename.empty())
581 {
582- if ( remove(filename.c_str()) != 0 )
583+ if (0 != remove(filename.c_str()))
584 {
585- CV_Error( CV_StsError, "unable to remove temporary file" );
586+ std::cerr << "unable to remove temporary file:" << filename << std::endl << std::flush;
587 }
588 }
589 return 0;
590 }
591
592- CvSize size;
593- size.width = decoder->width();
594- size.height = decoder->height();
595+ // established the required input image size
596+ Size size = validateInputImageSize(Size(decoder->width(), decoder->height()));
597
598 int type = decoder->type();
599 if( (flags & IMREAD_LOAD_GDAL) != IMREAD_LOAD_GDAL && flags != IMREAD_UNCHANGED )
600@@ -712,17 +799,30 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
601 temp = cvarrToMat(image);
602 }
603
604- bool code = decoder->readData( *data );
605+ success = false;
606+ try
607+ {
608+ if (decoder->readData(*data))
609+ success = true;
610+ }
611+ catch (const cv::Exception& e)
612+ {
613+ std::cerr << "imdecode_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
614+ }
615+ catch (...)
616+ {
617+ std::cerr << "imdecode_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
618+ }
619 decoder.release();
620- if ( !filename.empty() )
621+ if (!filename.empty())
622 {
623- if ( remove(filename.c_str()) != 0 )
624+ if (0 != remove(filename.c_str()))
625 {
626- CV_Error( CV_StsError, "unable to remove temporary file" );
627+ std::cerr << "unable to remove temporary file:" << filename << std::endl << std::flush;
628 }
629 }
630
631- if( !code )
632+ if (!success)
633 {
634 cvReleaseImage( &image );
635 cvReleaseMat( &matrix );
636@@ -859,7 +959,7 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params )
637 if( _params )
638 {
639 for( ; _params[i] > 0; i += 2 )
640- ;
641+ CV_Assert(i < CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
642 }
643 return cv::imwrite_(filename, cv::cvarrToMat(arr),
644 i > 0 ? std::vector<int>(_params, _params+i) : std::vector<int>(),
645@@ -890,7 +990,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params )
646 if( _params )
647 {
648 for( ; _params[i] > 0; i += 2 )
649- ;
650+ CV_Assert(i < CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
651 }
652 cv::Mat img = cv::cvarrToMat(arr);
653 if( CV_IS_IMAGE(arr) && ((const IplImage*)arr)->origin == IPL_ORIGIN_BL )
654--
6552.14.1
656
diff --git a/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch b/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
index a22b04a90..5270b8c9f 100644
--- a/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
+++ b/meta-oe/recipes-support/opencv/opencv/0003-To-fix-errors-as-following.patch
@@ -19,29 +19,21 @@ Signed-off-by: Ismo Puustinen <ismo.puustinen@intel.com>
19 modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +- 19 modules/ts/include/opencv2/ts/ts_ext.hpp | 2 +-
20 3 files changed, 5 insertions(+), 5 deletions(-) 20 3 files changed, 5 insertions(+), 5 deletions(-)
21 21
22diff --git a/modules/ts/include/opencv2/ts.hpp b/modules/ts/include/opencv2/ts.hpp 22Index: git/modules/ts/include/opencv2/ts.hpp
23index 41a76b13e..205646140 100644 23===================================================================
24--- a/modules/ts/include/opencv2/ts.hpp 24--- git.orig/modules/ts/include/opencv2/ts.hpp
25+++ b/modules/ts/include/opencv2/ts.hpp 25+++ git/modules/ts/include/opencv2/ts.hpp
26@@ -555,7 +555,7 @@ protected: 26@@ -608,7 +608,7 @@ protected:
27 } 27 }
28 }; 28 };
29 29
30-extern uint64 param_seed; 30-extern uint64 param_seed;
31+CV_EXPORTS extern uint64 param_seed; 31+CV_EXPORTS extern uint64 param_seed;
32 32
33 struct CV_EXPORTS DefaultRngAuto 33 struct DefaultRngAuto
34 { 34 {
35@@ -611,14 +611,14 @@ CV_EXPORTS std::string findDataFile(const std::string& relative_path, bool requi 35@@ -671,7 +671,7 @@ private:
36 36 #endif
37 #ifdef HAVE_OPENCL
38 namespace ocl {
39-void dumpOpenCLDevice();
40+CV_EXPORTS void dumpOpenCLDevice();
41 }
42 #define TEST_DUMP_OCL_INFO cvtest::ocl::dumpOpenCLDevice();
43 #else
44 #define TEST_DUMP_OCL_INFO
45 #endif 37 #endif
46 38
47-void parseCustomOptions(int argc, char **argv); 39-void parseCustomOptions(int argc, char **argv);
@@ -49,10 +41,10 @@ index 41a76b13e..205646140 100644
49 41
50 #define CV_TEST_INIT0_NOOP (void)0 42 #define CV_TEST_INIT0_NOOP (void)0
51 43
52diff --git a/modules/ts/include/opencv2/ts/ocl_test.hpp b/modules/ts/include/opencv2/ts/ocl_test.hpp 44Index: git/modules/ts/include/opencv2/ts/ocl_test.hpp
53index 54b33ece8..ef56bf9ef 100644 45===================================================================
54--- a/modules/ts/include/opencv2/ts/ocl_test.hpp 46--- git.orig/modules/ts/include/opencv2/ts/ocl_test.hpp
55+++ b/modules/ts/include/opencv2/ts/ocl_test.hpp 47+++ git/modules/ts/include/opencv2/ts/ocl_test.hpp
56@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src) 48@@ -82,7 +82,7 @@ inline UMat ToUMat(InputArray src)
57 return dst; 49 return dst;
58 } 50 }
@@ -62,19 +54,16 @@ index 54b33ece8..ef56bf9ef 100644
62 54
63 #define MAX_VALUE 357 55 #define MAX_VALUE 357
64 56
65diff --git a/modules/ts/include/opencv2/ts/ts_ext.hpp b/modules/ts/include/opencv2/ts/ts_ext.hpp 57Index: git/modules/ts/include/opencv2/ts/ts_ext.hpp
66index 0bdd346dd..2cd34dfce 100644 58===================================================================
67--- a/modules/ts/include/opencv2/ts/ts_ext.hpp 59--- git.orig/modules/ts/include/opencv2/ts/ts_ext.hpp
68+++ b/modules/ts/include/opencv2/ts/ts_ext.hpp 60+++ git/modules/ts/include/opencv2/ts/ts_ext.hpp
69@@ -9,7 +9,7 @@ 61@@ -9,7 +9,7 @@
70 #define OPENCV_TS_EXT_HPP 62 #define OPENCV_TS_EXT_HPP
71 63
72 namespace cvtest { 64 namespace cvtest {
73-void checkIppStatus(); 65-void checkIppStatus();
74+CV_EXPORTS void checkIppStatus(); 66+CV_EXPORTS void checkIppStatus();
75 } 67 extern bool skipUnstableTests;
76 68 extern bool runBigDataTests;
77 #define CV_TEST_INIT \ 69 extern int testThreads;
78--
792.13.4
80
diff --git a/meta-oe/recipes-support/opencv/opencv/0003-imgproc-test-add-checks-for-remove-call.patch b/meta-oe/recipes-support/opencv/opencv/0003-imgproc-test-add-checks-for-remove-call.patch
deleted file mode 100644
index 5f4a60c96..000000000
--- a/meta-oe/recipes-support/opencv/opencv/0003-imgproc-test-add-checks-for-remove-call.patch
+++ /dev/null
@@ -1,186 +0,0 @@
1Upstream-Status: Backport [https://github.com/opencv/opencv/pull/9376/commits/78a310630fb0a1f6d089576202343e672f27609d]
2
3Fix CVEs for opencv 3.3.
4
5* CVE-2017-12597
6* CVE-2017-12598
7* CVE-2017-12599
8* CVE-2017-12600
9* CVE-2017-12601
10* CVE-2017-12602
11* CVE-2017-12603
12* CVE-2017-12604
13* CVE-2017-12605
14* CVE-2017-12606
15* CVE-2017-12862
16* CVE-2017-12863
17* CVE-2017-12864
18
19Signed-off-by: Kai Kang <kai.kang@windriver.com>
20---
21From 78a310630fb0a1f6d089576202343e672f27609d Mon Sep 17 00:00:00 2001
22From: Alexander Alekhin <alexander.alekhin@intel.com>
23Date: Wed, 16 Aug 2017 13:53:12 +0300
24Subject: [PATCH 3/3] imgproc(test): add checks for remove() call
25
26---
27 modules/imgcodecs/test/test_grfmt.cpp | 2 +-
28 modules/imgcodecs/test/test_jpeg.cpp | 12 ++++++------
29 modules/imgcodecs/test/test_png.cpp | 2 +-
30 modules/imgcodecs/test/test_read_write.cpp | 4 ++--
31 modules/imgcodecs/test/test_tiff.cpp | 8 ++++----
32 modules/imgcodecs/test/test_webp.cpp | 6 +++---
33 6 files changed, 17 insertions(+), 17 deletions(-)
34
35diff --git a/modules/imgcodecs/test/test_grfmt.cpp b/modules/imgcodecs/test/test_grfmt.cpp
36index 64a0c1e3a..74b72c3b3 100644
37--- a/modules/imgcodecs/test/test_grfmt.cpp
38+++ b/modules/imgcodecs/test/test_grfmt.cpp
39@@ -175,7 +175,7 @@ TEST_P(Imgcodecs_ExtSize, write_imageseq)
40 EXPECT_LT(n, 1.);
41 EXPECT_PRED_FORMAT2(cvtest::MatComparator(0, 0), img, img_gt);
42 }
43- remove(filename.c_str());
44+ EXPECT_EQ(0, remove(filename.c_str()));
45 }
46 }
47
48diff --git a/modules/imgcodecs/test/test_jpeg.cpp b/modules/imgcodecs/test/test_jpeg.cpp
49index 5546f2d91..6ddb02840 100644
50--- a/modules/imgcodecs/test/test_jpeg.cpp
51+++ b/modules/imgcodecs/test/test_jpeg.cpp
52@@ -123,8 +123,8 @@ TEST(Imgcodecs_Jpeg, encode_decode_progressive_jpeg)
53
54 EXPECT_EQ(0, cvtest::norm(img_jpg_progressive, img_jpg_normal, NORM_INF));
55
56- remove(output_progressive.c_str());
57- remove(output_normal.c_str());
58+ EXPECT_EQ(0, remove(output_progressive.c_str()));
59+ EXPECT_EQ(0, remove(output_normal.c_str()));
60 }
61
62 TEST(Imgcodecs_Jpeg, encode_decode_optimize_jpeg)
63@@ -148,8 +148,8 @@ TEST(Imgcodecs_Jpeg, encode_decode_optimize_jpeg)
64
65 EXPECT_EQ(0, cvtest::norm(img_jpg_optimized, img_jpg_normal, NORM_INF));
66
67- remove(output_optimized.c_str());
68- remove(output_normal.c_str());
69+ EXPECT_EQ(0, remove(output_optimized.c_str()));
70+ EXPECT_EQ(0, remove(output_normal.c_str()));
71 }
72
73 TEST(Imgcodecs_Jpeg, encode_decode_rst_jpeg)
74@@ -173,8 +173,8 @@ TEST(Imgcodecs_Jpeg, encode_decode_rst_jpeg)
75
76 EXPECT_EQ(0, cvtest::norm(img_jpg_rst, img_jpg_normal, NORM_INF));
77
78- remove(output_rst.c_str());
79- remove(output_normal.c_str());
80+ EXPECT_EQ(0, remove(output_rst.c_str()));
81+ EXPECT_EQ(0, remove(output_normal.c_str()));
82 }
83
84 #endif // HAVE_JPEG
85diff --git a/modules/imgcodecs/test/test_png.cpp b/modules/imgcodecs/test/test_png.cpp
86index c46f90119..4e97043e1 100644
87--- a/modules/imgcodecs/test/test_png.cpp
88+++ b/modules/imgcodecs/test/test_png.cpp
89@@ -17,7 +17,7 @@ TEST(Imgcodecs_Png, write_big)
90 EXPECT_EQ(13043, img.cols);
91 EXPECT_EQ(13917, img.rows);
92 ASSERT_NO_THROW(imwrite(dst_file, img));
93- remove(dst_file.c_str());
94+ EXPECT_EQ(0, remove(dst_file.c_str()));
95 }
96
97 TEST(Imgcodecs_Png, encode)
98diff --git a/modules/imgcodecs/test/test_read_write.cpp b/modules/imgcodecs/test/test_read_write.cpp
99index 38f10225f..5119813bf 100644
100--- a/modules/imgcodecs/test/test_read_write.cpp
101+++ b/modules/imgcodecs/test/test_read_write.cpp
102@@ -50,7 +50,7 @@ TEST(Imgcodecs_Image, read_write_bmp)
103 psnr = cvtest::PSNR(buf_loaded, image);
104 EXPECT_GT(psnr, thresDbell);
105
106- remove(dst_name.c_str());
107+ EXPECT_EQ(0, remove(dst_name.c_str()));
108 }
109 }
110
111@@ -95,7 +95,7 @@ TEST_P(Imgcodecs_Image, read_write)
112 psnr = cvtest::PSNR(buf_loaded, image);
113 EXPECT_GT(psnr, thresDbell);
114
115- remove(full_name.c_str());
116+ EXPECT_EQ(0, remove(full_name.c_str()));
117 }
118
119 const string exts[] = {
120diff --git a/modules/imgcodecs/test/test_tiff.cpp b/modules/imgcodecs/test/test_tiff.cpp
121index 0264da4cd..6ef0c1748 100644
122--- a/modules/imgcodecs/test/test_tiff.cpp
123+++ b/modules/imgcodecs/test/test_tiff.cpp
124@@ -41,8 +41,8 @@ TEST(Imgcodecs_Tiff, decode_tile16384x16384)
125 // not enough memory
126 }
127
128- remove(file3.c_str());
129- remove(file4.c_str());
130+ EXPECT_EQ(0, remove(file3.c_str()));
131+ EXPECT_EQ(0, remove(file4.c_str()));
132 }
133
134 TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian)
135@@ -88,7 +88,7 @@ TEST(Imgcodecs_Tiff, write_read_16bit_big_little_endian)
136 EXPECT_EQ(0xDEAD, img.at<ushort>(0,0));
137 EXPECT_EQ(0xBEEF, img.at<ushort>(0,1));
138
139- remove(filename.c_str());
140+ EXPECT_EQ(0, remove(filename.c_str()));
141 }
142 }
143
144@@ -143,7 +143,7 @@ TEST(Imgcodecs_Tiff, decode_infinite_rowsperstrip)
145
146 EXPECT_NO_THROW(cv::imread(filename, IMREAD_UNCHANGED));
147
148- remove(filename.c_str());
149+ EXPECT_EQ(0, remove(filename.c_str()));
150 }
151
152 //==================================================================================================
153diff --git a/modules/imgcodecs/test/test_webp.cpp b/modules/imgcodecs/test/test_webp.cpp
154index 6d40ce21e..d82fdd289 100644
155--- a/modules/imgcodecs/test/test_webp.cpp
156+++ b/modules/imgcodecs/test/test_webp.cpp
157@@ -44,7 +44,7 @@ TEST(Imgcodecs_WebP, encode_decode_lossless_webp)
158 }
159 }
160
161- remove(output.c_str());
162+ EXPECT_EQ(0, remove(output.c_str()));
163
164 cv::Mat decode = cv::imdecode(buf, IMREAD_COLOR);
165 ASSERT_FALSE(decode.empty());
166@@ -71,7 +71,7 @@ TEST(Imgcodecs_WebP, encode_decode_lossy_webp)
167
168 EXPECT_NO_THROW(cv::imwrite(output, img, params));
169 cv::Mat img_webp = cv::imread(output);
170- remove(output.c_str());
171+ EXPECT_EQ(0, remove(output.c_str()));
172 EXPECT_FALSE(img_webp.empty());
173 EXPECT_EQ(3, img_webp.channels());
174 EXPECT_EQ(512, img_webp.cols);
175@@ -96,7 +96,7 @@ TEST(Imgcodecs_WebP, encode_decode_with_alpha_webp)
176
177 EXPECT_NO_THROW(cv::imwrite(output, img));
178 cv::Mat img_webp = cv::imread(output);
179- remove(output.c_str());
180+ EXPECT_EQ(0, remove(output.c_str()));
181 EXPECT_FALSE(img_webp.empty());
182 EXPECT_EQ(4, img_webp.channels());
183 EXPECT_EQ(512, img_webp.cols);
184--
1852.14.1
186
diff --git a/meta-oe/recipes-support/opencv/opencv/CVE-2017-14136.patch b/meta-oe/recipes-support/opencv/opencv/CVE-2017-14136.patch
deleted file mode 100644
index 7ad50a2d2..000000000
--- a/meta-oe/recipes-support/opencv/opencv/CVE-2017-14136.patch
+++ /dev/null
@@ -1,288 +0,0 @@
1Upstream-Status: Backport [https://github.com/opencv/opencv/pull/9448/commits/aacae20]
2
3Backport patch to fix CVE-2017-14136.
4
5Ref: https://github.com/opencv/opencv/issues/9443
6
7Signed-off-by: Kai Kang <kai.kang@windriver.com>
8---
9From aacae2065744adb05e858d327198c7bbe7f452b0 Mon Sep 17 00:00:00 2001
10From: Alexander Alekhin <alexander.alekhin@intel.com>
11Date: Wed, 23 Aug 2017 15:15:27 +0300
12Subject: [PATCH] imgcodesc: fix code problems with integer overflow / address
13 arithmetic / UB
14
15---
16 modules/imgcodecs/src/grfmt_bmp.cpp | 8 ++---
17 modules/imgcodecs/src/grfmt_exr.cpp | 10 +++----
18 modules/imgcodecs/src/grfmt_jpeg.cpp | 2 +-
19 modules/imgcodecs/src/grfmt_jpeg2000.cpp | 6 ++--
20 modules/imgcodecs/src/grfmt_pam.cpp | 2 +-
21 modules/imgcodecs/src/grfmt_sunras.cpp | 6 ++--
22 modules/imgcodecs/src/utils.cpp | 51 +++++++++++++++++++-------------
23 modules/imgcodecs/src/utils.hpp | 2 ++
24 8 files changed, 50 insertions(+), 37 deletions(-)
25
26diff --git a/modules/imgcodecs/src/grfmt_bmp.cpp b/modules/imgcodecs/src/grfmt_bmp.cpp
27index 257f97c2d8b..69768e276a3 100644
28--- a/modules/imgcodecs/src/grfmt_bmp.cpp
29+++ b/modules/imgcodecs/src/grfmt_bmp.cpp
30@@ -193,7 +193,7 @@ bool BmpDecoder::readHeader()
31 bool BmpDecoder::readData( Mat& img )
32 {
33 uchar* data = img.ptr();
34- int step = (int)img.step;
35+ int step = validateToInt(img.step);
36 bool color = img.channels() > 1;
37 uchar gray_palette[256] = {0};
38 bool result = false;
39@@ -206,7 +206,7 @@ bool BmpDecoder::readData( Mat& img )
40
41 if( m_origin == IPL_ORIGIN_BL )
42 {
43- data += (m_height - 1)*step;
44+ data += (m_height - 1)*(size_t)step;
45 step = -step;
46 }
47
48@@ -530,7 +530,7 @@ bool BmpEncoder::write( const Mat& img, const std::vector<int>& )
49 int bitmapHeaderSize = 40;
50 int paletteSize = channels > 1 ? 0 : 1024;
51 int headerSize = 14 /* fileheader */ + bitmapHeaderSize + paletteSize;
52- int fileSize = fileStep*height + headerSize;
53+ size_t fileSize = (size_t)fileStep*height + headerSize;
54 PaletteEntry palette[256];
55
56 if( m_buf )
57@@ -540,7 +540,7 @@ bool BmpEncoder::write( const Mat& img, const std::vector<int>& )
58 strm.putBytes( fmtSignBmp, (int)strlen(fmtSignBmp) );
59
60 // write file header
61- strm.putDWord( fileSize ); // file size
62+ strm.putDWord( validateToInt(fileSize) ); // file size
63 strm.putDWord( 0 );
64 strm.putDWord( headerSize );
65
66diff --git a/modules/imgcodecs/src/grfmt_exr.cpp b/modules/imgcodecs/src/grfmt_exr.cpp
67index 0d2ae9fa7d2..78ffe6c7668 100644
68--- a/modules/imgcodecs/src/grfmt_exr.cpp
69+++ b/modules/imgcodecs/src/grfmt_exr.cpp
70@@ -195,7 +195,7 @@ bool ExrDecoder::readData( Mat& img )
71 bool color = img.channels() > 1;
72
73 uchar* data = img.ptr();
74- int step = img.step;
75+ size_t step = img.step;
76 bool justcopy = m_native_depth;
77 bool chromatorgb = false;
78 bool rgbtogray = false;
79@@ -203,8 +203,8 @@ bool ExrDecoder::readData( Mat& img )
80 FrameBuffer frame;
81 int xsample[3] = {1, 1, 1};
82 char *buffer;
83- int xstep;
84- int ystep;
85+ size_t xstep = 0;
86+ size_t ystep = 0;
87
88 xstep = m_native_depth ? 4 : 1;
89
90@@ -593,7 +593,7 @@ bool ExrEncoder::write( const Mat& img, const std::vector<int>& )
91 bool issigned = depth == CV_8S || depth == CV_16S || depth == CV_32S;
92 bool isfloat = depth == CV_32F || depth == CV_64F;
93 depth = CV_ELEM_SIZE1(depth)*8;
94- const int step = img.step;
95+ const size_t step = img.step;
96
97 Header header( width, height );
98 Imf::PixelType type;
99@@ -623,7 +623,7 @@ bool ExrEncoder::write( const Mat& img, const std::vector<int>& )
100 FrameBuffer frame;
101
102 char *buffer;
103- int bufferstep;
104+ size_t bufferstep;
105 int size;
106 if( type == FLOAT && depth == 32 )
107 {
108diff --git a/modules/imgcodecs/src/grfmt_jpeg.cpp b/modules/imgcodecs/src/grfmt_jpeg.cpp
109index ce942ca1995..caf768d2569 100644
110--- a/modules/imgcodecs/src/grfmt_jpeg.cpp
111+++ b/modules/imgcodecs/src/grfmt_jpeg.cpp
112@@ -396,7 +396,7 @@ int my_jpeg_load_dht (struct jpeg_decompress_struct *info, unsigned char *dht,
113 bool JpegDecoder::readData( Mat& img )
114 {
115 volatile bool result = false;
116- int step = (int)img.step;
117+ size_t step = img.step;
118 bool color = img.channels() > 1;
119
120 if( m_state && m_width && m_height )
121diff --git a/modules/imgcodecs/src/grfmt_jpeg2000.cpp b/modules/imgcodecs/src/grfmt_jpeg2000.cpp
122index 950ec21375f..24dfb38bb9d 100644
123--- a/modules/imgcodecs/src/grfmt_jpeg2000.cpp
124+++ b/modules/imgcodecs/src/grfmt_jpeg2000.cpp
125@@ -156,7 +156,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
126 bool result = false;
127 int color = img.channels() > 1;
128 uchar* data = img.ptr();
129- int step = (int)img.step;
130+ size_t step = img.step;
131 jas_stream_t* stream = (jas_stream_t*)m_stream;
132 jas_image_t* image = (jas_image_t*)m_image;
133
134@@ -252,9 +252,9 @@ bool Jpeg2KDecoder::readData( Mat& img )
135 if( !jas_image_readcmpt( image, cmptlut[i], 0, 0, xend / xstep, yend / ystep, buffer ))
136 {
137 if( img.depth() == CV_8U )
138- result = readComponent8u( data + i, buffer, step, cmptlut[i], maxval, offset, ncmpts );
139+ result = readComponent8u( data + i, buffer, validateToInt(step), cmptlut[i], maxval, offset, ncmpts );
140 else
141- result = readComponent16u( ((unsigned short *)data) + i, buffer, step / 2, cmptlut[i], maxval, offset, ncmpts );
142+ result = readComponent16u( ((unsigned short *)data) + i, buffer, validateToInt(step / 2), cmptlut[i], maxval, offset, ncmpts );
143 if( !result )
144 {
145 i = ncmpts;
146diff --git a/modules/imgcodecs/src/grfmt_pam.cpp b/modules/imgcodecs/src/grfmt_pam.cpp
147index 11195dc342c..8eb9e012309 100644
148--- a/modules/imgcodecs/src/grfmt_pam.cpp
149+++ b/modules/imgcodecs/src/grfmt_pam.cpp
150@@ -479,7 +479,7 @@ bool PAMDecoder::readData( Mat& img )
151 {
152 uchar* data = img.ptr();
153 int target_channels = img.channels();
154- int imp_stride = (int)img.step;
155+ size_t imp_stride = img.step;
156 int sample_depth = CV_ELEM_SIZE1(m_type);
157 int src_elems_per_row = m_width*m_channels;
158 int src_stride = src_elems_per_row*sample_depth;
159diff --git a/modules/imgcodecs/src/grfmt_sunras.cpp b/modules/imgcodecs/src/grfmt_sunras.cpp
160index aca9b369318..6d448f94ed3 100644
161--- a/modules/imgcodecs/src/grfmt_sunras.cpp
162+++ b/modules/imgcodecs/src/grfmt_sunras.cpp
163@@ -160,7 +160,7 @@ bool SunRasterDecoder::readData( Mat& img )
164 {
165 int color = img.channels() > 1;
166 uchar* data = img.ptr();
167- int step = (int)img.step;
168+ size_t step = img.step;
169 uchar gray_palette[256] = {0};
170 bool result = false;
171 int src_pitch = ((m_width*m_bpp + 7)/8 + 1) & -2;
172@@ -308,11 +308,11 @@ bool SunRasterDecoder::readData( Mat& img )
173 code = m_strm.getByte();
174
175 if( color )
176- data = FillUniColor( data, line_end, step, width3,
177+ data = FillUniColor( data, line_end, validateToInt(step), width3,
178 y, m_height, len,
179 m_palette[code] );
180 else
181- data = FillUniGray( data, line_end, step, width3,
182+ data = FillUniGray( data, line_end, validateToInt(step), width3,
183 y, m_height, len,
184 gray_palette[code] );
185 if( y >= m_height )
186diff --git a/modules/imgcodecs/src/utils.cpp b/modules/imgcodecs/src/utils.cpp
187index 2ee5bafc712..474dae008ca 100644
188--- a/modules/imgcodecs/src/utils.cpp
189+++ b/modules/imgcodecs/src/utils.cpp
190@@ -42,6 +42,13 @@
191 #include "precomp.hpp"
192 #include "utils.hpp"
193
194+int validateToInt(size_t sz)
195+{
196+ int valueInt = (int)sz;
197+ CV_Assert((size_t)valueInt == sz);
198+ return valueInt;
199+}
200+
201 #define SCALE 14
202 #define cR (int)(0.299*(1 << SCALE) + 0.5)
203 #define cG (int)(0.587*(1 << SCALE) + 0.5)
204@@ -537,23 +544,25 @@ uchar* FillColorRow1( uchar* data, uchar* indices, int len, PaletteEntry* palett
205 {
206 uchar* end = data + len*3;
207
208+ const PaletteEntry p0 = palette[0], p1 = palette[1];
209+
210 while( (data += 24) < end )
211 {
212 int idx = *indices++;
213- *((PaletteEntry*)(data - 24)) = palette[(idx & 128) != 0];
214- *((PaletteEntry*)(data - 21)) = palette[(idx & 64) != 0];
215- *((PaletteEntry*)(data - 18)) = palette[(idx & 32) != 0];
216- *((PaletteEntry*)(data - 15)) = palette[(idx & 16) != 0];
217- *((PaletteEntry*)(data - 12)) = palette[(idx & 8) != 0];
218- *((PaletteEntry*)(data - 9)) = palette[(idx & 4) != 0];
219- *((PaletteEntry*)(data - 6)) = palette[(idx & 2) != 0];
220- *((PaletteEntry*)(data - 3)) = palette[(idx & 1) != 0];
221+ *((PaletteEntry*)(data - 24)) = (idx & 128) ? p1 : p0;
222+ *((PaletteEntry*)(data - 21)) = (idx & 64) ? p1 : p0;
223+ *((PaletteEntry*)(data - 18)) = (idx & 32) ? p1 : p0;
224+ *((PaletteEntry*)(data - 15)) = (idx & 16) ? p1 : p0;
225+ *((PaletteEntry*)(data - 12)) = (idx & 8) ? p1 : p0;
226+ *((PaletteEntry*)(data - 9)) = (idx & 4) ? p1 : p0;
227+ *((PaletteEntry*)(data - 6)) = (idx & 2) ? p1 : p0;
228+ *((PaletteEntry*)(data - 3)) = (idx & 1) ? p1 : p0;
229 }
230
231- int idx = indices[0] << 24;
232+ int idx = indices[0];
233 for( data -= 24; data < end; data += 3, idx += idx )
234 {
235- PaletteEntry clr = palette[idx < 0];
236+ const PaletteEntry clr = (idx & 128) ? p1 : p0;
237 WRITE_PIX( data, clr );
238 }
239
240@@ -565,23 +574,25 @@ uchar* FillGrayRow1( uchar* data, uchar* indices, int len, uchar* palette )
241 {
242 uchar* end = data + len;
243
244+ const uchar p0 = palette[0], p1 = palette[1];
245+
246 while( (data += 8) < end )
247 {
248 int idx = *indices++;
249- *((uchar*)(data - 8)) = palette[(idx & 128) != 0];
250- *((uchar*)(data - 7)) = palette[(idx & 64) != 0];
251- *((uchar*)(data - 6)) = palette[(idx & 32) != 0];
252- *((uchar*)(data - 5)) = palette[(idx & 16) != 0];
253- *((uchar*)(data - 4)) = palette[(idx & 8) != 0];
254- *((uchar*)(data - 3)) = palette[(idx & 4) != 0];
255- *((uchar*)(data - 2)) = palette[(idx & 2) != 0];
256- *((uchar*)(data - 1)) = palette[(idx & 1) != 0];
257+ *((uchar*)(data - 8)) = (idx & 128) ? p1 : p0;
258+ *((uchar*)(data - 7)) = (idx & 64) ? p1 : p0;
259+ *((uchar*)(data - 6)) = (idx & 32) ? p1 : p0;
260+ *((uchar*)(data - 5)) = (idx & 16) ? p1 : p0;
261+ *((uchar*)(data - 4)) = (idx & 8) ? p1 : p0;
262+ *((uchar*)(data - 3)) = (idx & 4) ? p1 : p0;
263+ *((uchar*)(data - 2)) = (idx & 2) ? p1 : p0;
264+ *((uchar*)(data - 1)) = (idx & 1) ? p1 : p0;
265 }
266
267- int idx = indices[0] << 24;
268+ int idx = indices[0];
269 for( data -= 8; data < end; data++, idx += idx )
270 {
271- data[0] = palette[idx < 0];
272+ data[0] = (idx & 128) ? p1 : p0;
273 }
274
275 return data;
276diff --git a/modules/imgcodecs/src/utils.hpp b/modules/imgcodecs/src/utils.hpp
277index cab10609db2..7af4c6174ee 100644
278--- a/modules/imgcodecs/src/utils.hpp
279+++ b/modules/imgcodecs/src/utils.hpp
280@@ -42,6 +42,8 @@
281 #ifndef _UTILS_H_
282 #define _UTILS_H_
283
284+int validateToInt(size_t step);
285+
286 struct PaletteEntry
287 {
288 unsigned char b, g, r, a;
diff --git a/meta-oe/recipes-support/opencv/opencv/already-exists.patch b/meta-oe/recipes-support/opencv/opencv/already-exists.patch
deleted file mode 100644
index 6e24f2de8..000000000
--- a/meta-oe/recipes-support/opencv/opencv/already-exists.patch
+++ /dev/null
@@ -1,394 +0,0 @@
1From e4bf148cddf277834e57c9afeec8daff8378a655 Mon Sep 17 00:00:00 2001
2From: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
3Date: Wed, 22 Nov 2017 15:27:07 +0100
4Subject: [PATCH] Fix: File already exists in database: caffe.proto
5
6Fixes error when importing python cv
7
8Upstream-status: Backport https://github.com/opencv/opencv/pull/10092
9Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
10---
11 modules/dnn/CMakeLists.txt | 6 +++---
12 modules/dnn/src/caffe/caffe_importer.cpp | 1 -
13 modules/dnn/src/caffe/caffe_io.cpp | 1 -
14 modules/dnn/src/caffe/caffe_io.hpp | 2 +-
15 modules/dnn/src/caffe/{caffe.proto => opencv-caffe.proto} | 0
16 5 files changed, 4 insertions(+), 6 deletions(-)
17 rename modules/dnn/src/caffe/{caffe.proto => opencv-caffe.proto} (100%)
18
19diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
20index c6329a742263..8ef00ef983ff 100644
21--- a/modules/dnn/CMakeLists.txt
22+++ b/modules/dnn/CMakeLists.txt
23@@ -55,13 +55,13 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS
24
25 if(PROTOBUF_UPDATE_FILES)
26 file(GLOB proto_files src/tensorflow/*.proto)
27- list(APPEND proto_files src/caffe/caffe.proto)
28+ list(APPEND proto_files src/caffe/opencv-caffe.proto)
29 PROTOBUF_GENERATE_CPP(Protobuf_HDRS Protobuf_SRCS ${proto_files})
30 else()
31 file(GLOB fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.cc)
32 file(GLOB fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/tensorflow/*.h)
33- list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.cc)
34- list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/caffe.pb.h)
35+ list(APPEND fw_srcs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/opencv-caffe.pb.cc)
36+ list(APPEND fw_hdrs ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe/opencv-caffe.pb.h)
37 list(APPEND Protobuf_SRCS ${fw_srcs})
38 list(APPEND Protobuf_HDRS ${fw_hdrs})
39 list(APPEND Protobuf_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/misc/caffe)
40diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp
41index c075651b95b3..2c977c84b0f4 100644
42--- a/modules/dnn/src/caffe/caffe_importer.cpp
43+++ b/modules/dnn/src/caffe/caffe_importer.cpp
44@@ -42,7 +42,6 @@
45 #include "../precomp.hpp"
46
47 #ifdef HAVE_PROTOBUF
48-#include "caffe.pb.h"
49
50 #include <iostream>
51 #include <fstream>
52diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
53index 0f46ea77df9a..1d3c518f1328 100644
54--- a/modules/dnn/src/caffe/caffe_io.cpp
55+++ b/modules/dnn/src/caffe/caffe_io.cpp
56@@ -99,7 +99,6 @@
57 #include <fstream>
58 #include <vector>
59
60-#include "caffe.pb.h"
61 #include "caffe_io.hpp"
62 #include "glog_emulator.hpp"
63
64diff --git a/modules/dnn/src/caffe/caffe_io.hpp b/modules/dnn/src/caffe/caffe_io.hpp
65index 09bc5709a24e..f5912c3bcec1 100644
66--- a/modules/dnn/src/caffe/caffe_io.hpp
67+++ b/modules/dnn/src/caffe/caffe_io.hpp
68@@ -91,7 +91,7 @@
69 #define __OPENCV_DNN_CAFFE_IO_HPP__
70 #ifdef HAVE_PROTOBUF
71
72-#include "caffe.pb.h"
73+#include "opencv-caffe.pb.h"
74
75 namespace cv {
76 namespace dnn {
77diff --git a/modules/dnn/src/caffe/caffe.proto b/modules/dnn/src/caffe/opencv-caffe.proto
78similarity index 100%
79rename from modules/dnn/src/caffe/caffe.proto
80rename to modules/dnn/src/caffe/opencv-caffe.proto
81diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp
82index 0b72326f7e7d..f413bad5b81a 100644
83--- a/modules/dnn/src/layers/detection_output_layer.cpp
84+++ b/modules/dnn/src/layers/detection_output_layer.cpp
85@@ -44,7 +44,7 @@
86 #include "layers_common.hpp"
87 #include <float.h>
88 #include <string>
89-#include <caffe.pb.h>
90+#include <opencv-caffe.pb.h>
91
92 namespace cv
93 {
94diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp
95index 2c977c84b0f4..a1827a381117 100644
96--- a/modules/dnn/src/caffe/caffe_importer.cpp
97+++ b/modules/dnn/src/caffe/caffe_importer.cpp
98@@ -78,8 +78,8 @@ static cv::String toString(const T &v)
99
100 class CaffeImporter : public Importer
101 {
102- caffe::NetParameter net;
103- caffe::NetParameter netBinary;
104+ opencvcaffe::NetParameter net;
105+ opencvcaffe::NetParameter netBinary;
106
107 public:
108
109@@ -197,7 +197,7 @@ public:
110 }
111 }
112
113- void blobShapeFromProto(const caffe::BlobProto &pbBlob, MatShape& shape)
114+ void blobShapeFromProto(const opencvcaffe::BlobProto &pbBlob, MatShape& shape)
115 {
116 shape.clear();
117 if (pbBlob.has_num() || pbBlob.has_channels() || pbBlob.has_height() || pbBlob.has_width())
118@@ -209,7 +209,7 @@ public:
119 }
120 else if (pbBlob.has_shape())
121 {
122- const caffe::BlobShape &_shape = pbBlob.shape();
123+ const opencvcaffe::BlobShape &_shape = pbBlob.shape();
124
125 for (int i = 0; i < _shape.dim_size(); i++)
126 shape.push_back((int)_shape.dim(i));
127@@ -218,7 +218,7 @@ public:
128 CV_Error(Error::StsError, "Unknown shape of input blob");
129 }
130
131- void blobFromProto(const caffe::BlobProto &pbBlob, cv::Mat &dstBlob)
132+ void blobFromProto(const opencvcaffe::BlobProto &pbBlob, cv::Mat &dstBlob)
133 {
134 MatShape shape;
135 blobShapeFromProto(pbBlob, shape);
136@@ -233,7 +233,7 @@ public:
137 dstData[i] = pbBlob.data(i);
138 }
139
140- void extractBinaryLayerParms(const caffe::LayerParameter& layer, LayerParams& layerParams)
141+ void extractBinaryLayerParms(const opencvcaffe::LayerParameter& layer, LayerParams& layerParams)
142 {
143 const std::string &name = layer.name();
144
145@@ -247,7 +247,7 @@ public:
146 if (li == netBinary.layer_size() || netBinary.layer(li).blobs_size() == 0)
147 return;
148
149- const caffe::LayerParameter &binLayer = netBinary.layer(li);
150+ const opencvcaffe::LayerParameter &binLayer = netBinary.layer(li);
151 layerParams.blobs.resize(binLayer.blobs_size());
152 for (int bi = 0; bi < binLayer.blobs_size(); bi++)
153 {
154@@ -289,7 +289,7 @@ public:
155
156 for (int li = 0; li < layersSize; li++)
157 {
158- const caffe::LayerParameter &layer = net.layer(li);
159+ const opencvcaffe::LayerParameter &layer = net.layer(li);
160 String name = layer.name();
161 String type = layer.type();
162 LayerParams layerParams;
163@@ -313,7 +313,7 @@ public:
164 addedBlobs.clear();
165 }
166
167- void addOutput(const caffe::LayerParameter &layer, int layerId, int outNum)
168+ void addOutput(const opencvcaffe::LayerParameter &layer, int layerId, int outNum)
169 {
170 const std::string &name = layer.top(outNum);
171
172diff --git a/modules/dnn/src/caffe/caffe_io.hpp b/modules/dnn/src/caffe/caffe_io.hpp
173index f5912c3bcec1..24cd5fa254eb 100644
174--- a/modules/dnn/src/caffe/caffe_io.hpp
175+++ b/modules/dnn/src/caffe/caffe_io.hpp
176@@ -98,9 +98,9 @@ namespace dnn {
177
178 // Read parameters from a file into a NetParameter proto message.
179 void ReadNetParamsFromTextFileOrDie(const char* param_file,
180- caffe::NetParameter* param);
181+ opencvcaffe::NetParameter* param);
182 void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
183- caffe::NetParameter* param);
184+ opencvcaffe::NetParameter* param);
185
186 }
187 }
188diff --git a/modules/dnn/src/caffe/opencv-caffe.proto b/modules/dnn/src/caffe/opencv-caffe.proto
189index 3d23fb48ea6a..df4e1d3269ae 100644
190--- a/modules/dnn/src/caffe/opencv-caffe.proto
191+++ b/modules/dnn/src/caffe/opencv-caffe.proto
192@@ -48,7 +48,7 @@
193
194 syntax = "proto2";
195
196-package caffe;
197+package opencvcaffe;
198
199 // Specifies the shape (dimensions) of a Blob.
200 message BlobShape {
201diff --git a/modules/dnn/src/layers/detection_output_layer.cpp b/modules/dnn/src/layers/detection_output_layer.cpp
202index f413bad5b81a..832c257eebf9 100644
203--- a/modules/dnn/src/layers/detection_output_layer.cpp
204+++ b/modules/dnn/src/layers/detection_output_layer.cpp
205@@ -72,7 +72,7 @@ public:
206
207 int _backgroundLabelId;
208
209- typedef caffe::PriorBoxParameter_CodeType CodeType;
210+ typedef opencvcaffe::PriorBoxParameter_CodeType CodeType;
211 CodeType _codeType;
212
213 bool _varianceEncodedInTarget;
214@@ -85,7 +85,7 @@ public:
215 enum { _numAxes = 4 };
216 static const std::string _layerName;
217
218- typedef std::map<int, std::vector<caffe::NormalizedBBox> > LabelBBox;
219+ typedef std::map<int, std::vector<opencvcaffe::NormalizedBBox> > LabelBBox;
220
221 bool getParameterDict(const LayerParams &params,
222 const std::string &parameterName,
223@@ -131,11 +131,11 @@ public:
224 {
225 String codeTypeString = params.get<String>("code_type").toLowerCase();
226 if (codeTypeString == "corner")
227- _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
228+ _codeType = opencvcaffe::PriorBoxParameter_CodeType_CORNER;
229 else if (codeTypeString == "center_size")
230- _codeType = caffe::PriorBoxParameter_CodeType_CENTER_SIZE;
231+ _codeType = opencvcaffe::PriorBoxParameter_CodeType_CENTER_SIZE;
232 else
233- _codeType = caffe::PriorBoxParameter_CodeType_CORNER;
234+ _codeType = opencvcaffe::PriorBoxParameter_CodeType_CORNER;
235 }
236
237 DetectionOutputLayerImpl(const LayerParams &params)
238@@ -215,7 +215,7 @@ public:
239 GetConfidenceScores(confidenceData, num, numPriors, _numClasses, allConfidenceScores);
240
241 // Retrieve all prior bboxes
242- std::vector<caffe::NormalizedBBox> priorBBoxes;
243+ std::vector<opencvcaffe::NormalizedBBox> priorBBoxes;
244 std::vector<std::vector<float> > priorVariances;
245 GetPriorBBoxes(priorData, numPriors, priorBBoxes, priorVariances);
246
247@@ -272,7 +272,7 @@ public:
248 for (size_t j = 0; j < indices.size(); ++j, ++count)
249 {
250 int idx = indices[j];
251- const caffe::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
252+ const opencvcaffe::NormalizedBBox& decode_bbox = label_bboxes->second[idx];
253 outputsData[count * 7] = i;
254 outputsData[count * 7 + 1] = label;
255 outputsData[count * 7 + 2] = scores[idx];
256@@ -355,7 +355,7 @@ public:
257
258 // Compute bbox size
259 template<bool normalized>
260- static float BBoxSize(const caffe::NormalizedBBox& bbox)
261+ static float BBoxSize(const opencvcaffe::NormalizedBBox& bbox)
262 {
263 if (bbox.xmax() < bbox.xmin() || bbox.ymax() < bbox.ymin())
264 {
265@@ -388,10 +388,10 @@ public:
266 // Decode a bbox according to a prior bbox
267 template<bool variance_encoded_in_target>
268 static void DecodeBBox(
269- const caffe::NormalizedBBox& prior_bbox, const std::vector<float>& prior_variance,
270+ const opencvcaffe::NormalizedBBox& prior_bbox, const std::vector<float>& prior_variance,
271 const CodeType code_type,
272- const bool clip_bbox, const caffe::NormalizedBBox& bbox,
273- caffe::NormalizedBBox& decode_bbox)
274+ const bool clip_bbox, const opencvcaffe::NormalizedBBox& bbox,
275+ opencvcaffe::NormalizedBBox& decode_bbox)
276 {
277 float bbox_xmin = variance_encoded_in_target ? bbox.xmin() : prior_variance[0] * bbox.xmin();
278 float bbox_ymin = variance_encoded_in_target ? bbox.ymin() : prior_variance[1] * bbox.ymin();
279@@ -399,13 +399,13 @@ public:
280 float bbox_ymax = variance_encoded_in_target ? bbox.ymax() : prior_variance[3] * bbox.ymax();
281 switch(code_type)
282 {
283- case caffe::PriorBoxParameter_CodeType_CORNER:
284+ case opencvcaffe::PriorBoxParameter_CodeType_CORNER:
285 decode_bbox.set_xmin(prior_bbox.xmin() + bbox_xmin);
286 decode_bbox.set_ymin(prior_bbox.ymin() + bbox_ymin);
287 decode_bbox.set_xmax(prior_bbox.xmax() + bbox_xmax);
288 decode_bbox.set_ymax(prior_bbox.ymax() + bbox_ymax);
289 break;
290- case caffe::PriorBoxParameter_CodeType_CENTER_SIZE:
291+ case opencvcaffe::PriorBoxParameter_CodeType_CENTER_SIZE:
292 {
293 float prior_width = prior_bbox.xmax() - prior_bbox.xmin();
294 CV_Assert(prior_width > 0);
295@@ -431,7 +431,7 @@ public:
296 };
297 if (clip_bbox)
298 {
299- // Clip the caffe::NormalizedBBox such that the range for each corner is [0, 1]
300+ // Clip the opencvcaffe::NormalizedBBox such that the range for each corner is [0, 1]
301 decode_bbox.set_xmin(std::max(std::min(decode_bbox.xmin(), 1.f), 0.f));
302 decode_bbox.set_ymin(std::max(std::min(decode_bbox.ymin(), 1.f), 0.f));
303 decode_bbox.set_xmax(std::max(std::min(decode_bbox.xmax(), 1.f), 0.f));
304@@ -443,11 +443,11 @@ public:
305
306 // Decode a set of bboxes according to a set of prior bboxes
307 static void DecodeBBoxes(
308- const std::vector<caffe::NormalizedBBox>& prior_bboxes,
309+ const std::vector<opencvcaffe::NormalizedBBox>& prior_bboxes,
310 const std::vector<std::vector<float> >& prior_variances,
311 const CodeType code_type, const bool variance_encoded_in_target,
312- const bool clip_bbox, const std::vector<caffe::NormalizedBBox>& bboxes,
313- std::vector<caffe::NormalizedBBox>& decode_bboxes)
314+ const bool clip_bbox, const std::vector<opencvcaffe::NormalizedBBox>& bboxes,
315+ std::vector<opencvcaffe::NormalizedBBox>& decode_bboxes)
316 {
317 CV_Assert(prior_bboxes.size() == prior_variances.size());
318 CV_Assert(prior_bboxes.size() == bboxes.size());
319@@ -470,7 +470,7 @@ public:
320
321 // Decode all bboxes in a batch
322 static void DecodeBBoxesAll(const std::vector<LabelBBox>& all_loc_preds,
323- const std::vector<caffe::NormalizedBBox>& prior_bboxes,
324+ const std::vector<opencvcaffe::NormalizedBBox>& prior_bboxes,
325 const std::vector<std::vector<float> >& prior_variances,
326 const int num, const bool share_location,
327 const int num_loc_classes, const int background_label_id,
328@@ -503,10 +503,10 @@ public:
329 // Get prior bounding boxes from prior_data
330 // prior_data: 1 x 2 x num_priors * 4 x 1 blob.
331 // num_priors: number of priors.
332- // prior_bboxes: stores all the prior bboxes in the format of caffe::NormalizedBBox.
333+ // prior_bboxes: stores all the prior bboxes in the format of opencvcaffe::NormalizedBBox.
334 // prior_variances: stores all the variances needed by prior bboxes.
335 static void GetPriorBBoxes(const float* priorData, const int& numPriors,
336- std::vector<caffe::NormalizedBBox>& priorBBoxes,
337+ std::vector<opencvcaffe::NormalizedBBox>& priorBBoxes,
338 std::vector<std::vector<float> >& priorVariances)
339 {
340 priorBBoxes.clear(); priorBBoxes.resize(numPriors);
341@@ -514,7 +514,7 @@ public:
342 for (int i = 0; i < numPriors; ++i)
343 {
344 int startIdx = i * 4;
345- caffe::NormalizedBBox& bbox = priorBBoxes[i];
346+ opencvcaffe::NormalizedBBox& bbox = priorBBoxes[i];
347 bbox.set_xmin(priorData[startIdx]);
348 bbox.set_ymin(priorData[startIdx + 1]);
349 bbox.set_xmax(priorData[startIdx + 2]);
350@@ -565,7 +565,7 @@ public:
351 {
352 labelBBox[label].resize(numPredsPerClass);
353 }
354- caffe::NormalizedBBox& bbox = labelBBox[label][p];
355+ opencvcaffe::NormalizedBBox& bbox = labelBBox[label][p];
356 bbox.set_xmin(locData[startIdx + c * 4]);
357 bbox.set_ymin(locData[startIdx + c * 4 + 1]);
358 bbox.set_xmax(locData[startIdx + c * 4 + 2]);
359@@ -612,7 +612,7 @@ public:
360 // nms_threshold: a threshold used in non maximum suppression.
361 // top_k: if not -1, keep at most top_k picked indices.
362 // indices: the kept indices of bboxes after nms.
363- static void ApplyNMSFast(const std::vector<caffe::NormalizedBBox>& bboxes,
364+ static void ApplyNMSFast(const std::vector<opencvcaffe::NormalizedBBox>& bboxes,
365 const std::vector<float>& scores, const float score_threshold,
366 const float nms_threshold, const float eta, const int top_k,
367 std::vector<int>& indices)
368@@ -674,10 +674,10 @@ public:
369
370 // Compute the jaccard (intersection over union IoU) overlap between two bboxes.
371 template<bool normalized>
372- static float JaccardOverlap(const caffe::NormalizedBBox& bbox1,
373- const caffe::NormalizedBBox& bbox2)
374+ static float JaccardOverlap(const opencvcaffe::NormalizedBBox& bbox1,
375+ const opencvcaffe::NormalizedBBox& bbox2)
376 {
377- caffe::NormalizedBBox intersect_bbox;
378+ opencvcaffe::NormalizedBBox intersect_bbox;
379 if (bbox2.xmin() > bbox1.xmax() || bbox2.xmax() < bbox1.xmin() ||
380 bbox2.ymin() > bbox1.ymax() || bbox2.ymax() < bbox1.ymin())
381 {
382diff --git a/modules/dnn/src/caffe/caffe_io.cpp b/modules/dnn/src/caffe/caffe_io.cpp
383index 1d3c518f1328..3cf6e255aa60 100644
384--- a/modules/dnn/src/caffe/caffe_io.cpp
385+++ b/modules/dnn/src/caffe/caffe_io.cpp
386@@ -107,7 +107,7 @@ namespace dnn {
387
388 using std::string;
389 using std::map;
390-using namespace caffe;
391+using namespace opencvcaffe;
392 using namespace ::google::protobuf;
393 using namespace ::google::protobuf::io;
394
diff --git a/meta-oe/recipes-support/opencv/opencv/fixpkgconfig.patch b/meta-oe/recipes-support/opencv/opencv/fixpkgconfig.patch
index 3aeda7d44..3ed3468d5 100644
--- a/meta-oe/recipes-support/opencv/opencv/fixpkgconfig.patch
+++ b/meta-oe/recipes-support/opencv/opencv/fixpkgconfig.patch
@@ -1,24 +1,25 @@
1diff --git a/cmake/OpenCVGenPkgconfig.cmake b/cmake/OpenCVGenPkgconfig.cmake 1Index: git/cmake/OpenCVGenPkgconfig.cmake
2index b8cb8777c06b..75281ee964fd 100644 2===================================================================
3--- a/cmake/OpenCVGenPkgconfig.cmake 3--- git.orig/cmake/OpenCVGenPkgconfig.cmake
4+++ b/cmake/OpenCVGenPkgconfig.cmake 4+++ git/cmake/OpenCVGenPkgconfig.cmake
5@@ -27,7 +27,7 @@ macro(fix_prefix lst isown) 5@@ -31,7 +31,7 @@ macro(fix_prefix lst isown)
6 get_filename_component(libdir "${item}" PATH) 6 get_filename_component(libdir "${item}" PATH)
7 get_filename_component(libname "${item}" NAME_WE) 7 get_filename_component(_libname "${item}" NAME)
8 string(REGEX REPLACE "^lib(.*)" "\\1" libname "${libname}") 8 ocv_get_libname(libname "${_libname}")
9- list(APPEND _lst "-L${libdir}" "-l${libname}") 9- list(APPEND _lst "-L${libdir}" "-l${libname}")
10+ list(APPEND _lst "-l${libname}") 10+ list(APPEND _lst "-l${libname}")
11 else() 11 else()
12 list(APPEND _lst "-l${item}") 12 list(APPEND _lst "-l${item}")
13 endif() 13 endif()
14@@ -66,10 +66,14 @@ ocv_list_unique(_3rdparty) 14@@ -124,11 +124,14 @@ ocv_list_unique(_extra)
15 ocv_list_unique(_3rdparty)
15 16
16 set(OPENCV_PC_LIBS 17 set(OPENCV_PC_LIBS
17 "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}" 18- "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}"
18+ "-L\${exec_prefix}/${OPENCV_3P_LIB_INSTALL_PATH}" 19+ "-L\${exec_prefix}/${OPENCV_3P_LIB_INSTALL_PATH}"
19 "${_modules}" 20 "${_modules}"
20 ) 21 )
21 if (BUILD_SHARED_LIBS) 22 if(BUILD_SHARED_LIBS)
22- set(OPENCV_PC_LIBS_PRIVATE "${_extra}") 23- set(OPENCV_PC_LIBS_PRIVATE "${_extra}")
23+ set(OPENCV_PC_LIBS_PRIVATE 24+ set(OPENCV_PC_LIBS_PRIVATE
24+ "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}" 25+ "-L\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}"
diff --git a/meta-oe/recipes-support/opencv/opencv/javagen.patch b/meta-oe/recipes-support/opencv/opencv/javagen.patch
deleted file mode 100644
index 56526ecd8..000000000
--- a/meta-oe/recipes-support/opencv/opencv/javagen.patch
+++ /dev/null
@@ -1,16 +0,0 @@
1Upstream-status: Inappropriate [OE specific] https://github.com/opencv/opencv/pull/10039#issuecomment-342539288
2
3Signed-off-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>
4diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt
5index 74bc0ef04169..4622fbf9a5f1 100644
6--- a/modules/java/CMakeLists.txt
7+++ b/modules/java/CMakeLists.txt
8@@ -291,7 +291,7 @@ foreach(java_file ${step3_input_files})
9 endif()
10 if(__configure)
11 configure_file("${java_file}" "${java_src_dir}/${output_name}" @ONLY)
12- elseif(NOT "${java_file}" MATCHES "${OpenCV_BINARY_DIR}/")
13+ elseif(EXISTS "${java_file}" AND NOT "${java_file}" MATCHES "${OpenCV_BINARY_DIR}/")
14 configure_file("${java_file}" "${java_src_dir}/${output_name}" COPYONLY)
15 else()
16 add_custom_command(OUTPUT "${java_src_dir}/${output_name}"
diff --git a/meta-oe/recipes-support/opencv/opencv/protobuf.patch b/meta-oe/recipes-support/opencv/opencv/protobuf.patch
deleted file mode 100644
index c63dc142e..000000000
--- a/meta-oe/recipes-support/opencv/opencv/protobuf.patch
+++ /dev/null
@@ -1,57 +0,0 @@
1Upstream-status: Inappropriate [OE specific]
2
3Signed-off-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>
4diff --git a/cmake/OpenCVFindLibProtobuf.cmake b/cmake/OpenCVFindLibProtobuf.cmake
5index b6ce1e7fd56b..e916ec0df2a6 100644
6--- a/cmake/OpenCVFindLibProtobuf.cmake
7+++ b/cmake/OpenCVFindLibProtobuf.cmake
8@@ -7,21 +7,21 @@ OCV_OPTION(BUILD_PROTOBUF "Force to build libprotobuf from sources" ON)
9 OCV_OPTION(PROTOBUF_UPDATE_FILES "Force to rebuild .proto files" OFF)
10
11 if(PROTOBUF_UPDATE_FILES)
12- if(NOT DEFINED Protobuf_PROTOC_EXECUTABLE)
13+ if(NOT DEFINED PROTOBUF_PROTOC_EXECUTABLE)
14 find_package(Protobuf QUIET)
15 endif()
16- if(DEFINED Protobuf_PROTOC_EXECUTABLE AND EXISTS ${Protobuf_PROTOC_EXECUTABLE})
17- message(STATUS "The protocol buffer compiler is found (${Protobuf_PROTOC_EXECUTABLE})")
18+ if(DEFINED PROTOBUF_PROTOC_EXECUTABLE AND EXISTS ${PROTOBUF_PROTOC_EXECUTABLE})
19+ message(STATUS "The protocol buffer compiler is found (${PROTOBUF_PROTOC_EXECUTABLE})")
20 else()
21- message(FATAL_ERROR "The protocol buffer compiler is not found (Protobuf_PROTOC_EXECUTABLE='${Protobuf_PROTOC_EXECUTABLE}')")
22+ message(FATAL_ERROR "The protocol buffer compiler is not found (PROTOBUF_PROTOC_EXECUTABLE='${PROTOBUF_PROTOC_EXECUTABLE}')")
23 endif()
24 endif()
25
26-if(NOT BUILD_PROTOBUF AND NOT (DEFINED Protobuf_INCLUDE_DIRS AND DEFINED Protobuf_LIBRARIES))
27+if(NOT BUILD_PROTOBUF AND NOT (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF_LIBRARIES))
28 find_package(Protobuf QUIET)
29 endif()
30
31-if(Protobuf_FOUND)
32+if(PROTOBUF_FOUND OR (DEFINED PROTOBUF_INCLUDE_DIR AND DEFINED PROTOBUF_LIBRARIES))
33 # nothing
34 else()
35 set(Protobuf_LIBRARIES libprotobuf)
36diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt
37index 2a71568d1a44..c6329a742263 100644
38--- a/modules/dnn/CMakeLists.txt
39+++ b/modules/dnn/CMakeLists.txt
40@@ -7,7 +7,7 @@ if(DEFINED BUILD_opencv_dnn AND NOT BUILD_opencv_dnn)
41 endif()
42
43 include(${OpenCV_SOURCE_DIR}/cmake/OpenCVFindLibProtobuf.cmake)
44-if(NOT Protobuf_FOUND)
45+if(NOT PROTOBUF_FOUND)
46 ocv_module_disable(opencv_dnn)
47 endif()
48
49@@ -72,7 +72,7 @@ ocv_source_group("Src\\protobuf" FILES ${Protobuf_SRCS} ${Protobuf_HDRS})
50 ocv_module_include_directories(include ${Protobuf_INCLUDE_DIRS})
51
52 ocv_glob_module_sources(${Protobuf_SRCS} ${Protobuf_HDRS} ${CBLAS_H_PROXY_PATH})
53-ocv_create_module(${Protobuf_LIBRARIES} ${LAPACK_LIBRARIES})
54+ocv_create_module(${PROTOBUF_LIBRARIES} ${LAPACK_LIBRARIES})
55 ocv_add_samples()
56 ocv_add_accuracy_tests()
57 ocv_add_perf_tests()
diff --git a/meta-oe/recipes-support/opencv/opencv/tinydnn.patch b/meta-oe/recipes-support/opencv/opencv/tinydnn.patch
deleted file mode 100644
index c433fc312..000000000
--- a/meta-oe/recipes-support/opencv/opencv/tinydnn.patch
+++ /dev/null
@@ -1,34 +0,0 @@
1Upstream-status: Inappropriate [OE specific]
2
3Signed-off-by: Ricardo Ribalda <ricardo.ribalda@gmail.com>
4diff --git a/modules/dnn_modern/CMakeLists.txt b/modules/dnn_modern/CMakeLists.txt
5index 79b64b12160b..ba06a0a163e4 100644
6--- a/modules/dnn_modern/CMakeLists.txt
7+++ b/modules/dnn_modern/CMakeLists.txt
8@@ -15,24 +15,8 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
9 # MODULE REQUIREMENTS
10 # ----------------------------------------------------------------------------
11
12-set(TINY_DNN_CPP_PATH "${OpenCV_BINARY_DIR}/3rdparty/tinydnn")
13-set(TINY_DNN_CPP_ROOT "${TINY_DNN_CPP_PATH}/tiny-dnn-1.0.0a3")
14-ocv_download(FILENAME "v1.0.0a3.tar.gz"
15- HASH "adb1c512e09ca2c7a6faef36f9c53e59"
16- URL
17- "${OPENCV_TINY_DNN_URL}"
18- "$ENV{OPENCV_TINY_DNN_URL}"
19- "https://github.com/tiny-dnn/tiny-dnn/archive/"
20- DESTINATION_DIR "${TINY_DNN_CPP_PATH}"
21- STATUS TINY_DNN_DOWNLOAD_SUCCESS
22- ID "tiny-dnn"
23- UNPACK RELATIVE_URL)
24-
25-if(NOT TINY_DNN_DOWNLOAD_SUCCESS)
26- message(STATUS "Failed to download tiny-dnn sources")
27-endif()
28-
29-find_package(TinyDNN QUIET)
30+set(TINYDNN_INCLUDE_DIRS "${OpenCV_SOURCE_DIR}/3rdparty/tinydnn/tiny-dnn-1.0.0a3")
31+set(TinyDNN_FOUND TRUE)
32
33 include(CheckCXXCompilerFlag)
34 CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
diff --git a/meta-oe/recipes-support/opencv/opencv_3.3.bb b/meta-oe/recipes-support/opencv/opencv_3.4.3.bb
index b697f44d1..5591481b7 100644
--- a/meta-oe/recipes-support/opencv/opencv_3.3.bb
+++ b/meta-oe/recipes-support/opencv/opencv_3.4.3.bb
@@ -3,16 +3,16 @@ HOMEPAGE = "http://opencv.org/"
3SECTION = "libs" 3SECTION = "libs"
4 4
5LICENSE = "BSD-3-Clause" 5LICENSE = "BSD-3-Clause"
6LIC_FILES_CHKSUM = "file://LICENSE;md5=2b2f8752cc5edf504d283107d033f544" 6LIC_FILES_CHKSUM = "file://LICENSE;md5=62d89c5dcb0583609ea919c56be0ee76"
7 7
8ARM_INSTRUCTION_SET_armv4 = "arm" 8ARM_INSTRUCTION_SET_armv4 = "arm"
9ARM_INSTRUCTION_SET_armv5 = "arm" 9ARM_INSTRUCTION_SET_armv5 = "arm"
10 10
11DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp" 11DEPENDS = "libtool swig-native bzip2 zlib glib-2.0 libwebp"
12 12
13SRCREV_opencv = "87c27a074db9f6d9d60513f351daa903606ca370" 13SRCREV_opencv = "b38c50b3d0c31e82294315ec44b54b7ef559ef12"
14SRCREV_contrib = "2a9d1b22ed76eb22fad1a5edf6faf4d05f207b13" 14SRCREV_contrib = "1f6d6f06266e1ef336437ae5404bee1c65d42cda"
15SRCREV_ipp = "a62e20676a60ee0ad6581e217fe7e4bada3b95db" 15SRCREV_ipp = "bdb7bb85f34a8cb0d35e40a81f58da431aa1557a"
16SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26" 16SRCREV_boostdesc = "34e4206aef44d50e6bbcd0ab06354b52e7466d26"
17SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d" 17SRCREV_vgg = "fccf7cd6a4b12079f73bbfb21745f9babcd4eb1d"
18SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59" 18SRC_URI[tinydnn.md5sum] = "adb1c512e09ca2c7a6faef36f9c53e59"
@@ -22,17 +22,17 @@ def ipp_filename(d):
22 import re 22 import re
23 arch = d.getVar('TARGET_ARCH', True) 23 arch = d.getVar('TARGET_ARCH', True)
24 if re.match("i.86$", arch): 24 if re.match("i.86$", arch):
25 return "ippicv_2017u2_lnx_ia32_20170418.tgz" 25 return "ippicv_2017u3_lnx_ia32_general_20180518.tgz"
26 else: 26 else:
27 return "ippicv_2017u2_lnx_intel64_20170418.tgz" 27 return "ippicv_2017u3_lnx_intel64_general_20180518.tgz"
28 28
29def ipp_md5sum(d): 29def ipp_md5sum(d):
30 import re 30 import re
31 arch = d.getVar('TARGET_ARCH', True) 31 arch = d.getVar('TARGET_ARCH', True)
32 if re.match("i.86$", arch): 32 if re.match("i.86$", arch):
33 return "f2cece00d802d4dea86df52ed095257e" 33 return "ea72de74dae3c604eb6348395366e78e"
34 else: 34 else:
35 return "808b791a6eac9ed78d32a7666804320e" 35 return "b7cc351267db2d34b9efa1cd22ff0572"
36 36
37IPP_FILENAME = "${@ipp_filename(d)}" 37IPP_FILENAME = "${@ipp_filename(d)}"
38IPP_MD5 = "${@ipp_md5sum(d)}" 38IPP_MD5 = "${@ipp_md5sum(d)}"
@@ -40,29 +40,18 @@ IPP_MD5 = "${@ipp_md5sum(d)}"
40SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg" 40SRCREV_FORMAT = "opencv_contrib_ipp_boostdesc_vgg"
41SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \ 41SRC_URI = "git://github.com/opencv/opencv.git;name=opencv \
42 git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \ 42 git://github.com/opencv/opencv_contrib.git;destsuffix=contrib;name=contrib \
43 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20170418;destsuffix=ipp;name=ipp \ 43 git://github.com/opencv/opencv_3rdparty.git;branch=ippicv/master_20180518;destsuffix=ipp;name=ipp \
44 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \ 44 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_boostdesc_20161012;destsuffix=boostdesc;name=boostdesc \
45 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \ 45 git://github.com/opencv/opencv_3rdparty.git;branch=contrib_xfeatures2d_vgg_20160317;destsuffix=vgg;name=vgg \
46 https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz;destsuffix=git/3rdparty/tinydnn/tiny-dnn-1.0.0a3;name=tinydnn;unpack=false \ 46 https://github.com/tiny-dnn/tiny-dnn/archive/v1.0.0a3.tar.gz;destsuffix=git/3rdparty/tinydnn/tiny-dnn-1.0.0a3;name=tinydnn;unpack=false \
47 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \ 47 file://0001-3rdparty-ippicv-Use-pre-downloaded-ipp.patch \
48 file://fixpkgconfig.patch \
49 file://uselocalxfeatures.patch;patchdir=../contrib/ \ 48 file://uselocalxfeatures.patch;patchdir=../contrib/ \
50 file://tinydnn.patch;patchdir=../contrib/ \
51 file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \ 49 file://0002-Make-opencv-ts-create-share-library-intead-of-static.patch \
52 file://0003-To-fix-errors-as-following.patch \ 50 file://0003-To-fix-errors-as-following.patch \
53 file://0001-build-workaround-GCC-7.1.1-compilation-issue-with-sa.patch \ 51 file://fixpkgconfig.patch \
54 file://0002-imgcodecs-refactoring-improve-code-quality.patch \
55 file://0003-imgproc-test-add-checks-for-remove-call.patch \
56 file://0001-Dont-use-isystem.patch \
57 file://0001-carotene-don-t-use-__asm__-with-aarch64.patch \
58 file://0002-Do-not-enable-asm-with-clang.patch \
59 file://CVE-2017-14136.patch \
60 file://javagen.patch \
61 file://protobuf.patch \
62 file://already-exists.patch \
63 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \ 52 file://0001-Temporarliy-work-around-deprecated-ffmpeg-RAW-functi.patch \
64" 53"
65PV = "3.3+git${SRCPV}" 54PV = "3.4.3+git${SRCPV}"
66 55
67S = "${WORKDIR}/git" 56S = "${WORKDIR}/git"
68 57
@@ -77,6 +66,7 @@ addtask unpack_extra after do_unpack before do_patch
77 66
78EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \ 67EXTRA_OECMAKE = "-DOPENCV_EXTRA_MODULES_PATH=${WORKDIR}/contrib/modules \
79 -DWITH_1394=OFF \ 68 -DWITH_1394=OFF \
69 -DENABLE_PRECOMPILED_HEADERS=OFF \
80 -DCMAKE_SKIP_RPATH=ON \ 70 -DCMAKE_SKIP_RPATH=ON \
81 -DOPENCV_ICV_HASH=${IPP_MD5} \ 71 -DOPENCV_ICV_HASH=${IPP_MD5} \
82 -DIPPROOT=${WORKDIR}/ippicv_lnx \ 72 -DIPPROOT=${WORKDIR}/ippicv_lnx \
@@ -196,9 +186,4 @@ do_install_append() {
196 mv ${D}/usr/lib/* ${D}/${libdir}/ 186 mv ${D}/usr/lib/* ${D}/${libdir}/
197 rm -rf ${D}/usr/lib 187 rm -rf ${D}/usr/lib
198 fi 188 fi
199
200 if ${@bb.utils.contains("PACKAGECONFIG", "samples", "true", "false", d)}; then
201 install -d ${D}${datadir}/OpenCV/samples/bin/
202 cp -f bin/*-tutorial-* bin/*-example-* ${D}${datadir}/OpenCV/samples/bin/
203 fi
204} 189}