diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 9e690fef2f..f4ca2d7da9 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -329,7 +329,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst, static BinaryFuncC* getMaxTab() { - static BinaryFuncC maxTab[] = + static BinaryFuncC maxTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::max8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max16s), @@ -343,7 +343,7 @@ static BinaryFuncC* getMaxTab() static BinaryFuncC* getMinTab() { - static BinaryFuncC minTab[] = + static BinaryFuncC minTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::min8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::min8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::min16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::min16s), @@ -617,7 +617,9 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, Mat src1 = psrc1->getMat(), src2 = psrc2->getMat(), dst = _dst.getMat(); Size sz = getContinuousSize2D(src1, src2, dst, src1.channels()); - tab[depth1](src1.ptr(), src1.step, src2.ptr(), src2.step, dst.ptr(), dst.step, sz.width, sz.height, usrdata); + BinaryFuncC func = tab[depth1]; + CV_Assert(func); + func(src1.ptr(), src1.step, src2.ptr(), src2.step, dst.ptr(), dst.step, sz.width, sz.height, usrdata); return; } @@ -868,7 +870,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst, static BinaryFuncC* getAddTab() { - static BinaryFuncC addTab[] = + static BinaryFuncC addTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::add8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add16s), @@ -882,7 +884,7 @@ static BinaryFuncC* getAddTab() static BinaryFuncC* getSubTab() { - static BinaryFuncC subTab[] = + static BinaryFuncC subTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub16s), @@ -896,7 +898,7 @@ static BinaryFuncC* getSubTab() static BinaryFuncC* getAbsDiffTab() { - static BinaryFuncC absDiffTab[] = + static BinaryFuncC absDiffTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff16s), @@ -949,7 +951,7 @@ namespace cv static BinaryFuncC* getMulTab() { - static BinaryFuncC mulTab[] = + static BinaryFuncC mulTab[CV_DEPTH_MAX] = { (BinaryFuncC)cv::hal::mul8u, (BinaryFuncC)cv::hal::mul8s, (BinaryFuncC)cv::hal::mul16u, (BinaryFuncC)cv::hal::mul16s, (BinaryFuncC)cv::hal::mul32s, (BinaryFuncC)cv::hal::mul32f, @@ -961,7 +963,7 @@ static BinaryFuncC* getMulTab() static BinaryFuncC* getDivTab() { - static BinaryFuncC divTab[] = + static BinaryFuncC divTab[CV_DEPTH_MAX] = { (BinaryFuncC)cv::hal::div8u, (BinaryFuncC)cv::hal::div8s, (BinaryFuncC)cv::hal::div16u, (BinaryFuncC)cv::hal::div16s, (BinaryFuncC)cv::hal::div32s, (BinaryFuncC)cv::hal::div32f, @@ -973,7 +975,7 @@ static BinaryFuncC* getDivTab() static BinaryFuncC* getRecipTab() { - static BinaryFuncC recipTab[] = + static BinaryFuncC recipTab[CV_DEPTH_MAX] = { (BinaryFuncC)cv::hal::recip8u, (BinaryFuncC)cv::hal::recip8s, (BinaryFuncC)cv::hal::recip16u, (BinaryFuncC)cv::hal::recip16s, (BinaryFuncC)cv::hal::recip32s, (BinaryFuncC)cv::hal::recip32f, @@ -1021,7 +1023,7 @@ UMat UMat::mul(InputArray m, double scale) const static BinaryFuncC* getAddWeightedTab() { - static BinaryFuncC addWeightedTab[] = + static BinaryFuncC addWeightedTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::addWeighted8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::addWeighted8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::addWeighted16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::addWeighted16s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::addWeighted32s), (BinaryFuncC)cv::hal::addWeighted32f, @@ -1052,7 +1054,7 @@ namespace cv static BinaryFuncC getCmpFunc(int depth) { - static BinaryFuncC cmpTab[] = + static BinaryFuncC cmpTab[CV_DEPTH_MAX] = { (BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp8s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp16s), @@ -1588,7 +1590,7 @@ typedef void (*InRangeFunc)( const uchar* src1, size_t step1, const uchar* src2, static InRangeFunc getInRangeFunc(int depth) { - static InRangeFunc inRangeTab[] = + static InRangeFunc inRangeTab[CV_DEPTH_MAX] = { (InRangeFunc)GET_OPTIMIZED(inRange8u), (InRangeFunc)GET_OPTIMIZED(inRange8s), (InRangeFunc)GET_OPTIMIZED(inRange16u), (InRangeFunc)GET_OPTIMIZED(inRange16s), (InRangeFunc)GET_OPTIMIZED(inRange32s), (InRangeFunc)GET_OPTIMIZED(inRange32f), diff --git a/modules/core/src/channels.cpp b/modules/core/src/channels.cpp index efaeb91068..3ee7088a4f 100644 --- a/modules/core/src/channels.cpp +++ b/modules/core/src/channels.cpp @@ -79,7 +79,7 @@ typedef void (*MixChannelsFunc)( const void** src, const int* sdelta, static MixChannelsFunc getMixchFunc(int depth) { - static MixChannelsFunc mixchTab[] = + static MixChannelsFunc mixchTab[CV_DEPTH_MAX] = { mixChannels8u, mixChannels8u, mixChannels16u, mixChannels16u, mixChannels32s, mixChannels32s, @@ -146,6 +146,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons NAryMatIterator it(arrays, ptrs, (int)(nsrcs + ndsts)); int total = (int)it.size, blocksize = std::min(total, (int)((BLOCK_SIZE + esz1-1)/esz1)); MixChannelsFunc func = getMixchFunc(depth); + CV_Assert(func); for( i = 0; i < it.nplanes; i++, ++it ) { diff --git a/modules/core/src/convert.simd.hpp b/modules/core/src/convert.simd.hpp index 524c43a16e..d6c18a70b5 100644 --- a/modules/core/src/convert.simd.hpp +++ b/modules/core/src/convert.simd.hpp @@ -372,7 +372,7 @@ DEF_CPY_FUNC(64s, int64) BinaryFunc getConvertFunc(int sdepth, int ddepth) { - static BinaryFunc cvtTab[][8] = + static BinaryFunc cvtTab[CV_DEPTH_MAX][CV_DEPTH_MAX] = { { (cvt8u), (cvt8s8u), (cvt16u8u), diff --git a/modules/core/src/convert_scale.simd.hpp b/modules/core/src/convert_scale.simd.hpp index ef6aa343e2..b5322ed888 100644 --- a/modules/core/src/convert_scale.simd.hpp +++ b/modules/core/src/convert_scale.simd.hpp @@ -299,7 +299,7 @@ DEF_CVT_SCALE_FUNC(16f, cvt1_32f, hfloat, hfloat, float) BinaryFunc getCvtScaleAbsFunc(int depth) { - static BinaryFunc cvtScaleAbsTab[] = + static BinaryFunc cvtScaleAbsTab[CV_DEPTH_MAX] = { (BinaryFunc)cvtScaleAbs8u, (BinaryFunc)cvtScaleAbs8s8u, (BinaryFunc)cvtScaleAbs16u8u, (BinaryFunc)cvtScaleAbs16s8u, (BinaryFunc)cvtScaleAbs32s8u, (BinaryFunc)cvtScaleAbs32f8u, @@ -311,7 +311,7 @@ BinaryFunc getCvtScaleAbsFunc(int depth) BinaryFunc getConvertScaleFunc(int sdepth, int ddepth) { - static BinaryFunc cvtScaleTab[][8] = + static BinaryFunc cvtScaleTab[CV_DEPTH_MAX][CV_DEPTH_MAX] = { { (BinaryFunc)GET_OPTIMIZED(cvtScale8u), (BinaryFunc)GET_OPTIMIZED(cvtScale8s8u), (BinaryFunc)GET_OPTIMIZED(cvtScale16u8u), diff --git a/modules/core/src/count_non_zero.simd.hpp b/modules/core/src/count_non_zero.simd.hpp index ce7c75aa54..9de616fe8a 100644 --- a/modules/core/src/count_non_zero.simd.hpp +++ b/modules/core/src/count_non_zero.simd.hpp @@ -196,7 +196,7 @@ static int countNonZero64f( const double* src, int len ) CountNonZeroFunc getCountNonZeroTab(int depth) { - static CountNonZeroFunc countNonZeroTab[] = + static CountNonZeroFunc countNonZeroTab[CV_DEPTH_MAX] = { (CountNonZeroFunc)GET_OPTIMIZED(countNonZero8u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero8u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero16u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero16u), diff --git a/modules/core/src/has_non_zero.simd.hpp b/modules/core/src/has_non_zero.simd.hpp index e9f9b683d6..29a1de0113 100644 --- a/modules/core/src/has_non_zero.simd.hpp +++ b/modules/core/src/has_non_zero.simd.hpp @@ -310,7 +310,7 @@ static bool hasNonZero64f( const double* src, size_t len ) HasNonZeroFunc getHasNonZeroTab(int depth) { - static HasNonZeroFunc hasNonZeroTab[] = + static HasNonZeroFunc hasNonZeroTab[CV_DEPTH_MAX] = { (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u), diff --git a/modules/core/src/lut.cpp b/modules/core/src/lut.cpp index cb2b9e7b56..c2464ef498 100644 --- a/modules/core/src/lut.cpp +++ b/modules/core/src/lut.cpp @@ -68,7 +68,7 @@ static void LUT8u_64f( const uchar* src, const double* lut, double* dst, int len typedef void (*LUTFunc)( const uchar* src, const uchar* lut, uchar* dst, int len, int cn, int lutcn ); -static LUTFunc lutTab[] = +static LUTFunc lutTab[CV_DEPTH_MAX] = { (LUTFunc)LUT8u_8u, (LUTFunc)LUT8u_8s, (LUTFunc)LUT8u_16u, (LUTFunc)LUT8u_16s, (LUTFunc)LUT8u_32s, (LUTFunc)LUT8u_32f, (LUTFunc)LUT8u_64f, 0 @@ -330,7 +330,7 @@ public: void operator()( const cv::Range& range ) const CV_OVERRIDE { - CV_DbgAssert(*ok); + CV_Assert(*ok); const int row0 = range.start; const int row1 = range.end; diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index 1aa16aaceb..764d2d9b03 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -1184,7 +1184,7 @@ static void iPow64f(const double* src, double* dst, int len, int power) typedef void (*IPowFunc)( const uchar* src, uchar* dst, int len, int power ); -static IPowFunc ipowTab[] = +static IPowFunc ipowTab[CV_DEPTH_MAX] = { (IPowFunc)iPow8u, (IPowFunc)iPow8s, (IPowFunc)iPow16u, (IPowFunc)iPow16s, (IPowFunc)iPow32s, (IPowFunc)iPow32f, (IPowFunc)iPow64f, 0 diff --git a/modules/core/src/matmul.dispatch.cpp b/modules/core/src/matmul.dispatch.cpp index a72301b4c3..81953265d7 100644 --- a/modules/core/src/matmul.dispatch.cpp +++ b/modules/core/src/matmul.dispatch.cpp @@ -979,7 +979,7 @@ typedef double (*DotProdFunc)(const uchar* src1, const uchar* src2, int len); static DotProdFunc getDotProdFunc(int depth) { - static DotProdFunc dotProdTab[] = + static DotProdFunc dotProdTab[CV_DEPTH_MAX] = { (DotProdFunc)GET_OPTIMIZED(dotProd_8u), (DotProdFunc)GET_OPTIMIZED(dotProd_8s), (DotProdFunc)dotProd_16u, (DotProdFunc)dotProd_16s, diff --git a/modules/core/src/matmul.simd.hpp b/modules/core/src/matmul.simd.hpp index fb0c6ddefe..ce3a48799e 100644 --- a/modules/core/src/matmul.simd.hpp +++ b/modules/core/src/matmul.simd.hpp @@ -1792,7 +1792,7 @@ diagtransform_64f(const double* src, double* dst, const double* m, int len, int TransformFunc getTransformFunc(int depth) { - static TransformFunc transformTab[] = + static TransformFunc transformTab[CV_DEPTH_MAX] = { (TransformFunc)transform_8u, (TransformFunc)transform_8s, (TransformFunc)transform_16u, (TransformFunc)transform_16s, (TransformFunc)transform_32s, (TransformFunc)transform_32f, @@ -1804,7 +1804,7 @@ TransformFunc getTransformFunc(int depth) TransformFunc getDiagTransformFunc(int depth) { - static TransformFunc diagTransformTab[] = + static TransformFunc diagTransformTab[CV_DEPTH_MAX] = { (TransformFunc)diagtransform_8u, (TransformFunc)diagtransform_8s, (TransformFunc)diagtransform_16u, (TransformFunc)diagtransform_16s, (TransformFunc)diagtransform_32s, (TransformFunc)diagtransform_32f, diff --git a/modules/core/src/matrix_operations.cpp b/modules/core/src/matrix_operations.cpp index 8bb8c66e5c..2992f00e73 100644 --- a/modules/core/src/matrix_operations.cpp +++ b/modules/core/src/matrix_operations.cpp @@ -1259,7 +1259,7 @@ void cv::sort( InputArray _src, OutputArray _dst, int flags ) Mat dst = _dst.getMat(); CV_IPP_RUN_FAST(ipp_sort(src, dst, flags)); - static SortFunc tab[] = + static SortFunc tab[CV_DEPTH_MAX] = { sort_, sort_, sort_, sort_, sort_, sort_, sort_, 0 @@ -1284,7 +1284,7 @@ void cv::sortIdx( InputArray _src, OutputArray _dst, int flags ) CV_IPP_RUN_FAST(ipp_sortIdx(src, dst, flags)); - static SortFunc tab[] = + static SortFunc tab[CV_DEPTH_MAX] = { sortIdx_, sortIdx_, sortIdx_, sortIdx_, sortIdx_, sortIdx_, sortIdx_, 0 diff --git a/modules/core/src/matrix_sparse.cpp b/modules/core/src/matrix_sparse.cpp index 7a02e5961d..cfc769e791 100644 --- a/modules/core/src/matrix_sparse.cpp +++ b/modules/core/src/matrix_sparse.cpp @@ -37,7 +37,7 @@ typedef void (*ConvertScaleData)(const void* from, void* to, int cn, double alph static ConvertData getConvertElem(int fromType, int toType) { - static ConvertData tab[][8] = + static ConvertData tab[CV_DEPTH_MAX][CV_DEPTH_MAX] = {{ convertData_, convertData_, convertData_, convertData_, convertData_, convertData_, @@ -82,7 +82,7 @@ static ConvertData getConvertElem(int fromType, int toType) static ConvertScaleData getConvertScaleElem(int fromType, int toType) { - static ConvertScaleData tab[][8] = + static ConvertScaleData tab[CV_DEPTH_MAX][CV_DEPTH_MAX] = {{ convertScaleData_, convertScaleData_, convertScaleData_, convertScaleData_, convertScaleData_, convertScaleData_, @@ -389,6 +389,7 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const if( alpha == 1 ) { ConvertData cvtfunc = getConvertElem(type(), rtype); + CV_Assert(cvtfunc); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); @@ -399,6 +400,7 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const else { ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype); + CV_Assert(cvtfunc); for( size_t i = 0; i < N; i++, ++from ) { const Node* n = from.node(); diff --git a/modules/core/src/mean.simd.hpp b/modules/core/src/mean.simd.hpp index e34293ee38..c6bbc20b89 100644 --- a/modules/core/src/mean.simd.hpp +++ b/modules/core/src/mean.simd.hpp @@ -311,7 +311,7 @@ static int sqsum64f( const double* src, const uchar* mask, double* sum, double* SumSqrFunc getSumSqrFunc(int depth) { CV_INSTRUMENT_REGION(); - static SumSqrFunc sumSqrTab[] = + static SumSqrFunc sumSqrTab[CV_DEPTH_MAX] = { (SumSqrFunc)GET_OPTIMIZED(sqsum8u), (SumSqrFunc)sqsum8s, (SumSqrFunc)sqsum16u, (SumSqrFunc)sqsum16s, (SumSqrFunc)sqsum32s, (SumSqrFunc)GET_OPTIMIZED(sqsum32f), (SumSqrFunc)sqsum64f, 0 diff --git a/modules/core/src/merge.dispatch.cpp b/modules/core/src/merge.dispatch.cpp index abde21e0df..19a62d22b0 100644 --- a/modules/core/src/merge.dispatch.cpp +++ b/modules/core/src/merge.dispatch.cpp @@ -50,7 +50,7 @@ typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn); static MergeFunc getMergeFunc(int depth) { - static MergeFunc mergeTab[] = + static MergeFunc mergeTab[CV_DEPTH_MAX] = { (MergeFunc)GET_OPTIMIZED(cv::hal::merge8u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge8u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), diff --git a/modules/core/src/minmax.cpp b/modules/core/src/minmax.cpp index 8d4d185a54..859fa9e54c 100644 --- a/modules/core/src/minmax.cpp +++ b/modules/core/src/minmax.cpp @@ -834,7 +834,7 @@ typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, s static MinMaxIdxFunc getMinmaxTab(int depth) { - static MinMaxIdxFunc minmaxTab[] = + static MinMaxIdxFunc minmaxTab[CV_DEPTH_MAX] = { (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_8u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_8s), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16s), diff --git a/modules/core/src/rand.cpp b/modules/core/src/rand.cpp index a6301afe34..ee4afd7ef5 100644 --- a/modules/core/src/rand.cpp +++ b/modules/core/src/rand.cpp @@ -215,7 +215,7 @@ static void randf_16f( hfloat* arr, int len, uint64* state, const Vec2f* p, floa typedef void (*RandFunc)(uchar* arr, int len, uint64* state, const void* p, void* tempbuf, bool small_flag); -static RandFunc randTab[][8] = +static RandFunc randTab[CV_DEPTH_MAX][CV_DEPTH_MAX] = { { (RandFunc)randi_8u, (RandFunc)randi_8s, (RandFunc)randi_16u, (RandFunc)randi_16s, diff --git a/modules/core/src/split.dispatch.cpp b/modules/core/src/split.dispatch.cpp index fc5e073497..e2a47b704d 100644 --- a/modules/core/src/split.dispatch.cpp +++ b/modules/core/src/split.dispatch.cpp @@ -53,7 +53,7 @@ typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn); static SplitFunc getSplitFunc(int depth) { - static SplitFunc splitTab[] = + static SplitFunc splitTab[CV_DEPTH_MAX] = { (SplitFunc)GET_OPTIMIZED(cv::hal::split8u), (SplitFunc)GET_OPTIMIZED(cv::hal::split8u), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u), diff --git a/modules/core/src/sum.simd.hpp b/modules/core/src/sum.simd.hpp index e20cd39b70..f790fc733a 100644 --- a/modules/core/src/sum.simd.hpp +++ b/modules/core/src/sum.simd.hpp @@ -434,7 +434,7 @@ static int sum64f( const double* src, const uchar* mask, double* dst, int len, i SumFunc getSumFunc(int depth) { - static SumFunc sumTab[] = + static SumFunc sumTab[CV_DEPTH_MAX] = { (SumFunc)GET_OPTIMIZED(sum8u), (SumFunc)sum8s, (SumFunc)sum16u, (SumFunc)sum16s,