1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Compare commits

...

16 Commits

Author SHA1 Message Date
Alexander Alekhin c3d60a6cac imgcodecs: add runtime checks to validate input
original commits: f9b1dbe2ac
2022-02-15 19:45:13 +03:00
Maksim Shabunin 7b92f3ce32 Update filters in ONNX tests 2022-02-15 12:06:04 +03:00
Trutnev Aleksei d385e24967 GAPI: Replace resize perf test to imgproc
* resize + test configs

* fluid kernel "add"

* Add fluid core

(cherry picked from commit 9cab808c5d)
2022-02-03 16:41:44 +00:00
Maksim Shabunin de139a32d5 Option to enable/disable plugin linking with OpenCV 2022-02-01 14:56:09 +03:00
Alexander Alekhin 3abed8efd5 core(persistence): avoid NULL pointer dereference
original commit: 5ba9a089e1
2022-01-18 10:30:36 +00:00
Anna Khakimova 0c1db4574a GAPI Fluid: Resize Linear U8C3 - reworking horizontal pass.
* Reworked horizontal pass

* Fixed valgrind issue and removed unnesesary snippet

original commit: 60228d30d1
2022-01-14 12:53:11 +00:00
Maksim Shabunin 82396d15a6 Fixed issues found by static analysis
original commit: d5f73f89d8
2022-01-13 17:49:47 +00:00
Dmitry Budnikov 822dab00b5 Adapt remote inference to operate with NV12 blobs
* Media Frame Adapter support

* address comments

original commit: 19bbe6c67d
2022-01-13 04:50:05 +00:00
Alexander Alekhin fb570b0172 dnn: don't use aligned load without alignment checks
- weights are unaligned in dasiamprn sample (comes from numpy)

original commit: 80d9f624d0
2022-01-13 04:50:05 +00:00
Aleksei Trutnev b1d3edad73 fix rounding
original commit: e9c46f38fc
2022-01-13 04:50:05 +00:00
Harvey a39e5fd9e4 tiff need check TIFFTAG_SAMPLEFORMAT, should not always use unsigned.
original commit: c3e27bcf87
2022-01-13 04:50:05 +00:00
Alexander Alekhin 09f8dbce28 videoio(msmf): use info message in SourceReaderCB destructor
original commit: 05dbaf7672
2022-01-13 04:50:05 +00:00
Alexander Alekhin 0309d957ae copyright: 2022
original commit: 6e4d61c1fd
2022-01-13 04:50:05 +00:00
Stefano Allegretti 899cc881a1 Fix 21366
original commit: c685293297
2022-01-13 04:50:05 +00:00
Alexander Alekhin a4fda9c12d dnn(ocl): fix fp16 kernel compilation
original commit: 76fb3652fc
2022-01-13 04:50:05 +00:00
Alexander Alekhin 3ab4435b40 OpenCV version '-openvino' 2022-01-13 04:50:05 +00:00
25 changed files with 459 additions and 524 deletions
+4 -4
View File
@@ -1,11 +1,11 @@
Copyright (C) 2000-2021, Intel Corporation, all rights reserved. Copyright (C) 2000-2022, Intel Corporation, all rights reserved.
Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved. Copyright (C) 2009-2016, NVIDIA Corporation, all rights reserved.
Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved. Copyright (C) 2010-2013, Advanced Micro Devices, Inc., all rights reserved.
Copyright (C) 2015-2021, OpenCV Foundation, all rights reserved. Copyright (C) 2015-2022, OpenCV Foundation, all rights reserved.
Copyright (C) 2008-2016, Itseez Inc., all rights reserved. Copyright (C) 2008-2016, Itseez Inc., all rights reserved.
Copyright (C) 2019-2021, Xperience AI, all rights reserved. Copyright (C) 2019-2022, Xperience AI, all rights reserved.
Copyright (C) 2019-2021, Shenzhen Institute of Artificial Intelligence and Copyright (C) 2019-2022, Shenzhen Institute of Artificial Intelligence and
Robotics for Society, all rights reserved. Robotics for Society, all rights reserved.
Third party copyrights are property of their respective owners. Third party copyrights are property of their respective owners.
+11 -4
View File
@@ -78,10 +78,17 @@ function(ocv_create_plugin module default_name dependency_target dependency_targ
set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES PREFIX "${OPENCV_PLUGIN_MODULE_PREFIX}") set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES PREFIX "${OPENCV_PLUGIN_MODULE_PREFIX}")
endif() endif()
if(APPLE) if(WIN32 OR NOT APPLE)
set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") set(OPENCV_PLUGIN_NO_LINK FALSE CACHE BOOL "")
elseif(WIN32) else()
# Hack for Windows only, Linux/MacOS uses global symbol table (without exact .so binding) set(OPENCV_PLUGIN_NO_LINK TRUE CACHE BOOL "")
endif()
if(OPENCV_PLUGIN_NO_LINK)
if(APPLE)
set_target_properties(${OPENCV_PLUGIN_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
endif()
else()
find_package(OpenCV REQUIRED ${module} ${OPENCV_PLUGIN_DEPS}) find_package(OpenCV REQUIRED ${module} ${OPENCV_PLUGIN_DEPS})
target_link_libraries(${OPENCV_PLUGIN_NAME} PRIVATE ${OpenCV_LIBRARIES}) target_link_libraries(${OPENCV_PLUGIN_NAME} PRIVATE ${OpenCV_LIBRARIES})
endif() endif()
@@ -8,7 +8,7 @@
#define CV_VERSION_MAJOR 4 #define CV_VERSION_MAJOR 4
#define CV_VERSION_MINOR 5 #define CV_VERSION_MINOR 5
#define CV_VERSION_REVISION 5 #define CV_VERSION_REVISION 5
#define CV_VERSION_STATUS "" #define CV_VERSION_STATUS "-openvino"
#define CVAUX_STR_EXP(__A) #__A #define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A) #define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
+36 -24
View File
@@ -9,6 +9,8 @@
#include <unordered_map> #include <unordered_map>
#include <iterator> #include <iterator>
#include <opencv2/core/utils/logger.hpp>
namespace cv namespace cv
{ {
@@ -499,21 +501,29 @@ bool FileStorage::Impl::open(const char *filename_or_buf, int _flags, const char
if (!isGZ) { if (!isGZ) {
file = fopen(filename.c_str(), !write_mode ? "rt" : !append ? "wt" : "a+t"); file = fopen(filename.c_str(), !write_mode ? "rt" : !append ? "wt" : "a+t");
if (!file) if (!file)
{
CV_LOG_ERROR(NULL, "Can't open file: '" << filename << "' in " << (!write_mode ? "read" : !append ? "write" : "append") << " mode");
return false; return false;
}
} else { } else {
#if USE_ZLIB #if USE_ZLIB
char mode[] = {write_mode ? 'w' : 'r', 'b', compression ? compression : '3', '\0'}; char mode[] = {write_mode ? 'w' : 'r', 'b', compression ? compression : '3', '\0'};
gzfile = gzopen(filename.c_str(), mode); gzfile = gzopen(filename.c_str(), mode);
if (!gzfile) if (!gzfile)
{
CV_LOG_ERROR(NULL, "Can't open archive: '" << filename << "' mode=" << mode);
return false; return false;
}
#else #else
CV_Error(cv::Error::StsNotImplemented, "There is no compressed file storage support in this configuration"); CV_Error(cv::Error::StsNotImplemented, "There is no compressed file storage support in this configuration");
#endif #endif
} }
} }
// FIXIT release() must do that, use CV_Assert() here instead
roots.clear(); roots.clear();
fs_data.clear(); fs_data.clear();
wrap_margin = 71; wrap_margin = 71;
fmt = FileStorage::FORMAT_AUTO; fmt = FileStorage::FORMAT_AUTO;
@@ -616,14 +626,14 @@ bool FileStorage::Impl::open(const char *filename_or_buf, int _flags, const char
puts("\n"); puts("\n");
} }
emitter = createXMLEmitter(this); emitter_do_not_use_direct_dereference = createXMLEmitter(this);
} else if (fmt == FileStorage::FORMAT_YAML) { } else if (fmt == FileStorage::FORMAT_YAML) {
if (!append) if (!append)
puts("%YAML:1.0\n---\n"); puts("%YAML:1.0\n---\n");
else else
puts("...\n---\n"); puts("...\n---\n");
emitter = createYAMLEmitter(this); emitter_do_not_use_direct_dereference = createYAMLEmitter(this);
} else { } else {
CV_Assert(fmt == FileStorage::FORMAT_JSON); CV_Assert(fmt == FileStorage::FORMAT_JSON);
if (!append) if (!append)
@@ -653,7 +663,7 @@ bool FileStorage::Impl::open(const char *filename_or_buf, int _flags, const char
} }
} }
write_stack.back().indent = 4; write_stack.back().indent = 4;
emitter = createJSONEmitter(this); emitter_do_not_use_direct_dereference = createJSONEmitter(this);
} }
is_opened = true; is_opened = true;
} else { } else {
@@ -701,20 +711,20 @@ bool FileStorage::Impl::open(const char *filename_or_buf, int _flags, const char
switch (fmt) { switch (fmt) {
case FileStorage::FORMAT_XML: case FileStorage::FORMAT_XML:
parser = createXMLParser(this); parser_do_not_use_direct_dereference = createXMLParser(this);
break; break;
case FileStorage::FORMAT_YAML: case FileStorage::FORMAT_YAML:
parser = createYAMLParser(this); parser_do_not_use_direct_dereference = createYAMLParser(this);
break; break;
case FileStorage::FORMAT_JSON: case FileStorage::FORMAT_JSON:
parser = createJSONParser(this); parser_do_not_use_direct_dereference = createJSONParser(this);
break; break;
default: default:
parser = Ptr<FileStorageParser>(); parser_do_not_use_direct_dereference = Ptr<FileStorageParser>();
} }
if (!parser.empty()) { if (!parser_do_not_use_direct_dereference.empty()) {
ok = parser->parse(ptr); ok = getParser().parse(ptr);
if (ok) { if (ok) {
finalizeCollection(root_nodes); finalizeCollection(root_nodes);
@@ -728,7 +738,9 @@ bool FileStorage::Impl::open(const char *filename_or_buf, int _flags, const char
} }
} }
} }
catch (...) { catch (...)
{
// FIXIT log error message
is_opened = true; is_opened = true;
release(); release();
throw; throw;
@@ -926,7 +938,7 @@ void FileStorage::Impl::endWriteStruct() {
if (fmt == FileStorage::FORMAT_JSON && !FileNode::isFlow(current_struct.flags) && write_stack.size() > 1) if (fmt == FileStorage::FORMAT_JSON && !FileNode::isFlow(current_struct.flags) && write_stack.size() > 1)
current_struct.indent = write_stack[write_stack.size() - 2].indent; current_struct.indent = write_stack[write_stack.size() - 2].indent;
emitter->endWriteStruct(current_struct); getEmitter().endWriteStruct(current_struct);
write_stack.pop_back(); write_stack.pop_back();
if (!write_stack.empty()) if (!write_stack.empty())
@@ -945,7 +957,7 @@ void FileStorage::Impl::startWriteStruct_helper(const char *key, int struct_flag
if (type_name && type_name[0] == '\0') if (type_name && type_name[0] == '\0')
type_name = 0; type_name = 0;
FStructData s = emitter->startWriteStruct(write_stack.back(), key, struct_flags, type_name); FStructData s = getEmitter().startWriteStruct(write_stack.back(), key, struct_flags, type_name);
write_stack.push_back(s); write_stack.push_back(s);
size_t write_stack_size = write_stack.size(); size_t write_stack_size = write_stack.size();
@@ -956,7 +968,7 @@ void FileStorage::Impl::startWriteStruct_helper(const char *key, int struct_flag
flush(); flush();
if (fmt == FileStorage::FORMAT_JSON && type_name && type_name[0] && FileNode::isMap(struct_flags)) { if (fmt == FileStorage::FORMAT_JSON && type_name && type_name[0] && FileNode::isMap(struct_flags)) {
emitter->write("type_id", type_name, false); getEmitter().write("type_id", type_name, false);
} }
} }
@@ -997,7 +1009,7 @@ void FileStorage::Impl::startWriteStruct(const char *key, int struct_flags,
void FileStorage::Impl::writeComment(const char *comment, bool eol_comment) { void FileStorage::Impl::writeComment(const char *comment, bool eol_comment) {
CV_Assert(write_mode); CV_Assert(write_mode);
emitter->writeComment(comment, eol_comment); getEmitter().writeComment(comment, eol_comment);
} }
void FileStorage::Impl::startNextStream() { void FileStorage::Impl::startNextStream() {
@@ -1006,7 +1018,7 @@ void FileStorage::Impl::startNextStream() {
while (!write_stack.empty()) while (!write_stack.empty())
endWriteStruct(); endWriteStruct();
flush(); flush();
emitter->startNextStream(); getEmitter().startNextStream();
empty_stream = true; empty_stream = true;
write_stack.push_back(FStructData("", FileNode::EMPTY, 0)); write_stack.push_back(FStructData("", FileNode::EMPTY, 0));
bufofs = 0; bufofs = 0;
@@ -1015,17 +1027,17 @@ void FileStorage::Impl::startNextStream() {
void FileStorage::Impl::write(const String &key, int value) { void FileStorage::Impl::write(const String &key, int value) {
CV_Assert(write_mode); CV_Assert(write_mode);
emitter->write(key.c_str(), value); getEmitter().write(key.c_str(), value);
} }
void FileStorage::Impl::write(const String &key, double value) { void FileStorage::Impl::write(const String &key, double value) {
CV_Assert(write_mode); CV_Assert(write_mode);
emitter->write(key.c_str(), value); getEmitter().write(key.c_str(), value);
} }
void FileStorage::Impl::write(const String &key, const String &value) { void FileStorage::Impl::write(const String &key, const String &value) {
CV_Assert(write_mode); CV_Assert(write_mode);
emitter->write(key.c_str(), value.c_str(), false); getEmitter().write(key.c_str(), value.c_str(), false);
} }
void FileStorage::Impl::writeRawData(const std::string &dt, const void *_data, size_t len) { void FileStorage::Impl::writeRawData(const std::string &dt, const void *_data, size_t len) {
@@ -1111,7 +1123,7 @@ void FileStorage::Impl::writeRawData(const std::string &dt, const void *_data, s
return; return;
} }
emitter->writeScalar(0, ptr); getEmitter().writeScalar(0, ptr);
} }
offset = (int) (data - data0); offset = (int) (data - data0);
@@ -1597,8 +1609,8 @@ FileStorage::Impl::Base64Decoder::Base64Decoder() {
eos = true; eos = true;
} }
void FileStorage::Impl::Base64Decoder::init(Ptr<FileStorageParser> &_parser, char *_ptr, int _indent) { void FileStorage::Impl::Base64Decoder::init(const Ptr<FileStorageParser> &_parser, char *_ptr, int _indent) {
parser = _parser; parser_do_not_use_direct_dereference = _parser;
ptr = _ptr; ptr = _ptr;
indent = _indent; indent = _indent;
encoded.clear(); encoded.clear();
@@ -1641,9 +1653,9 @@ bool FileStorage::Impl::Base64Decoder::readMore(int needed) {
decoded.resize(sz); decoded.resize(sz);
ofs = 0; ofs = 0;
CV_Assert(!parser.empty() && ptr); CV_Assert(ptr);
char *beg = 0, *end = 0; char *beg = 0, *end = 0;
bool ok = parser->getBase64Row(ptr, indent, beg, end); bool ok = getParser().getBase64Row(ptr, indent, beg, end);
ptr = end; ptr = end;
std::copy(beg, end, std::back_inserter(encoded)); std::copy(beg, end, std::back_inserter(encoded));
totalchars += end - beg; totalchars += end - beg;
@@ -1730,7 +1742,7 @@ char *FileStorage::Impl::Base64Decoder::getPtr() const { return ptr; }
char *FileStorage::Impl::parseBase64(char *ptr, int indent, FileNode &collection) { char *FileStorage::Impl::parseBase64(char *ptr, int indent, FileNode &collection) {
const int BASE64_HDR_SIZE = 24; const int BASE64_HDR_SIZE = 24;
char dt[BASE64_HDR_SIZE + 1] = {0}; char dt[BASE64_HDR_SIZE + 1] = {0};
base64decoder.init(parser, ptr, indent); base64decoder.init(parser_do_not_use_direct_dereference, ptr, indent);
int i, k; int i, k;
+23 -5
View File
@@ -139,7 +139,7 @@ public:
{ {
public: public:
Base64Decoder(); Base64Decoder();
void init(Ptr<FileStorageParser>& _parser, char* _ptr, int _indent); void init(const Ptr<FileStorageParser>& _parser, char* _ptr, int _indent);
bool readMore(int needed); bool readMore(int needed);
@@ -155,7 +155,13 @@ public:
char* getPtr() const; char* getPtr() const;
protected: protected:
Ptr<FileStorageParser> parser; Ptr<FileStorageParser> parser_do_not_use_direct_dereference;
FileStorageParser& getParser() const
{
if (!parser_do_not_use_direct_dereference)
CV_Error(Error::StsNullPtr, "Parser is not available");
return *parser_do_not_use_direct_dereference;
}
char* ptr; char* ptr;
int indent; int indent;
std::vector<char> encoded; std::vector<char> encoded;
@@ -205,8 +211,20 @@ public:
std::deque<char> outbuf; std::deque<char> outbuf;
Ptr<FileStorageEmitter> emitter; Ptr<FileStorageEmitter> emitter_do_not_use_direct_dereference;
Ptr<FileStorageParser> parser; FileStorageEmitter& getEmitter()
{
if (!emitter_do_not_use_direct_dereference)
CV_Error(Error::StsNullPtr, "Emitter is not available");
return *emitter_do_not_use_direct_dereference;
}
Ptr<FileStorageParser> parser_do_not_use_direct_dereference;
FileStorageParser& getParser() const
{
if (!parser_do_not_use_direct_dereference)
CV_Error(Error::StsNullPtr, "Parser is not available");
return *parser_do_not_use_direct_dereference;
}
Base64Decoder base64decoder; Base64Decoder base64decoder;
base64::Base64Writer* base64_writer; base64::Base64Writer* base64_writer;
@@ -228,4 +246,4 @@ public:
} }
#endif #endif
+24
View File
@@ -1918,5 +1918,29 @@ TEST(Core_InputOutput, FileStorage_16F_json)
test_20279(fs); test_20279(fs);
} }
TEST(Core_InputOutput, FileStorage_invalid_path_regression_21448_YAML)
{
FileStorage fs("invalid_path/test.yaml", cv::FileStorage::WRITE);
EXPECT_FALSE(fs.isOpened());
EXPECT_ANY_THROW(fs.write("K", 1));
fs.release();
}
TEST(Core_InputOutput, FileStorage_invalid_path_regression_21448_XML)
{
FileStorage fs("invalid_path/test.xml", cv::FileStorage::WRITE);
EXPECT_FALSE(fs.isOpened());
EXPECT_ANY_THROW(fs.write("K", 1));
fs.release();
}
TEST(Core_InputOutput, FileStorage_invalid_path_regression_21448_JSON)
{
FileStorage fs("invalid_path/test.json", cv::FileStorage::WRITE);
EXPECT_FALSE(fs.isOpened());
EXPECT_ANY_THROW(fs.write("K", 1));
fs.release();
}
}} // namespace }} // namespace
+3 -2
View File
@@ -421,7 +421,9 @@ public:
if (!blobs.empty()) if (!blobs.empty())
{ {
Mat wm = blobs[0].reshape(1, numOutput); Mat wm = blobs[0].reshape(1, numOutput);
if( wm.step1() % VEC_ALIGN != 0 ) if ((wm.step1() % VEC_ALIGN != 0) ||
!isAligned<VEC_ALIGN * sizeof(float)>(wm.data)
)
{ {
int newcols = (int)alignSize(wm.step1(), VEC_ALIGN); int newcols = (int)alignSize(wm.step1(), VEC_ALIGN);
Mat wm_buffer = Mat(numOutput, newcols, wm.type()); Mat wm_buffer = Mat(numOutput, newcols, wm.type());
@@ -1660,7 +1662,6 @@ public:
} }
} }
} }
// now compute dot product of the weights // now compute dot product of the weights
// and im2row-transformed part of the tensor // and im2row-transformed part of the tensor
#if CV_TRY_AVX512_SKX #if CV_TRY_AVX512_SKX
@@ -81,6 +81,8 @@ void fastConv( const float* weights, size_t wstep, const float* bias,
int blockSize, int vecsize, int vecsize_aligned, int blockSize, int vecsize, int vecsize_aligned,
const float* relu, bool initOutput ) const float* relu, bool initOutput )
{ {
CV_Assert(isAligned<32>(weights));
int outCn = outShape[1]; int outCn = outShape[1];
size_t outPlaneSize = outShape[2]*outShape[3]; size_t outPlaneSize = outShape[2]*outShape[3];
float r0 = 1.f, r1 = 1.f, r2 = 1.f; float r0 = 1.f, r1 = 1.f, r2 = 1.f;
+11
View File
@@ -1188,6 +1188,7 @@ void ONNXImporter::parseSlice(LayerParams& layerParams, const opencv_onnx::NodeP
CV_Assert(starts.size() == ends.size()); CV_Assert(starts.size() == ends.size());
if (axis > 0) { if (axis > 0) {
CV_CheckLE(axis, 1024, "Slice layer can't have more than 1024 axes"); // arbitrary limit
begin.resize(axis, 0); begin.resize(axis, 0);
end.resize(axis, -1); end.resize(axis, -1);
} }
@@ -1470,6 +1471,13 @@ void ONNXImporter::parseLSTM(LayerParams& layerParams, const opencv_onnx::NodePr
const int numDirs = Wx.size[0]; // Is 1 for forward only and 2 for bidirectional LSTM. const int numDirs = Wx.size[0]; // Is 1 for forward only and 2 for bidirectional LSTM.
const int numFeatures = Wx.size[2]; const int numFeatures = Wx.size[2];
// Following checks are deduced from the IFGO->IGFO loop below
// Wx is numDirs X numHidden*3 X numFeatures
// Wh is numDirs X numHidden*3 X numHidden
CV_CheckLE(numHidden * 3, Wx.size[1], "Wx should have beat least 3x hidden_size in dimension 1");
CV_CheckLE(numHidden * 3, Wh.size[1], "Wh should have be at least 3x hidden_size in dimension 1");
CV_CheckLE(numHidden, Wh.size[2], "Wh should have be at least hidden_size in dimension 2");
Mat h0, c0; Mat h0, c0;
if (!node_proto.input(5).empty()) { if (!node_proto.input(5).empty()) {
h0 = getBlob(node_proto, 5); h0 = getBlob(node_proto, 5);
@@ -1491,6 +1499,9 @@ void ONNXImporter::parseLSTM(LayerParams& layerParams, const opencv_onnx::NodePr
Mat bh = b.colRange(b.cols / 2, b.cols); Mat bh = b.colRange(b.cols / 2, b.cols);
b = bx + bh; b = bx + bh;
// b is numDirs X numHidden*3
CV_CheckLE(numHidden * 3, b.cols, "Bias data should have at least 3x hidden_size columns");
// IFGO->IGFO // IFGO->IGFO
for (int k = 0; k < numDirs; ++k) for (int k = 0; k < numDirs; ++k)
{ {
+2 -2
View File
@@ -278,7 +278,7 @@ __kernel void CeluForward(const int n, __global T* in, __global T* out,
{ {
int index = get_global_id(0); int index = get_global_id(0);
if(index < n) if(index < n)
out[index] = max(0.f, in[index]) + min(0.f, alpha * expm1(in[index] / alpha)); out[index] = max((T)0.f, in[index]) + (T)min(0.f, alpha * expm1(in[index] / alpha));
} }
__kernel void HardSigmoidForward(const int n, __global T* in, __global T* out, __kernel void HardSigmoidForward(const int n, __global T* in, __global T* out,
@@ -287,7 +287,7 @@ __kernel void HardSigmoidForward(const int n, __global T* in, __global T* out,
{ {
int index = get_global_id(0); int index = get_global_id(0);
if(index < n) if(index < n)
out[index] = max(0.f, min(1.f, alpha * in[index] + beta)); out[index] = max((T)0.f, (T)min(1.f, alpha * in[index] + beta));
} }
__kernel void SeluForward(const int n, __global T* in, __global T* out, __kernel void SeluForward(const int n, __global T* in, __global T* out,
@@ -59,6 +59,12 @@ EOF_LABEL:
bool filterApplied = false; bool filterApplied = false;
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) || INF_ENGINE_VER_MAJOR_EQ(2022010000)
#define SKIP_SET_1 1
#else
#define SKIP_SET_1 0
#endif
// Update note: execute <opencv_extra>/testdata/dnn/onnx/generate_conformance_list.py // Update note: execute <opencv_extra>/testdata/dnn/onnx/generate_conformance_list.py
BEGIN_SWITCH() BEGIN_SWITCH()
CASE(test_abs) CASE(test_abs)
@@ -82,11 +88,11 @@ CASE(test_adam_multiple)
CASE(test_add) CASE(test_add)
// no filter // no filter
CASE(test_add_bcast) CASE(test_add_bcast)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_add_uint8) CASE(test_add_uint8)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_and2d) CASE(test_and2d)
@@ -106,131 +112,131 @@ CASE(test_and_bcast4v3d)
CASE(test_and_bcast4v4d) CASE(test_and_bcast4v4d)
// no filter // no filter
CASE(test_argmax_default_axis_example) CASE(test_argmax_default_axis_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_default_axis_example_select_last_index) CASE(test_argmax_default_axis_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_default_axis_random) CASE(test_argmax_default_axis_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_default_axis_random_select_last_index) CASE(test_argmax_default_axis_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_keepdims_example) CASE(test_argmax_keepdims_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_keepdims_example_select_last_index) CASE(test_argmax_keepdims_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_keepdims_random) CASE(test_argmax_keepdims_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_keepdims_random_select_last_index) CASE(test_argmax_keepdims_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_negative_axis_keepdims_example) CASE(test_argmax_negative_axis_keepdims_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_negative_axis_keepdims_example_select_last_index) CASE(test_argmax_negative_axis_keepdims_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_negative_axis_keepdims_random) CASE(test_argmax_negative_axis_keepdims_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_negative_axis_keepdims_random_select_last_index) CASE(test_argmax_negative_axis_keepdims_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_no_keepdims_example) CASE(test_argmax_no_keepdims_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_no_keepdims_example_select_last_index) CASE(test_argmax_no_keepdims_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_no_keepdims_random) CASE(test_argmax_no_keepdims_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmax_no_keepdims_random_select_last_index) CASE(test_argmax_no_keepdims_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_default_axis_example) CASE(test_argmin_default_axis_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_default_axis_example_select_last_index) CASE(test_argmin_default_axis_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_default_axis_random) CASE(test_argmin_default_axis_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_default_axis_random_select_last_index) CASE(test_argmin_default_axis_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_keepdims_example) CASE(test_argmin_keepdims_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_keepdims_example_select_last_index) CASE(test_argmin_keepdims_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_keepdims_random) CASE(test_argmin_keepdims_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_keepdims_random_select_last_index) CASE(test_argmin_keepdims_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_negative_axis_keepdims_example) CASE(test_argmin_negative_axis_keepdims_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_negative_axis_keepdims_example_select_last_index) CASE(test_argmin_negative_axis_keepdims_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_negative_axis_keepdims_random) CASE(test_argmin_negative_axis_keepdims_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_negative_axis_keepdims_random_select_last_index) CASE(test_argmin_negative_axis_keepdims_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_no_keepdims_example) CASE(test_argmin_no_keepdims_example)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_no_keepdims_example_select_last_index) CASE(test_argmin_no_keepdims_example_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_no_keepdims_random) CASE(test_argmin_no_keepdims_random)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_argmin_no_keepdims_random_select_last_index) CASE(test_argmin_no_keepdims_random_select_last_index)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_asin) CASE(test_asin)
@@ -256,11 +262,11 @@ CASE(test_averagepool_2d_ceil)
CASE(test_averagepool_2d_default) CASE(test_averagepool_2d_default)
// no filter // no filter
CASE(test_averagepool_2d_pads) CASE(test_averagepool_2d_pads)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_averagepool_2d_pads_count_include_pad) CASE(test_averagepool_2d_pads_count_include_pad)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_CPU; SKIP_CPU;
// MYRIAD is ok // MYRIAD is ok
SKIP_OPENCL; SKIP_OPENCL;
@@ -269,7 +275,7 @@ CASE(test_averagepool_2d_pads_count_include_pad)
CASE(test_averagepool_2d_precomputed_pads) CASE(test_averagepool_2d_precomputed_pads)
// no filter // no filter
CASE(test_averagepool_2d_precomputed_pads_count_include_pad) CASE(test_averagepool_2d_precomputed_pads_count_include_pad)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_averagepool_2d_precomputed_same_upper) CASE(test_averagepool_2d_precomputed_same_upper)
@@ -277,7 +283,7 @@ CASE(test_averagepool_2d_precomputed_same_upper)
CASE(test_averagepool_2d_precomputed_strides) CASE(test_averagepool_2d_precomputed_strides)
// no filter // no filter
CASE(test_averagepool_2d_same_lower) CASE(test_averagepool_2d_same_lower)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_averagepool_2d_same_upper) CASE(test_averagepool_2d_same_upper)
@@ -287,11 +293,11 @@ CASE(test_averagepool_2d_strides)
CASE(test_averagepool_3d_default) CASE(test_averagepool_3d_default)
// no filter // no filter
CASE(test_basic_conv_with_padding) CASE(test_basic_conv_with_padding)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_basic_conv_without_padding) CASE(test_basic_conv_without_padding)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_basic_convinteger) CASE(test_basic_convinteger)
@@ -349,11 +355,11 @@ CASE(test_cast_FLOAT_to_DOUBLE)
CASE(test_cast_FLOAT_to_FLOAT16) CASE(test_cast_FLOAT_to_FLOAT16)
// no filter // no filter
CASE(test_cast_FLOAT_to_STRING) CASE(test_cast_FLOAT_to_STRING)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_cast_STRING_to_FLOAT) CASE(test_cast_STRING_to_FLOAT)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_castlike_BFLOAT16_to_FLOAT) CASE(test_castlike_BFLOAT16_to_FLOAT)
@@ -391,13 +397,13 @@ CASE(test_castlike_FLOAT_to_FLOAT16_expanded)
CASE(test_castlike_FLOAT_to_STRING) CASE(test_castlike_FLOAT_to_STRING)
// no filter // no filter
CASE(test_castlike_FLOAT_to_STRING_expanded) CASE(test_castlike_FLOAT_to_STRING_expanded)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_castlike_STRING_to_FLOAT) CASE(test_castlike_STRING_to_FLOAT)
// no filter // no filter
CASE(test_castlike_STRING_to_FLOAT_expanded) CASE(test_castlike_STRING_to_FLOAT_expanded)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_ceil) CASE(test_ceil)
@@ -441,7 +447,7 @@ CASE(test_compress_negative_axis)
CASE(test_concat_1d_axis_0) CASE(test_concat_1d_axis_0)
// no filter // no filter
CASE(test_concat_1d_axis_negative_1) CASE(test_concat_1d_axis_negative_1)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_concat_2d_axis_0) CASE(test_concat_2d_axis_0)
@@ -475,19 +481,19 @@ CASE(test_constantofshape_int_shape_zero)
CASE(test_constantofshape_int_zeros) CASE(test_constantofshape_int_zeros)
// no filter // no filter
CASE(test_conv_with_autopad_same) CASE(test_conv_with_autopad_same)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_conv_with_strides_and_asymmetric_padding) CASE(test_conv_with_strides_and_asymmetric_padding)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_conv_with_strides_no_padding) CASE(test_conv_with_strides_no_padding)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_conv_with_strides_padding) CASE(test_conv_with_strides_padding)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_convinteger_with_padding) CASE(test_convinteger_with_padding)
@@ -555,13 +561,13 @@ CASE(test_det_nd)
CASE(test_div) CASE(test_div)
// no filter // no filter
CASE(test_div_bcast) CASE(test_div_bcast)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_div_example) CASE(test_div_example)
// no filter // no filter
CASE(test_div_uint8) CASE(test_div_uint8)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_dropout_default) CASE(test_dropout_default)
@@ -573,7 +579,7 @@ CASE(test_dropout_default_mask_ratio)
CASE(test_dropout_default_old) CASE(test_dropout_default_old)
// no filter // no filter
CASE(test_dropout_default_ratio) CASE(test_dropout_default_ratio)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_dropout_random_old) CASE(test_dropout_random_old)
@@ -697,11 +703,11 @@ CASE(test_globalaveragepool)
CASE(test_globalaveragepool_precomputed) CASE(test_globalaveragepool_precomputed)
// no filter // no filter
CASE(test_globalmaxpool) CASE(test_globalmaxpool)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_globalmaxpool_precomputed) CASE(test_globalmaxpool_precomputed)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_greater) CASE(test_greater)
@@ -811,12 +817,12 @@ CASE(test_log)
CASE(test_log_example) CASE(test_log_example)
// no filter // no filter
CASE(test_logsoftmax_axis_0) CASE(test_logsoftmax_axis_0)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL; SKIP_OPENCL;
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
#endif #endif
CASE(test_logsoftmax_axis_0_expanded) CASE(test_logsoftmax_axis_0_expanded)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL; SKIP_OPENCL;
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
#endif #endif
@@ -829,7 +835,7 @@ CASE(test_logsoftmax_axis_2)
CASE(test_logsoftmax_axis_2_expanded) CASE(test_logsoftmax_axis_2_expanded)
// no filter // no filter
CASE(test_logsoftmax_default_axis) CASE(test_logsoftmax_default_axis)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_logsoftmax_default_axis_expanded) CASE(test_logsoftmax_default_axis_expanded)
@@ -839,12 +845,12 @@ CASE(test_logsoftmax_example_1)
CASE(test_logsoftmax_example_1_expanded) CASE(test_logsoftmax_example_1_expanded)
// no filter // no filter
CASE(test_logsoftmax_large_number) CASE(test_logsoftmax_large_number)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_logsoftmax_large_number_expanded) CASE(test_logsoftmax_large_number_expanded)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
@@ -907,71 +913,71 @@ CASE(test_max_uint64)
CASE(test_max_uint8) CASE(test_max_uint8)
// no filter // no filter
CASE(test_maxpool_1d_default) CASE(test_maxpool_1d_default)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_ceil) CASE(test_maxpool_2d_ceil)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_default) CASE(test_maxpool_2d_default)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_dilations) CASE(test_maxpool_2d_dilations)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_maxpool_2d_pads) CASE(test_maxpool_2d_pads)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_precomputed_pads) CASE(test_maxpool_2d_precomputed_pads)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_precomputed_same_upper) CASE(test_maxpool_2d_precomputed_same_upper)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_precomputed_strides) CASE(test_maxpool_2d_precomputed_strides)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_same_lower) CASE(test_maxpool_2d_same_lower)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_maxpool_2d_same_upper) CASE(test_maxpool_2d_same_upper)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_strides) CASE(test_maxpool_2d_strides)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_maxpool_2d_uint8) CASE(test_maxpool_2d_uint8)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_maxpool_3d_default) CASE(test_maxpool_3d_default)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_NON_CPU; SKIP_NON_CPU;
#endif #endif
CASE(test_maxpool_with_argmax_2d_precomputed_pads) CASE(test_maxpool_with_argmax_2d_precomputed_pads)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_maxpool_with_argmax_2d_precomputed_strides) CASE(test_maxpool_with_argmax_2d_precomputed_strides)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_maxunpool_export_with_output_shape) CASE(test_maxunpool_export_with_output_shape)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_maxunpool_export_without_output_shape) CASE(test_maxunpool_export_without_output_shape)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_mean_example) CASE(test_mean_example)
@@ -1041,13 +1047,13 @@ CASE(test_momentum_multiple)
CASE(test_mul) CASE(test_mul)
// no filter // no filter
CASE(test_mul_bcast) CASE(test_mul_bcast)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_mul_example) CASE(test_mul_example)
// no filter // no filter
CASE(test_mul_uint8) CASE(test_mul_uint8)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_mvn) CASE(test_mvn)
@@ -1717,12 +1723,12 @@ CASE(test_slice_negative_axes)
CASE(test_slice_start_out_of_bounds) CASE(test_slice_start_out_of_bounds)
// no filter // no filter
CASE(test_softmax_axis_0) CASE(test_softmax_axis_0)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL; SKIP_OPENCL;
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
#endif #endif
CASE(test_softmax_axis_0_expanded) CASE(test_softmax_axis_0_expanded)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL; SKIP_OPENCL;
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
#endif #endif
@@ -1735,7 +1741,7 @@ CASE(test_softmax_axis_2)
CASE(test_softmax_axis_2_expanded) CASE(test_softmax_axis_2_expanded)
// no filter // no filter
CASE(test_softmax_default_axis) CASE(test_softmax_default_axis)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_softmax_default_axis_expanded) CASE(test_softmax_default_axis_expanded)
@@ -1745,12 +1751,12 @@ CASE(test_softmax_example)
CASE(test_softmax_example_expanded) CASE(test_softmax_example_expanded)
// no filter // no filter
CASE(test_softmax_large_number) CASE(test_softmax_large_number)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
CASE(test_softmax_large_number_expanded) CASE(test_softmax_large_number_expanded)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
SKIP_MYRIAD; SKIP_MYRIAD;
#endif #endif
@@ -1771,21 +1777,21 @@ CASE(test_spacetodepth)
CASE(test_spacetodepth_example) CASE(test_spacetodepth_example)
// no filter // no filter
CASE(test_split_equal_parts_1d) CASE(test_split_equal_parts_1d)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_CPU; SKIP_CPU;
// MYRIAD is ok // MYRIAD is ok
SKIP_OPENCL; SKIP_OPENCL;
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
#endif #endif
CASE(test_split_equal_parts_2d) CASE(test_split_equal_parts_2d)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_CPU; SKIP_CPU;
// MYRIAD is ok // MYRIAD is ok
SKIP_OPENCL; SKIP_OPENCL;
SKIP_OPENCL_FP16; SKIP_OPENCL_FP16;
#endif #endif
CASE(test_split_equal_parts_default_axis) CASE(test_split_equal_parts_default_axis)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP_CPU; SKIP_CPU;
// MYRIAD is ok // MYRIAD is ok
SKIP_OPENCL; SKIP_OPENCL;
@@ -1822,13 +1828,13 @@ CASE(test_strnormalizer_nostopwords_nochangecase)
CASE(test_sub) CASE(test_sub)
// no filter // no filter
CASE(test_sub_bcast) CASE(test_sub_bcast)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_sub_example) CASE(test_sub_example)
// no filter // no filter
CASE(test_sub_uint8) CASE(test_sub_uint8)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_sum_example) CASE(test_sum_example)
@@ -1964,7 +1970,7 @@ CASE(test_unsqueeze_two_axes)
CASE(test_unsqueeze_unsorted_axes) CASE(test_unsqueeze_unsorted_axes)
// no filter // no filter
CASE(test_upsample_nearest) CASE(test_upsample_nearest)
#if INF_ENGINE_VER_MAJOR_EQ(2021040000) #if SKIP_SET_1
SKIP; SKIP;
#endif #endif
CASE(test_where_example) CASE(test_where_example)
+2 -2
View File
@@ -406,8 +406,8 @@ namespace core {
} }
else else
{ {
int outSz_w = static_cast<int>(round(in.size.width * fx)); int outSz_w = saturate_cast<int>(in.size.width * fx);
int outSz_h = static_cast<int>(round(in.size.height * fy)); int outSz_h = saturate_cast<int>(in.size.height * fy);
GAPI_Assert(outSz_w > 0 && outSz_h > 0); GAPI_Assert(outSz_w > 0 && outSz_h > 0);
return in.withSize(Size(outSz_w, outSz_h)); return in.withSize(Size(outSz_w, outSz_h));
} }
@@ -2333,8 +2333,8 @@ PERF_TEST_P_(ResizeFxFyPerfTest, TestPerformance)
MatType type = -1; MatType type = -1;
int interp = 1; int interp = 1;
cv::Size sz; cv::Size sz;
double fx = 0.0; double fx = 1.0;
double fy = 0.0; double fy = 1.0;
cv::GCompileArgs compile_args; cv::GCompileArgs compile_args;
std::tie(cmpF, type, interp, sz, fx, fy, compile_args) = GetParam(); std::tie(cmpF, type, interp, sz, fx, fy, compile_args) = GetParam();
@@ -2342,7 +2342,7 @@ PERF_TEST_P_(ResizeFxFyPerfTest, TestPerformance)
cv::Scalar mean = cv::Scalar::all(127); cv::Scalar mean = cv::Scalar::all(127);
cv::Scalar stddev = cv::Scalar::all(40.f); cv::Scalar stddev = cv::Scalar::all(40.f);
cv::randn(in_mat1, mean, stddev); cv::randn(in_mat1, mean, stddev);
cv::Size sz_out = cv::Size(saturate_cast<int>(sz.width *fx), saturate_cast<int>(sz.height*fy)); cv::Size sz_out = cv::Size(saturate_cast<int>(sz.width*fx), saturate_cast<int>(sz.height*fy));
out_mat_gapi = cv::Mat(sz_out, type); out_mat_gapi = cv::Mat(sz_out, type);
out_mat_ocv = cv::Mat(sz_out, type); out_mat_ocv = cv::Mat(sz_out, type);
@@ -49,8 +49,8 @@ INSTANTIATE_TEST_CASE_P(SubPerfTestFluid, SubPerfTest,
INSTANTIATE_TEST_CASE_P(SubCPerfTestFluid, SubCPerfTest, INSTANTIATE_TEST_CASE_P(SubCPerfTestFluid, SubCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()), Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p), Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1), Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F), Values(-1, CV_8U, CV_16U, CV_16S, CV_32F),
Values(cv::compile_args(CORE_FLUID)))); Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(SubRCPerfTestFluid, SubRCPerfTest, INSTANTIATE_TEST_CASE_P(SubRCPerfTestFluid, SubRCPerfTest,
@@ -78,8 +78,8 @@ INSTANTIATE_TEST_CASE_P(MulDoublePerfTestFluid, MulDoublePerfTest,
INSTANTIATE_TEST_CASE_P(MulCPerfTestFluid, MulCPerfTest, INSTANTIATE_TEST_CASE_P(MulCPerfTestFluid, MulCPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()), Combine(Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p), Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_8UC3, CV_16SC1, CV_32FC1), Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(-1, CV_8U, CV_32F), Values(-1, CV_8U, CV_16U, CV_16S, CV_32F),
Values(cv::compile_args(CORE_FLUID)))); Values(cv::compile_args(CORE_FLUID))));
INSTANTIATE_TEST_CASE_P(DivPerfTestFluid, DivPerfTest, INSTANTIATE_TEST_CASE_P(DivPerfTestFluid, DivPerfTest,
@@ -342,7 +342,7 @@ INSTANTIATE_TEST_CASE_P(BottleneckKernelsPerfTestFluid, BottleneckKernelsConstIn
Combine(Values(AbsSimilarPoints(0, 1).to_compare_f()), Combine(Values(AbsSimilarPoints(0, 1).to_compare_f()),
Values("cv/optflow/frames/1080p_00.png", "cv/optflow/frames/720p_00.png", Values("cv/optflow/frames/1080p_00.png", "cv/optflow/frames/720p_00.png",
"cv/optflow/frames/VGA_00.png", "cv/dnn_face/recognition/Aaron_Tippin_0001.jpg"), "cv/optflow/frames/VGA_00.png", "cv/dnn_face/recognition/Aaron_Tippin_0001.jpg"),
Values(cv::compile_args(CORE_FLUID, IMGPROC_FLUID)))); Values(cv::compile_args(cv::gapi::combine(IMGPROC_FLUID, CORE_FLUID)))));
INSTANTIATE_TEST_CASE_P(ResizeInSimpleGraphPerfTestFluid, ResizeInSimpleGraphPerfTest, INSTANTIATE_TEST_CASE_P(ResizeInSimpleGraphPerfTestFluid, ResizeInSimpleGraphPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()), Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
@@ -350,14 +350,14 @@ INSTANTIATE_TEST_CASE_P(ResizeInSimpleGraphPerfTestFluid, ResizeInSimpleGraphPer
Values(szSmall128, szVGA, sz720p, sz1080p), Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5), Values(0.5),
Values(0.5), Values(0.5),
Values(cv::compile_args(CORE_FLUID, IMGPROC_FLUID)))); Values(cv::compile_args(cv::gapi::combine(IMGPROC_FLUID, CORE_FLUID)))));
INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestFluid, ResizeFxFyPerfTest, INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestFluid, ResizeFxFyPerfTest,
Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()), Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(CV_8UC3), Values(CV_8UC3),
Values(cv::INTER_LINEAR), Values(cv::INTER_LINEAR),
Values(szSmall128, szVGA, sz720p, sz1080p), Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5, 0.1), Values(0.5, 0.25, 2),
Values(0.5, 0.1), Values(0.5, 0.25, 2),
Values(cv::compile_args(CORE_FLUID)))); Values(cv::compile_args(CORE_FLUID))));
} // opencv_test } // opencv_test
@@ -320,8 +320,8 @@ INSTANTIATE_TEST_CASE_P(TransposePerfTestGPU, TransposePerfTest,
Combine(Values(AbsExact().to_compare_f()), Combine(Values(AbsExact().to_compare_f()),
Values(szSmall128, szVGA, sz720p, sz1080p), Values(szSmall128, szVGA, sz720p, sz1080p),
Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1, Values(CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1,
CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2, CV_8UC2, CV_16UC2, CV_16SC2, CV_32FC2,
CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3), CV_8UC3, CV_16UC3, CV_16SC3, CV_32FC3),
Values(cv::compile_args(CORE_GPU)))); Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ResizePerfTestGPU, ResizePerfTest, INSTANTIATE_TEST_CASE_P(ResizePerfTestGPU, ResizePerfTest,
@@ -330,14 +330,14 @@ INSTANTIATE_TEST_CASE_P(ResizePerfTestGPU, ResizePerfTest,
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values( szSmall128, szVGA, sz720p, sz1080p ), Values( szSmall128, szVGA, sz720p, sz1080p ),
Values(cv::Size(64,64), Values(cv::Size(64,64),
cv::Size(30,30)), cv::Size(30,30)),
Values(cv::compile_args(CORE_GPU)))); Values(cv::compile_args(CORE_GPU))));
INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestGPU, ResizeFxFyPerfTest, INSTANTIATE_TEST_CASE_P(ResizeFxFyPerfTestGPU, ResizeFxFyPerfTest,
Combine(Values(AbsSimilarPoints(2, 0.05).to_compare_f()), Combine(Values(Tolerance_FloatRel_IntAbs(1e-5, 1).to_compare_f()),
Values(CV_8UC1, CV_16UC1, CV_16SC1), Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA), Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values( szSmall128, szVGA, sz720p, sz1080p ), Values(szSmall128, szVGA, sz720p, sz1080p),
Values(0.5, 0.1), Values(0.5, 0.1),
Values(0.5, 0.1), Values(0.5, 0.1),
Values(cv::compile_args(CORE_GPU)))); Values(cv::compile_args(CORE_GPU))));
+1 -1
View File
@@ -36,7 +36,7 @@ cv::MediaFrame::IAdapter* cv::MediaFrame::getAdapter() const {
} }
void cv::MediaFrame::serialize(cv::gapi::s11n::IOStream& os) const { void cv::MediaFrame::serialize(cv::gapi::s11n::IOStream& os) const {
return m->adapter->serialize(os); m->adapter->serialize(os);
} }
cv::MediaFrame::View::View(Ptrs&& ptrs, Strides&& strs, Callback &&cb) cv::MediaFrame::View::View(Ptrs&& ptrs, Strides&& strs, Callback &&cb)
@@ -2952,14 +2952,13 @@ static void calcRowLinearC(const cv::gapi::fluid::View & in,
dst[l] = out.OutLine<T>(l); dst[l] = out.OutLine<T>(l);
} }
#if 0 // Disabling SSE4.1 path due to Valgrind issues: https://github.com/opencv/opencv/issues/21097
#if CV_SSE4_1 #if CV_SSE4_1
const auto* clone = scr.clone; const auto* clone = scr.clone;
auto* tmp = scr.tmp; auto* tmp = scr.tmp;
if (inSz.width >= 16 && outSz.width >= 16) if (inSz.width >= 16 && outSz.width >= 16)
{ {
sse42::calcRowLinear_8UC_Impl_<numChan>(reinterpret_cast<uint8_t**>(dst), sse41::calcRowLinear_8UC_Impl_<numChan>(reinterpret_cast<uint8_t**>(dst),
reinterpret_cast<const uint8_t**>(src0), reinterpret_cast<const uint8_t**>(src0),
reinterpret_cast<const uint8_t**>(src1), reinterpret_cast<const uint8_t**>(src1),
reinterpret_cast<const short*>(alpha), reinterpret_cast<const short*>(alpha),
@@ -2972,7 +2971,6 @@ static void calcRowLinearC(const cv::gapi::fluid::View & in,
return; return;
} }
#endif // CV_SSE4_1 #endif // CV_SSE4_1
#endif
int length = out.length(); int length = out.length();
for (int l = 0; l < lpi; l++) { for (int l = 0; l < lpi; l++) {
constexpr static const auto unity = Mapper::unity; constexpr static const auto unity = Mapper::unity;
@@ -28,7 +28,7 @@
namespace cv { namespace cv {
namespace gapi { namespace gapi {
namespace fluid { namespace fluid {
namespace sse42 { namespace sse41 {
CV_ALWAYS_INLINE void v_gather_pixel_map(v_uint8x16& vec, const uchar src[], const short* index, const int pos) CV_ALWAYS_INLINE void v_gather_pixel_map(v_uint8x16& vec, const uchar src[], const short* index, const int pos)
{ {
@@ -216,8 +216,8 @@ CV_ALWAYS_INLINE void calcRowLinear_8UC_Impl_<3>(uint8_t* dst[],
const int lpi) { const int lpi) {
bool xRatioEq = inSz.width == outSz.width; bool xRatioEq = inSz.width == outSz.width;
bool yRatioEq = inSz.height == outSz.height; bool yRatioEq = inSz.height == outSz.height;
constexpr int nlanes = 16; constexpr int nlanes = 16; // number of 8-bit integers that fit into a 128-bit SIMD vector.
constexpr int half_nlanes = 16 / 2; constexpr int half_nlanes = nlanes / 2;
constexpr int chanNum = 3; constexpr int chanNum = 3;
if (!xRatioEq && !yRatioEq) { if (!xRatioEq && !yRatioEq) {
@@ -298,84 +298,31 @@ CV_ALWAYS_INLINE void calcRowLinear_8UC_Impl_<3>(uint8_t* dst[],
// horizontal pass // horizontal pass
__m128i horizontal_shuf_mask = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15); __m128i horizontal_shuf_mask = _mm_setr_epi8(0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15);
__m128i horizontal_shuf_mask1 = _mm_setr_epi8(0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 3, 7, 11, 15);
for (int x = 0; outSz.width >= nlanes; ) constexpr int nproc_pixels = 5;
for (int x = 0; ; )
{ {
for (; x <= outSz.width - nlanes; x += nlanes) for (; x <= outSz.width - (nproc_pixels + 1); x += nproc_pixels)
{ {
#ifdef _WIN64 #ifdef _MSC_VER
__m128i a00 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * x]), *reinterpret_cast<const int64_t*>(&clone[4 * x])); __m128i a00 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * x]), *reinterpret_cast<const int64_t*>(&clone[4 * x]));
__m128i a01 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * x]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]));
__m128i a11 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]));
__m128i a22 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]));
__m128i a23 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]));
__m128i a33 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]));
__m128i a44 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]));
__m128i a45 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 5)]));
__m128i a55 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 5)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 5)]));
__m128i a66 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 6)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 6)]));
__m128i a67 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 6)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 7)]));
__m128i a77 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 7)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 7)]));
__m128i a88 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 8)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 8)]));
__m128i a89 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 8)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 9)]));
__m128i a99 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 9)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 9)]));
__m128i a1010 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 10)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 10)]));
__m128i a1011 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 10)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 11)]));
__m128i a1111 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 11)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 11)]));
__m128i a1212 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 12)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 12)]));
__m128i a1213 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 12)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 13)]));
__m128i a1313 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 13)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 13)]));
__m128i a1414 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 14)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 14)]));
__m128i a1415 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 14)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 15)]));
__m128i a1515 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 15)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 15)]));
#else #else
__m128i a00 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * x]), *reinterpret_cast<const __m64*>(&clone[4 * x])); __m128i a00 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * x]), *reinterpret_cast<const __m64*>(&clone[4 * x]));
__m128i a01 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * x]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]));
__m128i a11 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]));
__m128i a22 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]));
__m128i a23 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]));
__m128i a33 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]));
__m128i a44 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]));
__m128i a45 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 5)]));
__m128i a55 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 5)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 5)]));
__m128i a66 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 6)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 6)]));
__m128i a67 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 6)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 7)]));
__m128i a77 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 7)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 7)]));
__m128i a88 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 8)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 8)]));
__m128i a89 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 8)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 9)]));
__m128i a99 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 9)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 9)]));
__m128i a1010 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 10)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 10)]));
__m128i a1011 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 10)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 11)]));
__m128i a1111 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 11)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 11)]));
__m128i a1212 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 12)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 12)]));
__m128i a1213 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 12)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 13)]));
__m128i a1313 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 13)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 13)]));
__m128i a1414 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 14)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 14)]));
__m128i a1415 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 14)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 15)]));
__m128i a1515 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 15)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 15)]));
#endif #endif
// load 3 channels of first pixel from first pair of 4-couple scope
__m128i pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x])])); __m128i pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x])]));
// insert first channel from next couple of pixels to completely fill the simd vector __m128i pix2 = _mm_setzero_si128();
pix1 = _mm_insert_epi32(pix1, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 1])]), 3); pix2 = _mm_insert_epi64(pix2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x] + 1))]), 0);
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x] + 1)) + 8]), 2);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix2 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 1] + 1))]), 3);
// expand 8-bit data to 16-bit // expand 8-bit data to 16-bit
__m128i val_0 = _mm_unpacklo_epi8(pix1, zero); __m128i val_0 = _mm_unpacklo_epi8(pix1, zero);
__m128i val_1 = _mm_unpacklo_epi8(pix2, zero); __m128i val_1 = _mm_unpacklo_epi8(pix2, zero);
// expand 8-bit data to 16-bit
__m128i val_2 = _mm_unpackhi_epi8(pix1, zero); __m128i val_2 = _mm_unpackhi_epi8(pix1, zero);
__m128i val_3 = _mm_unpackhi_epi8(pix2, zero); __m128i val_3 = _mm_unpackhi_epi8(pix2, zero);
// the main calculations // the main calculations
__m128i t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a00); __m128i t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a00);
__m128i t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a01); __m128i t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a00);
__m128i r0_0 = _mm_add_epi16(val_1, t0_0); __m128i r0_0 = _mm_add_epi16(val_1, t0_0);
__m128i r1_0 = _mm_add_epi16(val_3, t1_0); __m128i r1_0 = _mm_add_epi16(val_3, t1_0);
@@ -384,111 +331,113 @@ CV_ALWAYS_INLINE void calcRowLinear_8UC_Impl_<3>(uint8_t* dst[],
// gather data from the same lines together // gather data from the same lines together
__m128i res1 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask); __m128i res1 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 1] + 1)]), 0), zero); #ifdef _MSC_VER
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 1] + 1) + 1)]), 0), zero); __m128i a11 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 1)]));
#else
__m128i a11 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 1)]));
#endif
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 2])]), 0); pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 1])]));
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 2] + 1))]), 0); pix2 = _mm_insert_epi64(pix2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 1] + 1))]), 0);
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 1] + 1)) + 8]), 2);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_1 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a11);
__m128i t1_1 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a22);
__m128i r0_1 = _mm_add_epi16(val_1, t0_1);
__m128i r1_1 = _mm_add_epi16(val_3, t1_1);
__m128i q0_1 = _mm_packus_epi16(r0_1, r1_1);
__m128i res2 = _mm_shuffle_epi8(q0_1, horizontal_shuf_mask);
__m128i pix7 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 3] - 1) + 2)]));
pix7 = _mm_insert_epi32(pix7, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 2] + 2)]), 0);
__m128i pix8 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 3] + 2)]));
pix8 = _mm_insert_epi32(pix8, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 2] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix7, zero);
val_1 = _mm_unpacklo_epi8(pix8, zero);
val_2 = _mm_unpackhi_epi8(pix7, zero);
val_3 = _mm_unpackhi_epi8(pix8, zero);
// the main calculations
__m128i t0_2 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a23);
__m128i t1_2 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a33);
__m128i r0_2 = _mm_add_epi16(val_1, t0_2);
__m128i r1_2 = _mm_add_epi16(val_3, t1_2);
// pack 16-bit data to 8-bit
__m128i q0_2 = _mm_packus_epi16(r0_2, r1_2);
__m128i res3 = _mm_shuffle_epi8(q0_2, horizontal_shuf_mask);
__m128i pix9 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 4])]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix9 = _mm_insert_epi32(pix9, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 5])]), 3);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix10 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 4] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix10 = _mm_insert_epi32(pix10, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 5] + 1))]), 3);
// expand 8-bit data to 16-bit // expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix9, zero); val_0 = _mm_unpacklo_epi8(pix1, zero);
val_1 = _mm_unpacklo_epi8(pix10, zero); val_1 = _mm_unpacklo_epi8(pix2, zero);
val_2 = _mm_unpackhi_epi8(pix1, zero);
// expand 8-bit data to 16-bit val_3 = _mm_unpackhi_epi8(pix2, zero);
val_2 = _mm_unpackhi_epi8(pix9, zero);
val_3 = _mm_unpackhi_epi8(pix10, zero);
// the main calculations // the main calculations
__m128i t0_3 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a44); t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a11);
__m128i t1_3 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a45); t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a11);
__m128i r0_3 = _mm_add_epi16(val_1, t0_3); r0_0 = _mm_add_epi16(val_1, t0_0);
__m128i r1_3 = _mm_add_epi16(val_3, t1_3); r1_0 = _mm_add_epi16(val_3, t1_0);
// pack 16-bit data to 8-bit // pack 16-bit data to 8-bit
__m128i q0_3 = _mm_packus_epi16(r0_3, r1_3); q0_0 = _mm_packus_epi16(r0_0, r1_0);
// gather data from the same lines together // gather data from the same lines together
__m128i res4 = _mm_shuffle_epi8(q0_3, horizontal_shuf_mask); __m128i res2 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 5] + 1)]), 0), zero); #ifdef _MSC_VER
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 5] + 1) + 1)]), 0), zero); __m128i a22 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 2)]));
#else
__m128i a22 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 2)]));
#endif
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 6])]), 0); pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 2])]));
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 6] + 1))]), 0); pix2 = _mm_insert_epi64(pix2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 2] + 1))]), 0);
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 2] + 1)) + 8]), 2);
val_2 = _mm_unpacklo_epi8(val_2, zero); // expand 8-bit data to 16-bit
val_3 = _mm_unpacklo_epi8(val_3, zero); val_0 = _mm_unpacklo_epi8(pix1, zero);
val_1 = _mm_unpacklo_epi8(pix2, zero);
__m128i t0_4 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a55); val_2 = _mm_unpackhi_epi8(pix1, zero);
__m128i t1_4 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a66); val_3 = _mm_unpackhi_epi8(pix2, zero);
__m128i r0_4 = _mm_add_epi16(val_1, t0_4);
__m128i r1_4 = _mm_add_epi16(val_3, t1_4);
__m128i q0_4 = _mm_packus_epi16(r0_4, r1_4);
__m128i res5 = _mm_shuffle_epi8(q0_4, horizontal_shuf_mask);
__m128i pix15 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 7] - 1) + 2)]));
pix15 = _mm_insert_epi32(pix15, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 6] + 2)]), 0);
__m128i pix16 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 7] + 2)]));
pix16 = _mm_insert_epi32(pix16, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 6] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix15, zero);
val_1 = _mm_unpacklo_epi8(pix16, zero);
val_2 = _mm_unpackhi_epi8(pix15, zero);
val_3 = _mm_unpackhi_epi8(pix16, zero);
// the main calculations // the main calculations
__m128i t0_5 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a67); t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a22);
__m128i t1_5 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a77); t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a22);
__m128i r0_5 = _mm_add_epi16(val_1, t0_5); r0_0 = _mm_add_epi16(val_1, t0_0);
__m128i r1_5 = _mm_add_epi16(val_3, t1_5); r1_0 = _mm_add_epi16(val_3, t1_0);
// pack 16-bit data to 8-bit // pack 16-bit data to 8-bit
__m128i q0_5 = _mm_packus_epi16(r0_5, r1_5); q0_0 = _mm_packus_epi16(r0_0, r1_0);
__m128i res6 = _mm_shuffle_epi8(q0_5, horizontal_shuf_mask); // gather data from the same lines together
__m128i res3 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask);
#ifdef _MSC_VER
__m128i a33 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 3)]));
#else
__m128i a33 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 3)]));
#endif
pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 3])]));
pix2 = _mm_insert_epi64(pix2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 3] + 1))]), 0);
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 3] + 1)) + 8]), 2);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix1, zero);
val_1 = _mm_unpacklo_epi8(pix2, zero);
val_2 = _mm_unpackhi_epi8(pix1, zero);
val_3 = _mm_unpackhi_epi8(pix2, zero);
// the main calculations
t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a33);
t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a33);
r0_0 = _mm_add_epi16(val_1, t0_0);
r1_0 = _mm_add_epi16(val_3, t1_0);
// pack 16-bit data to 8-bit
q0_0 = _mm_packus_epi16(r0_0, r1_0);
// gather data from the same lines together
__m128i res4 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask);
#ifdef _MSC_VER
__m128i a44 = _mm_setr_epi64x(*reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]), *reinterpret_cast<const int64_t*>(&clone[4 * (x + 4)]));
#else
__m128i a44 = _mm_setr_epi64(*reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]), *reinterpret_cast<const __m64*>(&clone[4 * (x + 4)]));
#endif
pix1 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 4])]));
pix2 = _mm_insert_epi64(pix2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 4] + 1))]), 0);
pix2 = _mm_insert_epi32(pix2, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 4] + 1)) + 8]), 2);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix1, zero);
val_1 = _mm_unpacklo_epi8(pix2, zero);
val_2 = _mm_unpackhi_epi8(pix1, zero);
val_3 = _mm_unpackhi_epi8(pix2, zero);
// the main calculations
t0_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a44);
t1_0 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a44);
r0_0 = _mm_add_epi16(val_1, t0_0);
r1_0 = _mm_add_epi16(val_3, t1_0);
// pack 16-bit data to 8-bit
q0_0 = _mm_packus_epi16(r0_0, r1_0);
// gather data from the same lines together
__m128i res5 = _mm_shuffle_epi8(q0_0, horizontal_shuf_mask);
__m128i bl1 = _mm_blend_epi16(res1, _mm_slli_si128(res2, 4), 0xCC /*0b11001100*/); __m128i bl1 = _mm_blend_epi16(res1, _mm_slli_si128(res2, 4), 0xCC /*0b11001100*/);
__m128i bl2 = _mm_blend_epi16(_mm_srli_si128(res1, 4), res2, 0xCC /*0b11001100*/); __m128i bl2 = _mm_blend_epi16(_mm_srli_si128(res1, 4), res2, 0xCC /*0b11001100*/);
@@ -496,189 +445,47 @@ CV_ALWAYS_INLINE void calcRowLinear_8UC_Impl_<3>(uint8_t* dst[],
__m128i bl3 = _mm_blend_epi16(res3, _mm_slli_si128(res4, 4), 0xCC /*0b11001100*/); __m128i bl3 = _mm_blend_epi16(res3, _mm_slli_si128(res4, 4), 0xCC /*0b11001100*/);
__m128i bl4 = _mm_blend_epi16(_mm_srli_si128(res3, 4), res4, 0xCC /*0b11001100*/); __m128i bl4 = _mm_blend_epi16(_mm_srli_si128(res3, 4), res4, 0xCC /*0b11001100*/);
__m128i bl5 = _mm_blend_epi16(res5, _mm_slli_si128(res6, 4), 0xCC /*0b11001100*/);
__m128i bl6 = _mm_blend_epi16(_mm_srli_si128(res5, 4), res6, 0xCC /*0b11001100*/);
__m128i bl13 = _mm_blend_epi16(bl1, _mm_slli_si128(bl3, 8), 0xF0 /*0b11110000*/); __m128i bl13 = _mm_blend_epi16(bl1, _mm_slli_si128(bl3, 8), 0xF0 /*0b11110000*/);
__m128i bl31 = _mm_blend_epi16(_mm_srli_si128(bl1, 8), bl3, 0xF0 /*0b11110000*/); __m128i bl31 = _mm_blend_epi16(_mm_srli_si128(bl1, 8), bl3, 0xF0 /*0b11110000*/);
__m128i bl24 = _mm_blend_epi16(bl2, _mm_slli_si128(bl4, 8), 0xF0 /*0b11110000*/); __m128i bl24 = _mm_blend_epi16(bl2, _mm_slli_si128(bl4, 8), 0xF0 /*0b11110000*/);
__m128i bl42 = _mm_blend_epi16(_mm_srli_si128(bl2, 8), bl4, 0xF0 /*0b11110000*/); __m128i bl42 = _mm_blend_epi16(_mm_srli_si128(bl2, 8), bl4, 0xF0 /*0b11110000*/);
// load 3 channels of first pixel from first pair of 4-couple scope bl1 = _mm_blend_epi16(_mm_shuffle_epi8(bl13, horizontal_shuf_mask1),
__m128i pix17 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 8])])); _mm_slli_si128(res5, 12), 192 /*0b11000000*/);
// insert first channel from next couple of pixels to completely fill the simd vector bl2 = _mm_blend_epi16(_mm_shuffle_epi8(bl24, horizontal_shuf_mask1),
pix17 = _mm_insert_epi32(pix17, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 9])]), 3); _mm_slli_si128(res5, 8), 192 /*0b11000000*/);
bl3 = _mm_blend_epi16(_mm_shuffle_epi8(bl31, horizontal_shuf_mask1),
_mm_slli_si128(res5, 4), 192 /*0b11000000*/);
bl4 = _mm_blend_epi16(_mm_shuffle_epi8(bl42, horizontal_shuf_mask1),
res5, 192 /*0b11000000*/);
// load 3 channels of neighbor pixel from first pair of 4-couple scope _mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][chanNum * x]), bl1);
__m128i pix18 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 8] + 1))])); _mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][chanNum * x]), bl2);
// insert first channel from next couple of pixels to completely fill the simd vector _mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][chanNum * x]), bl3);
pix18 = _mm_insert_epi32(pix18, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 9] + 1))]), 3); _mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][chanNum * x]), bl4);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix17, zero);
val_1 = _mm_unpacklo_epi8(pix18, zero);
// expand 8-bit data to 16-bit
val_2 = _mm_unpackhi_epi8(pix17, zero);
val_3 = _mm_unpackhi_epi8(pix18, zero);
// the main calculations
__m128i t0_6 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a88);
__m128i t1_6 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a89);
__m128i r0_6 = _mm_add_epi16(val_1, t0_6);
__m128i r1_6 = _mm_add_epi16(val_3, t1_6);
// pack 16-bit data to 8-bit
__m128i q0_6 = _mm_packus_epi16(r0_6, r1_6);
// gather data from the same lines together
__m128i res7 = _mm_shuffle_epi8(q0_6, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 9] + 1)]), 0), zero);
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 9] + 1) + 1)]), 0), zero);
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 10])]), 0);
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 10] + 1))]), 0);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_7 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a99);
__m128i t1_7 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1010);
__m128i r0_7 = _mm_add_epi16(val_1, t0_7);
__m128i r1_7 = _mm_add_epi16(val_3, t1_7);
__m128i q0_7 = _mm_packus_epi16(r0_7, r1_7);
__m128i res8 = _mm_shuffle_epi8(q0_7, horizontal_shuf_mask);
__m128i pix21 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 11] - 1) + 2)]));
pix21 = _mm_insert_epi32(pix21, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 10] + 2)]), 0);
__m128i pix22 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 11] + 2)]));
pix22 = _mm_insert_epi32(pix22, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 10] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix21, zero);
val_1 = _mm_unpacklo_epi8(pix22, zero);
val_2 = _mm_unpackhi_epi8(pix21, zero);
val_3 = _mm_unpackhi_epi8(pix22, zero);
// the main calculations
__m128i t0_8 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1011);
__m128i t1_8 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1111);
__m128i r0_8 = _mm_add_epi16(val_1, t0_8);
__m128i r1_8 = _mm_add_epi16(val_3, t1_8);
// pack 16-bit data to 8-bit
__m128i q0_8 = _mm_packus_epi16(r0_8, r1_8);
__m128i res9 = _mm_shuffle_epi8(q0_8, horizontal_shuf_mask);
__m128i pix23 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 12])]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix23 = _mm_insert_epi32(pix23, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 13])]), 3);
// load 3 channels of neighbor pixel from first pair of 4-couple scope
__m128i pix24 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 12] + 1))]));
// insert first channel from next couple of pixels to completely fill the simd vector
pix24 = _mm_insert_epi32(pix24, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 13] + 1))]), 3);
// expand 8-bit data to 16-bit
val_0 = _mm_unpacklo_epi8(pix23, zero);
val_1 = _mm_unpacklo_epi8(pix24, zero);
// expand 8-bit data to 16-bit
val_2 = _mm_unpackhi_epi8(pix23, zero);
val_3 = _mm_unpackhi_epi8(pix24, zero);
// the main calculations
__m128i t0_9 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1212);
__m128i t1_9 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1213);
__m128i r0_9 = _mm_add_epi16(val_1, t0_9);
__m128i r1_9 = _mm_add_epi16(val_3, t1_9);
// pack 16-bit data to 8-bit
__m128i q0_9 = _mm_packus_epi16(r0_9, r1_9);
// gather data from the same lines together
__m128i res10 = _mm_shuffle_epi8(q0_9, horizontal_shuf_mask);
val_0 = _mm_unpacklo_epi8(_mm_insert_epi64(val_0, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 13] + 1)]), 0), zero);
val_1 = _mm_unpacklo_epi8(_mm_insert_epi64(val_1, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 13] + 1) + 1)]), 0), zero);
val_2 = _mm_insert_epi64(val_2, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * mapsx[x + 14])]), 0);
val_3 = _mm_insert_epi64(val_3, *reinterpret_cast<const int64_t*>(&tmp[4 * (chanNum * (mapsx[x + 14] + 1))]), 0);
val_2 = _mm_unpacklo_epi8(val_2, zero);
val_3 = _mm_unpacklo_epi8(val_3, zero);
__m128i t0_10 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1313);
__m128i t1_10 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1414);
__m128i r0_10 = _mm_add_epi16(val_1, t0_10);
__m128i r1_10 = _mm_add_epi16(val_3, t1_10);
__m128i q0_10 = _mm_packus_epi16(r0_10, r1_10);
__m128i res11 = _mm_shuffle_epi8(q0_10, horizontal_shuf_mask);
__m128i pix27 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * (mapsx[x + 15] - 1) + 2)]));
pix27 = _mm_insert_epi32(pix27, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * mapsx[x + 14] + 2)]), 0);
__m128i pix28 = _mm_lddqu_si128(reinterpret_cast<const __m128i*>(&tmp[4 * (chanNum * mapsx[x + 15] + 2)]));
pix28 = _mm_insert_epi32(pix28, *reinterpret_cast<const int*>(&tmp[4 * (chanNum * (mapsx[x + 14] + 1) + 2)]), 0);
val_0 = _mm_unpacklo_epi8(pix27, zero);
val_1 = _mm_unpacklo_epi8(pix28, zero);
val_2 = _mm_unpackhi_epi8(pix27, zero);
val_3 = _mm_unpackhi_epi8(pix28, zero);
// the main calculations
__m128i t0_11 = _mm_mulhrs_epi16(_mm_sub_epi16(val_0, val_1), a1415);
__m128i t1_11 = _mm_mulhrs_epi16(_mm_sub_epi16(val_2, val_3), a1515);
__m128i r0_11 = _mm_add_epi16(val_1, t0_11);
__m128i r1_11 = _mm_add_epi16(val_3, t1_11);
// pack 16-bit data to 8-bit
__m128i q0_11 = _mm_packus_epi16(r0_11, r1_11);
__m128i res12 = _mm_shuffle_epi8(q0_11, horizontal_shuf_mask);
__m128i bl7 = _mm_blend_epi16(res7, _mm_slli_si128(res8, 4), 0xCC /*0b11001100*/);
__m128i bl8 = _mm_blend_epi16(_mm_srli_si128(res7, 4), res8, 0xCC /*0b11001100*/);
__m128i bl9 = _mm_blend_epi16(res9, _mm_slli_si128(res10, 4), 0xCC /*0b11001100*/);
__m128i bl10 = _mm_blend_epi16(_mm_srli_si128(res9, 4), res10, 0xCC /*0b11001100*/);
__m128i bl11 = _mm_blend_epi16(res11, _mm_slli_si128(res12, 4), 0xCC /*0b11001100*/);
__m128i bl12 = _mm_blend_epi16(_mm_srli_si128(res11, 4), res12, 0xCC /*0b11001100*/);
__m128i bl57 = _mm_blend_epi16(bl5, _mm_slli_si128(bl7, 8), 0xF0 /*0b11110000*/);
__m128i bl75 = _mm_blend_epi16(_mm_srli_si128(bl5, 8), bl7, 0xF0 /*0b11110000*/);
__m128i bl68 = _mm_blend_epi16(bl6, _mm_slli_si128(bl8, 8), 0xF0 /*0b11110000*/);
__m128i bl86 = _mm_blend_epi16(_mm_srli_si128(bl6, 8), bl8, 0xF0 /*0b11110000*/);
__m128i bl911 = _mm_blend_epi16(bl9, _mm_slli_si128(bl11, 8), 0xF0 /*0b11110000*/);
__m128i bl119 = _mm_blend_epi16(_mm_srli_si128(bl9, 8), bl11, 0xF0 /*0b11110000*/);
__m128i bl1012 = _mm_blend_epi16(bl10, _mm_slli_si128(bl12, 8), 0xF0 /*0b11110000*/);
__m128i bl1210 = _mm_blend_epi16(_mm_srli_si128(bl10, 8), bl12, 0xF0 /*0b11110000*/);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][3 * x]), bl13);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][3 * x]), bl24);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][3 * x]), bl31);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][3 * x]), bl42);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][3 * x + 16]), bl57);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][3 * x + 16]), bl68);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][3 * x + 16]), bl75);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][3 * x + 16]), bl86);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[0][3 * x + 32]), bl911);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[1][3 * x + 32]), bl1012);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[2][3 * x + 32]), bl119);
_mm_storeu_si128(reinterpret_cast<__m128i*>(&dst[3][3 * x + 32]), bl1210);
} }
if (x < outSz.width) { for (; x < outSz.width; ++x)
x = outSz.width - nlanes; {
continue; constexpr static const int ONE = 1 << 15;
constexpr static const int half = 1 << 14;
auto alpha0 = alpha[x];
auto alpha1 = saturate_cast<short>(ONE - alpha[x]);
for (int c = 0; c < chanNum; ++c)
{
dst[0][chanNum * x + c] = (tmp[4 * (chanNum * mapsx[x] + c) ] * alpha0 +
tmp[4 * (chanNum * (mapsx[x] + 1) + c) ] * alpha1 + half) >> 15;
dst[1][chanNum * x + c] = (tmp[4 * (chanNum * mapsx[x] + c) + 1] * alpha0 +
tmp[4 * (chanNum * (mapsx[x] + 1) + c) + 1] * alpha1 + half) >> 15;
dst[2][chanNum * x + c] = (tmp[4 * (chanNum * mapsx[x] + c) + 2] * alpha0 +
tmp[4 * (chanNum * (mapsx[x] + 1) + c) + 2] * alpha1 + half) >> 15;
dst[3][chanNum * x + c] = (tmp[4 * (chanNum * mapsx[x] + c) + 3] * alpha0 +
tmp[4 * (chanNum * (mapsx[x] + 1) + c) + 3] * alpha1 + half) >> 15;
}
} }
break; break;
} }
} }
+19 -8
View File
@@ -19,6 +19,8 @@
#include <functional> #include <functional>
#include <unordered_set> #include <unordered_set>
#include <atomic> #include <atomic>
#include <tuple>
#include <ade/util/algorithm.hpp> #include <ade/util/algorithm.hpp>
@@ -507,18 +509,27 @@ inline IE::Blob::Ptr extractRemoteBlob(IECallContext& ctx, std::size_t i) {
cv::util::any any_blob_params = ctx.inFrame(i).blobParams(); cv::util::any any_blob_params = ctx.inFrame(i).blobParams();
auto ie_core = cv::gimpl::ie::wrap::getCore(); auto ie_core = cv::gimpl::ie::wrap::getCore();
using ParamType = std::pair<InferenceEngine::TensorDesc, using ParamType = std::pair<InferenceEngine::TensorDesc, InferenceEngine::ParamMap>;
InferenceEngine::ParamMap>; using NV12ParamType = std::pair<ParamType, ParamType>;
ParamType* blob_params = cv::util::any_cast<ParamType>(&any_blob_params); NV12ParamType* blob_params = cv::util::any_cast<NV12ParamType>(&any_blob_params);
if (blob_params == nullptr) { if (blob_params == nullptr) {
GAPI_Assert(false && "Incorrect type of blobParams: " GAPI_Assert(false && "Incorrect type of blobParams:"
"expected std::pair<InferenceEngine::TensorDesc," "expected std::pair<ParamType, ParamType>,"
"InferenceEngine::ParamMap>"); "with ParamType std::pair<InferenceEngine::TensorDesc,"
"InferenceEngine::ParamMap >>");
} }
return ctx.uu.rctx->CreateBlob(blob_params->first, //The parameters are TensorDesc and ParamMap for both y and uv blobs
blob_params->second); auto y_blob = ctx.uu.rctx->CreateBlob(blob_params->first.first, blob_params->first.second);
auto uv_blob = ctx.uu.rctx->CreateBlob(blob_params->second.first, blob_params->second.second);
#if INF_ENGINE_RELEASE >= 2021010000
return IE::make_shared_blob<IE::NV12Blob>(y_blob, uv_blob);
#else
return IE::make_shared_blob<InferenceEngine::NV12Blob>(y_blob, uv_blob);
#endif
} }
inline IE::Blob::Ptr extractBlob(IECallContext& ctx, inline IE::Blob::Ptr extractBlob(IECallContext& ctx,
@@ -545,7 +545,7 @@ bool Jpeg2KOpjDecoderBase::readHeader()
*/ */
bool hasAlpha = false; bool hasAlpha = false;
const int numcomps = image_->numcomps; const int numcomps = image_->numcomps;
CV_Assert(numcomps >= 1); CV_Check(numcomps, numcomps >= 1 && numcomps <= 4, "Unsupported number of components");
for (int i = 0; i < numcomps; i++) for (int i = 0; i < numcomps; i++)
{ {
const opj_image_comp_t& comp = image_->comps[i]; const opj_image_comp_t& comp = image_->comps[i];
+8
View File
@@ -470,7 +470,11 @@ bool PAMDecoder::readHeader()
selected_fmt = CV_IMWRITE_PAM_FORMAT_GRAYSCALE; selected_fmt = CV_IMWRITE_PAM_FORMAT_GRAYSCALE;
else if (m_channels == 3 && m_maxval < 256) else if (m_channels == 3 && m_maxval < 256)
selected_fmt = CV_IMWRITE_PAM_FORMAT_RGB; selected_fmt = CV_IMWRITE_PAM_FORMAT_RGB;
else
CV_Error(Error::StsError, "Can't determine selected_fmt (IMWRITE_PAM_FORMAT_NULL)");
} }
CV_CheckDepth(m_sampledepth, m_sampledepth == CV_8U || m_sampledepth == CV_16U, "");
CV_Check(m_channels, m_channels >= 1 && m_channels <= 4, "Unsupported number of channels");
m_type = CV_MAKETYPE(m_sampledepth, m_channels); m_type = CV_MAKETYPE(m_sampledepth, m_channels);
m_offset = m_strm.getPos(); m_offset = m_strm.getPos();
@@ -567,6 +571,10 @@ bool PAMDecoder::readData(Mat& img)
FillColorRow1( data, src, m_width, palette ); FillColorRow1( data, src, m_width, palette );
} }
} }
else
{
CV_Error(Error::StsError, cv::format("Unsupported value of target_channels: %d", target_channels));
}
} else { } else {
for (int y = 0; y < m_height; y++, data += imp_stride) for (int y = 0; y < m_height; y++, data += imp_stride)
{ {
+49 -30
View File
@@ -145,8 +145,8 @@ bool TiffDecoder::checkSignature( const String& signature ) const
int TiffDecoder::normalizeChannelsNumber(int channels) const int TiffDecoder::normalizeChannelsNumber(int channels) const
{ {
CV_Assert(channels <= 4); CV_Check(channels, channels >= 1 && channels <= 4, "Unsupported number of channels");
return channels > 4 ? 4 : channels; return channels;
} }
ImageDecoder TiffDecoder::newDecoder() const ImageDecoder TiffDecoder::newDecoder() const
@@ -295,34 +295,53 @@ bool TiffDecoder::readHeader()
(ncn != 1 && ncn != 3 && ncn != 4))) (ncn != 1 && ncn != 3 && ncn != 4)))
bpp = 8; bpp = 8;
uint16 sample_format = SAMPLEFORMAT_UINT;
TIFFGetField(tif, TIFFTAG_SAMPLEFORMAT, &sample_format);
int wanted_channels = normalizeChannelsNumber(ncn); int wanted_channels = normalizeChannelsNumber(ncn);
switch(bpp) switch (bpp)
{ {
case 1: case 1:
m_type = CV_MAKETYPE(CV_8U, !isGrayScale ? wanted_channels : 1); {
result = true; CV_Check((int)sample_format, sample_format == SAMPLEFORMAT_UINT || sample_format == SAMPLEFORMAT_INT, "");
break; int depth = sample_format == SAMPLEFORMAT_INT ? CV_8S : CV_8U;
case 8: m_type = CV_MAKETYPE(depth, !isGrayScale ? wanted_channels : 1);
//Palette color, the value of the component is used as an index into the red, result = true;
//green and blue curves in the ColorMap field to retrieve an RGB triplet that defines the color. break;
if(photometric == PHOTOMETRIC_PALETTE) }
m_type = CV_MAKETYPE(CV_8U, 3); case 8:
else {
m_type = CV_MAKETYPE(CV_8U, !isGrayScale ? wanted_channels : 1); //Palette color, the value of the component is used as an index into the red,
result = true; //green and blue curves in the ColorMap field to retrieve an RGB triplet that defines the color.
break; CV_Check((int)sample_format, sample_format == SAMPLEFORMAT_UINT || sample_format == SAMPLEFORMAT_INT, "");
case 16: int depth = sample_format == SAMPLEFORMAT_INT ? CV_8S : CV_8U;
m_type = CV_MAKETYPE(CV_16U, !isGrayScale ? wanted_channels : 1); if (photometric == PHOTOMETRIC_PALETTE)
result = true; m_type = CV_MAKETYPE(depth, 3);
break; else
case 32: m_type = CV_MAKETYPE(depth, !isGrayScale ? wanted_channels : 1);
m_type = CV_MAKETYPE(CV_32F, wanted_channels); result = true;
result = true; break;
break; }
case 64: case 16:
m_type = CV_MAKETYPE(CV_64F, wanted_channels); {
result = true; CV_Check((int)sample_format, sample_format == SAMPLEFORMAT_UINT || sample_format == SAMPLEFORMAT_INT, "");
break; int depth = sample_format == SAMPLEFORMAT_INT ? CV_16S : CV_16U;
m_type = CV_MAKETYPE(depth, !isGrayScale ? wanted_channels : 1);
result = true;
break;
}
case 32:
{
CV_Check((int)sample_format, sample_format == SAMPLEFORMAT_IEEEFP || sample_format == SAMPLEFORMAT_INT, "");
int depth = sample_format == SAMPLEFORMAT_IEEEFP ? CV_32F : CV_32S;
m_type = CV_MAKETYPE(depth, wanted_channels);
result = true;
break;
}
case 64:
CV_CheckEQ((int)sample_format, SAMPLEFORMAT_IEEEFP, "");
m_type = CV_MAKETYPE(CV_64F, wanted_channels);
result = true;
break;
default: default:
CV_Error(cv::Error::StsError, "Invalid bitsperpixel value read from TIFF header! Must be 1, 8, 16, 32 or 64."); CV_Error(cv::Error::StsError, "Invalid bitsperpixel value read from TIFF header! Must be 1, 8, 16, 32 or 64.");
} }
@@ -432,7 +451,7 @@ bool TiffDecoder::readData( Mat& img )
bool color = img.channels() > 1; bool color = img.channels() > 1;
CV_CheckType(type, depth == CV_8U || depth == CV_16U || depth == CV_32F || depth == CV_64F, ""); CV_CheckType(type, depth == CV_8U || depth == CV_8S || depth == CV_16U || depth == CV_16S || depth == CV_32S || depth == CV_32F || depth == CV_64F, "");
if (m_width && m_height) if (m_width && m_height)
{ {
@@ -649,7 +668,7 @@ bool TiffDecoder::readData( Mat& img )
CV_TIFF_CHECK_CALL((int)TIFFReadEncodedTile(tif, tileidx, buffer, buffer_size) >= 0); CV_TIFF_CHECK_CALL((int)TIFFReadEncodedTile(tif, tileidx, buffer, buffer_size) >= 0);
} }
Mat m_tile(Size(tile_width0, tile_height0), CV_MAKETYPE((dst_bpp == 32) ? CV_32F : CV_64F, ncn), buffer); Mat m_tile(Size(tile_width0, tile_height0), CV_MAKETYPE((dst_bpp == 32) ? (depth == CV_32S ? CV_32S : CV_32F) : CV_64F, ncn), buffer);
Rect roi_tile(0, 0, tile_width, tile_height); Rect roi_tile(0, 0, tile_width, tile_height);
Rect roi_img(x, img_y, tile_width, tile_height); Rect roi_img(x, img_y, tile_width, tile_height);
if (!m_hdr && ncn == 3) if (!m_hdr && ncn == 3)
+3 -3
View File
@@ -1570,7 +1570,7 @@ namespace cv{
#define CONDITION_S img_row[c - 1] > 0 #define CONDITION_S img_row[c - 1] > 0
#define CONDITION_X img_row[c] > 0 #define CONDITION_X img_row[c] > 0
#define ACTION_1 // nothing to do #define ACTION_1 img_labels_row[c] = 0;
#define ACTION_2 img_labels_row[c] = label; \ #define ACTION_2 img_labels_row[c] = label; \
P_[label] = label; \ P_[label] = label; \
label = label + 1; label = label + 1;
@@ -1831,7 +1831,7 @@ namespace cv{
std::vector<LabelT> P_(Plength, 0); std::vector<LabelT> P_(Plength, 0);
LabelT* P = P_.data(); LabelT* P = P_.data();
//P[0] = 0; P[0] = 0;
LabelT lunique = 1; LabelT lunique = 1;
// First scan // First scan
@@ -1851,7 +1851,7 @@ namespace cv{
#define CONDITION_S img_row[c - 1] > 0 #define CONDITION_S img_row[c - 1] > 0
#define CONDITION_X img_row[c] > 0 #define CONDITION_X img_row[c] > 0
#define ACTION_1 // nothing to do #define ACTION_1 img_labels_row[c] = 0;
#define ACTION_2 img_labels_row[c] = lunique; \ #define ACTION_2 img_labels_row[c] = lunique; \
P[lunique] = lunique; \ P[lunique] = lunique; \
lunique = lunique + 1; // new label lunique = lunique + 1; // new label
@@ -789,5 +789,16 @@ TEST(Imgproc_ConnectedComponents, single_column)
} }
TEST(Imgproc_ConnectedComponents, 4conn_regression_21366)
{
Mat src = Mat::zeros(Size(10, 10), CV_8UC1);
{
Mat labels, stats, centroids;
EXPECT_NO_THROW(cv::connectedComponentsWithStats(src, labels, stats, centroids, 4));
}
}
} }
} // namespace } // namespace
+1 -1
View File
@@ -536,7 +536,7 @@ private:
// Destructor is private. Caller should call Release. // Destructor is private. Caller should call Release.
virtual ~SourceReaderCB() virtual ~SourceReaderCB()
{ {
CV_LOG_WARNING(NULL, "terminating async callback"); CV_LOG_INFO(NULL, "terminating async callback");
} }
public: public: