Skip to content

Commit ab429d2

Browse files
committed
test: fix inplace in 'mulComplex' from test_dxt
1 parent 21f3531 commit ab429d2

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

modules/core/test/test_dxt.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,6 @@ static void fixCCS( Mat& mat, int cols, int flags )
419419
}
420420
}
421421

422-
#if defined _MSC_VER && _MSC_VER >= 1700
423-
#pragma optimize("", off)
424-
#endif
425422
static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
426423
{
427424
dst.create(src1.rows, src1.cols, src1.type());
@@ -430,12 +427,27 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
430427
CV_Assert( src1.size == src2.size && src1.type() == src2.type() &&
431428
(src1.type() == CV_32FC2 || src1.type() == CV_64FC2) );
432429

430+
const Mat* src1_ = &src1;
431+
Mat src1_tmp;
432+
if (dst.data == src1.data)
433+
{
434+
src1_tmp = src1.clone();
435+
src1_ = &src1_tmp;
436+
}
437+
const Mat* src2_ = &src2;
438+
Mat src2_tmp;
439+
if (dst.data == src2.data)
440+
{
441+
src2_tmp = src2.clone();
442+
src2_ = &src2_tmp;
443+
}
444+
433445
for( i = 0; i < dst.rows; i++ )
434446
{
435447
if( depth == CV_32F )
436448
{
437-
const float* a = src1.ptr<float>(i);
438-
const float* b = src2.ptr<float>(i);
449+
const float* a = src1_->ptr<float>(i);
450+
const float* b = src2_->ptr<float>(i);
439451
float* c = dst.ptr<float>(i);
440452

441453
if( !(flags & CV_DXT_MUL_CONJ) )
@@ -459,8 +471,8 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
459471
}
460472
else
461473
{
462-
const double* a = src1.ptr<double>(i);
463-
const double* b = src2.ptr<double>(i);
474+
const double* a = src1_->ptr<double>(i);
475+
const double* b = src2_->ptr<double>(i);
464476
double* c = dst.ptr<double>(i);
465477

466478
if( !(flags & CV_DXT_MUL_CONJ) )
@@ -484,9 +496,6 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
484496
}
485497
}
486498
}
487-
#if defined _MSC_VER && _MSC_VER >= 1700
488-
#pragma optimize("", on)
489-
#endif
490499

491500
}
492501

0 commit comments

Comments
 (0)