From fcdbe162527609ace078e1a9b626f1e6b40a72af Mon Sep 17 00:00:00 2001 From: Rostislav Vasilikhin Date: Fri, 16 Dec 2016 23:00:55 +0300 Subject: [PATCH] openvx_cvt disabled for Khronos, fixed sstep and dstep usage --- modules/core/src/convert.cpp | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 158003332a83..e04d89ef2713 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -4644,31 +4644,50 @@ static bool _openvx_cvt(const T* src, size_t sstep, { using namespace ivx; - if(!(continuousSize.width > 0 && continuousSize.height > 0 && sstep > 0 && dstep > 0)) + if(!(continuousSize.width > 0 && continuousSize.height > 0)) { return true; } - CV_Assert(sstep / sizeof(T) == dstep / sizeof(DT)); - //.height is for number of continuous pieces //.width is for length of one piece Size imgSize = continuousSize; if(continuousSize.height == 1) { - //continuous case - imgSize.width = sstep / sizeof(T); - imgSize.height = continuousSize.width / (sstep / sizeof(T)); + if(sstep / sizeof(T) == dstep / sizeof(DT) && sstep / sizeof(T) > 0 && + continuousSize.width % (sstep / sizeof(T)) == 0) + { + //continuous n-lines image + imgSize.width = sstep / sizeof(T); + imgSize.height = continuousSize.width / (sstep / sizeof(T)); + } + else + { + //1-row image with possibly incorrect step + sstep = continuousSize.width * sizeof(T); + dstep = continuousSize.width * sizeof(DT); + } } + int srcType = DataType::type, dstType = DataType
::type; + try { Context context = Context::create(); - Image srcImage = Image::createFromHandle(context, Image::matTypeToFormat(DataType::type), + + // Other conversions are marked as "experimental" + if(context.vendorID() == VX_ID_KHRONOS && + !(srcType == CV_8U && dstType == CV_16S) && + !(srcType == CV_16S && dstType == CV_8U)) + { + return false; + } + + Image srcImage = Image::createFromHandle(context, Image::matTypeToFormat(srcType), Image::createAddressing(imgSize.width, imgSize.height, (vx_uint32)sizeof(T), (vx_uint32)sstep), (void*)src); - Image dstImage = Image::createFromHandle(context, Image::matTypeToFormat(DataType
::type), + Image dstImage = Image::createFromHandle(context, Image::matTypeToFormat(dstType), Image::createAddressing(imgSize.width, imgSize.height, (vx_uint32)sizeof(DT), (vx_uint32)dstep), (void*)dst);