1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Fixed several warnings produced by clang 6 and static analyzers

This commit is contained in:
Maksim Shabunin
2017-12-25 16:57:40 +03:00
parent cbb21f3cf2
commit 8b87c4b96a
10 changed files with 64 additions and 71 deletions
+38 -46
View File
@@ -2135,13 +2135,38 @@ static bool ocl_dft_cols(InputArray _src, OutputArray _dst, int nonzero_cols, in
return plan->enqueueTransform(_src, _dst, nonzero_cols, flags, fftType, false);
}
inline FftType determineFFTType(bool real_input, bool complex_input, bool real_output, bool complex_output, bool inv)
{
// output format is not specified
if (!real_output && !complex_output)
complex_output = true;
// input or output format is ambiguous
if (real_input == complex_input || real_output == complex_output)
CV_Error(Error::StsBadArg, "Invalid FFT input or output format");
FftType result = real_input ? (real_output ? R2R : R2C) : (real_output ? C2R : C2C);
// Forward Complex to CCS not supported
if (result == C2R && !inv)
result = C2C;
// Inverse CCS to Complex not supported
if (result == R2C && inv)
result = R2R;
return result;
}
static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_rows)
{
int type = _src.type(), cn = CV_MAT_CN(type), depth = CV_MAT_DEPTH(type);
Size ssize = _src.size();
bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0;
if ( !((cn == 1 || cn == 2) && (depth == CV_32F || (depth == CV_64F && doubleSupport))) )
if (!(cn == 1 || cn == 2)
|| !(depth == CV_32F || (depth == CV_64F && doubleSupport))
|| ((flags & DFT_REAL_OUTPUT) && (flags & DFT_COMPLEX_OUTPUT)))
return false;
// if is not a multiplication of prime numbers { 2, 3, 5 }
@@ -2149,34 +2174,14 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_ro
return false;
UMat src = _src.getUMat();
int complex_input = cn == 2 ? 1 : 0;
int complex_output = (flags & DFT_COMPLEX_OUTPUT) != 0;
int real_input = cn == 1 ? 1 : 0;
int real_output = (flags & DFT_REAL_OUTPUT) != 0;
bool inv = (flags & DFT_INVERSE) != 0 ? 1 : 0;
if( nonzero_rows <= 0 || nonzero_rows > _src.rows() )
nonzero_rows = _src.rows();
bool is1d = (flags & DFT_ROWS) != 0 || nonzero_rows == 1;
// if output format is not specified
if (complex_output + real_output == 0)
{
if (real_input)
real_output = 1;
else
complex_output = 1;
}
FftType fftType = (FftType)(complex_input << 0 | complex_output << 1);
// Forward Complex to CCS not supported
if (fftType == C2R && !inv)
fftType = C2C;
// Inverse CCS to Complex not supported
if (fftType == R2C && inv)
fftType = R2R;
FftType fftType = determineFFTType(cn == 1, cn == 2,
(flags & DFT_REAL_OUTPUT) != 0, (flags & DFT_COMPLEX_OUTPUT) != 0, inv);
UMat output;
if (fftType == C2C || fftType == R2C)
@@ -2200,51 +2205,38 @@ static bool ocl_dft(InputArray _src, OutputArray _dst, int flags, int nonzero_ro
}
}
bool result = false;
if (!inv)
{
if (!ocl_dft_rows(src, output, nonzero_rows, flags, fftType))
return false;
int nonzero_cols = fftType == R2R ? output.cols/2 + 1 : output.cols;
result = ocl_dft_rows(src, output, nonzero_rows, flags, fftType);
if (!is1d)
{
int nonzero_cols = fftType == R2R ? output.cols/2 + 1 : output.cols;
if (!ocl_dft_cols(output, _dst, nonzero_cols, flags, fftType))
return false;
}
result = result && ocl_dft_cols(output, _dst, nonzero_cols, flags, fftType);
}
else
{
if (fftType == C2C)
{
// complex output
if (!ocl_dft_rows(src, output, nonzero_rows, flags, fftType))
return false;
result = ocl_dft_rows(src, output, nonzero_rows, flags, fftType);
if (!is1d)
{
if (!ocl_dft_cols(output, output, output.cols, flags, fftType))
return false;
}
result = result && ocl_dft_cols(output, output, output.cols, flags, fftType);
}
else
{
if (is1d)
{
if (!ocl_dft_rows(src, output, nonzero_rows, flags, fftType))
return false;
result = ocl_dft_rows(src, output, nonzero_rows, flags, fftType);
}
else
{
int nonzero_cols = src.cols/2 + 1;
if (!ocl_dft_cols(src, output, nonzero_cols, flags, fftType))
return false;
if (!ocl_dft_rows(output, _dst, nonzero_rows, flags, fftType))
return false;
result = ocl_dft_cols(src, output, nonzero_cols, flags, fftType);
result = result && ocl_dft_rows(output, _dst, nonzero_rows, flags, fftType);
}
}
}
return true;
return result;
}
} // namespace cv;