Merge pull request #25598 from asmorkalov:as/tables_range_check_core

Check range for type-dependant function tables #25598

Address https://github.com/opencv/opencv/issues/24703

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Alexander Smorkalov 2024-05-17 10:48:40 +03:00 committed by GitHub
parent 41f08988b4
commit 0044047782
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 39 additions and 34 deletions

View File

@ -329,7 +329,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
static BinaryFuncC* getMaxTab() 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::max8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max8s),
(BinaryFuncC)GET_OPTIMIZED(cv::hal::max16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max16s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::max16s),
@ -343,7 +343,7 @@ static BinaryFuncC* getMaxTab()
static BinaryFuncC* getMinTab() 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::min8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::min8s),
(BinaryFuncC)GET_OPTIMIZED(cv::hal::min16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::min16s), (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(); Mat src1 = psrc1->getMat(), src2 = psrc2->getMat(), dst = _dst.getMat();
Size sz = getContinuousSize2D(src1, src2, dst, src1.channels()); 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; return;
} }
@ -868,7 +870,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
static BinaryFuncC* getAddTab() 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::add8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add8s),
(BinaryFuncC)GET_OPTIMIZED(cv::hal::add16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add16s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::add16s),
@ -882,7 +884,7 @@ static BinaryFuncC* getAddTab()
static BinaryFuncC* getSubTab() 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::sub8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub8s),
(BinaryFuncC)GET_OPTIMIZED(cv::hal::sub16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub16s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::sub16s),
@ -896,7 +898,7 @@ static BinaryFuncC* getSubTab()
static BinaryFuncC* getAbsDiffTab() 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::absdiff8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff8s),
(BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff16s), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::absdiff16s),
@ -949,7 +951,7 @@ namespace cv
static BinaryFuncC* getMulTab() 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::mul8u, (BinaryFuncC)cv::hal::mul8s, (BinaryFuncC)cv::hal::mul16u,
(BinaryFuncC)cv::hal::mul16s, (BinaryFuncC)cv::hal::mul32s, (BinaryFuncC)cv::hal::mul32f, (BinaryFuncC)cv::hal::mul16s, (BinaryFuncC)cv::hal::mul32s, (BinaryFuncC)cv::hal::mul32f,
@ -961,7 +963,7 @@ static BinaryFuncC* getMulTab()
static BinaryFuncC* getDivTab() 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::div8u, (BinaryFuncC)cv::hal::div8s, (BinaryFuncC)cv::hal::div16u,
(BinaryFuncC)cv::hal::div16s, (BinaryFuncC)cv::hal::div32s, (BinaryFuncC)cv::hal::div32f, (BinaryFuncC)cv::hal::div16s, (BinaryFuncC)cv::hal::div32s, (BinaryFuncC)cv::hal::div32f,
@ -973,7 +975,7 @@ static BinaryFuncC* getDivTab()
static BinaryFuncC* getRecipTab() 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::recip8u, (BinaryFuncC)cv::hal::recip8s, (BinaryFuncC)cv::hal::recip16u,
(BinaryFuncC)cv::hal::recip16s, (BinaryFuncC)cv::hal::recip32s, (BinaryFuncC)cv::hal::recip32f, (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* 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::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, (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 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::cmp8u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp8s),
(BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp16u), (BinaryFuncC)GET_OPTIMIZED(cv::hal::cmp16s), (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 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(inRange8u), (InRangeFunc)GET_OPTIMIZED(inRange8s), (InRangeFunc)GET_OPTIMIZED(inRange16u),
(InRangeFunc)GET_OPTIMIZED(inRange16s), (InRangeFunc)GET_OPTIMIZED(inRange32s), (InRangeFunc)GET_OPTIMIZED(inRange32f), (InRangeFunc)GET_OPTIMIZED(inRange16s), (InRangeFunc)GET_OPTIMIZED(inRange32s), (InRangeFunc)GET_OPTIMIZED(inRange32f),

View File

@ -79,7 +79,7 @@ typedef void (*MixChannelsFunc)( const void** src, const int* sdelta,
static MixChannelsFunc getMixchFunc(int depth) static MixChannelsFunc getMixchFunc(int depth)
{ {
static MixChannelsFunc mixchTab[] = static MixChannelsFunc mixchTab[CV_DEPTH_MAX] =
{ {
mixChannels8u, mixChannels8u, mixChannels16u, mixChannels8u, mixChannels8u, mixChannels16u,
mixChannels16u, mixChannels32s, mixChannels32s, 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)); NAryMatIterator it(arrays, ptrs, (int)(nsrcs + ndsts));
int total = (int)it.size, blocksize = std::min(total, (int)((BLOCK_SIZE + esz1-1)/esz1)); int total = (int)it.size, blocksize = std::min(total, (int)((BLOCK_SIZE + esz1-1)/esz1));
MixChannelsFunc func = getMixchFunc(depth); MixChannelsFunc func = getMixchFunc(depth);
CV_Assert(func);
for( i = 0; i < it.nplanes; i++, ++it ) for( i = 0; i < it.nplanes; i++, ++it )
{ {

View File

@ -372,7 +372,7 @@ DEF_CPY_FUNC(64s, int64)
BinaryFunc getConvertFunc(int sdepth, int ddepth) BinaryFunc getConvertFunc(int sdepth, int ddepth)
{ {
static BinaryFunc cvtTab[][8] = static BinaryFunc cvtTab[CV_DEPTH_MAX][CV_DEPTH_MAX] =
{ {
{ {
(cvt8u), (cvt8s8u), (cvt16u8u), (cvt8u), (cvt8s8u), (cvt16u8u),

View File

@ -299,7 +299,7 @@ DEF_CVT_SCALE_FUNC(16f, cvt1_32f, hfloat, hfloat, float)
BinaryFunc getCvtScaleAbsFunc(int depth) BinaryFunc getCvtScaleAbsFunc(int depth)
{ {
static BinaryFunc cvtScaleAbsTab[] = static BinaryFunc cvtScaleAbsTab[CV_DEPTH_MAX] =
{ {
(BinaryFunc)cvtScaleAbs8u, (BinaryFunc)cvtScaleAbs8s8u, (BinaryFunc)cvtScaleAbs16u8u, (BinaryFunc)cvtScaleAbs8u, (BinaryFunc)cvtScaleAbs8s8u, (BinaryFunc)cvtScaleAbs16u8u,
(BinaryFunc)cvtScaleAbs16s8u, (BinaryFunc)cvtScaleAbs32s8u, (BinaryFunc)cvtScaleAbs32f8u, (BinaryFunc)cvtScaleAbs16s8u, (BinaryFunc)cvtScaleAbs32s8u, (BinaryFunc)cvtScaleAbs32f8u,
@ -311,7 +311,7 @@ BinaryFunc getCvtScaleAbsFunc(int depth)
BinaryFunc getConvertScaleFunc(int sdepth, int ddepth) 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), (BinaryFunc)GET_OPTIMIZED(cvtScale8u), (BinaryFunc)GET_OPTIMIZED(cvtScale8s8u), (BinaryFunc)GET_OPTIMIZED(cvtScale16u8u),

View File

@ -196,7 +196,7 @@ static int countNonZero64f( const double* src, int len )
CountNonZeroFunc getCountNonZeroTab(int depth) CountNonZeroFunc getCountNonZeroTab(int depth)
{ {
static CountNonZeroFunc countNonZeroTab[] = static CountNonZeroFunc countNonZeroTab[CV_DEPTH_MAX] =
{ {
(CountNonZeroFunc)GET_OPTIMIZED(countNonZero8u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero8u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero8u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero8u),
(CountNonZeroFunc)GET_OPTIMIZED(countNonZero16u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero16u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero16u), (CountNonZeroFunc)GET_OPTIMIZED(countNonZero16u),

View File

@ -310,7 +310,7 @@ static bool hasNonZero64f( const double* src, size_t len )
HasNonZeroFunc getHasNonZeroTab(int depth) HasNonZeroFunc getHasNonZeroTab(int depth)
{ {
static HasNonZeroFunc hasNonZeroTab[] = static HasNonZeroFunc hasNonZeroTab[CV_DEPTH_MAX] =
{ {
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero8u),
(HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u), (HasNonZeroFunc)GET_OPTIMIZED(hasNonZero16u),

View File

@ -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 ); 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_8u, (LUTFunc)LUT8u_8s, (LUTFunc)LUT8u_16u, (LUTFunc)LUT8u_16s,
(LUTFunc)LUT8u_32s, (LUTFunc)LUT8u_32f, (LUTFunc)LUT8u_64f, 0 (LUTFunc)LUT8u_32s, (LUTFunc)LUT8u_32f, (LUTFunc)LUT8u_64f, 0
@ -330,7 +330,7 @@ public:
void operator()( const cv::Range& range ) const CV_OVERRIDE void operator()( const cv::Range& range ) const CV_OVERRIDE
{ {
CV_DbgAssert(*ok); CV_Assert(*ok);
const int row0 = range.start; const int row0 = range.start;
const int row1 = range.end; const int row1 = range.end;

View File

@ -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 ); 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)iPow8u, (IPowFunc)iPow8s, (IPowFunc)iPow16u, (IPowFunc)iPow16s,
(IPowFunc)iPow32s, (IPowFunc)iPow32f, (IPowFunc)iPow64f, 0 (IPowFunc)iPow32s, (IPowFunc)iPow32f, (IPowFunc)iPow64f, 0

View File

@ -979,7 +979,7 @@ typedef double (*DotProdFunc)(const uchar* src1, const uchar* src2, int len);
static DotProdFunc getDotProdFunc(int depth) 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)GET_OPTIMIZED(dotProd_8u), (DotProdFunc)GET_OPTIMIZED(dotProd_8s),
(DotProdFunc)dotProd_16u, (DotProdFunc)dotProd_16s, (DotProdFunc)dotProd_16u, (DotProdFunc)dotProd_16s,

View File

@ -1792,7 +1792,7 @@ diagtransform_64f(const double* src, double* dst, const double* m, int len, int
TransformFunc getTransformFunc(int depth) TransformFunc getTransformFunc(int depth)
{ {
static TransformFunc transformTab[] = static TransformFunc transformTab[CV_DEPTH_MAX] =
{ {
(TransformFunc)transform_8u, (TransformFunc)transform_8s, (TransformFunc)transform_16u, (TransformFunc)transform_8u, (TransformFunc)transform_8s, (TransformFunc)transform_16u,
(TransformFunc)transform_16s, (TransformFunc)transform_32s, (TransformFunc)transform_32f, (TransformFunc)transform_16s, (TransformFunc)transform_32s, (TransformFunc)transform_32f,
@ -1804,7 +1804,7 @@ TransformFunc getTransformFunc(int depth)
TransformFunc getDiagTransformFunc(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_8u, (TransformFunc)diagtransform_8s, (TransformFunc)diagtransform_16u,
(TransformFunc)diagtransform_16s, (TransformFunc)diagtransform_32s, (TransformFunc)diagtransform_32f, (TransformFunc)diagtransform_16s, (TransformFunc)diagtransform_32s, (TransformFunc)diagtransform_32f,

View File

@ -1259,7 +1259,7 @@ void cv::sort( InputArray _src, OutputArray _dst, int flags )
Mat dst = _dst.getMat(); Mat dst = _dst.getMat();
CV_IPP_RUN_FAST(ipp_sort(src, dst, flags)); CV_IPP_RUN_FAST(ipp_sort(src, dst, flags));
static SortFunc tab[] = static SortFunc tab[CV_DEPTH_MAX] =
{ {
sort_<uchar>, sort_<schar>, sort_<ushort>, sort_<short>, sort_<uchar>, sort_<schar>, sort_<ushort>, sort_<short>,
sort_<int>, sort_<float>, sort_<double>, 0 sort_<int>, sort_<float>, sort_<double>, 0
@ -1284,7 +1284,7 @@ void cv::sortIdx( InputArray _src, OutputArray _dst, int flags )
CV_IPP_RUN_FAST(ipp_sortIdx(src, dst, flags)); CV_IPP_RUN_FAST(ipp_sortIdx(src, dst, flags));
static SortFunc tab[] = static SortFunc tab[CV_DEPTH_MAX] =
{ {
sortIdx_<uchar>, sortIdx_<schar>, sortIdx_<ushort>, sortIdx_<short>, sortIdx_<uchar>, sortIdx_<schar>, sortIdx_<ushort>, sortIdx_<short>,
sortIdx_<int>, sortIdx_<float>, sortIdx_<double>, 0 sortIdx_<int>, sortIdx_<float>, sortIdx_<double>, 0

View File

@ -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 getConvertElem(int fromType, int toType)
{ {
static ConvertData tab[][8] = static ConvertData tab[CV_DEPTH_MAX][CV_DEPTH_MAX] =
{{ convertData_<uchar, uchar>, convertData_<uchar, schar>, {{ convertData_<uchar, uchar>, convertData_<uchar, schar>,
convertData_<uchar, ushort>, convertData_<uchar, short>, convertData_<uchar, ushort>, convertData_<uchar, short>,
convertData_<uchar, int>, convertData_<uchar, float>, convertData_<uchar, int>, convertData_<uchar, float>,
@ -82,7 +82,7 @@ static ConvertData getConvertElem(int fromType, int toType)
static ConvertScaleData getConvertScaleElem(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_<uchar, uchar>, convertScaleData_<uchar, schar>, {{ convertScaleData_<uchar, uchar>, convertScaleData_<uchar, schar>,
convertScaleData_<uchar, ushort>, convertScaleData_<uchar, short>, convertScaleData_<uchar, ushort>, convertScaleData_<uchar, short>,
convertScaleData_<uchar, int>, convertScaleData_<uchar, float>, convertScaleData_<uchar, int>, convertScaleData_<uchar, float>,
@ -389,6 +389,7 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const
if( alpha == 1 ) if( alpha == 1 )
{ {
ConvertData cvtfunc = getConvertElem(type(), rtype); ConvertData cvtfunc = getConvertElem(type(), rtype);
CV_Assert(cvtfunc);
for( size_t i = 0; i < N; i++, ++from ) for( size_t i = 0; i < N; i++, ++from )
{ {
const Node* n = from.node(); const Node* n = from.node();
@ -399,6 +400,7 @@ void SparseMat::convertTo( SparseMat& m, int rtype, double alpha ) const
else else
{ {
ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype); ConvertScaleData cvtfunc = getConvertScaleElem(type(), rtype);
CV_Assert(cvtfunc);
for( size_t i = 0; i < N; i++, ++from ) for( size_t i = 0; i < N; i++, ++from )
{ {
const Node* n = from.node(); const Node* n = from.node();

View File

@ -311,7 +311,7 @@ static int sqsum64f( const double* src, const uchar* mask, double* sum, double*
SumSqrFunc getSumSqrFunc(int depth) SumSqrFunc getSumSqrFunc(int depth)
{ {
CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION();
static SumSqrFunc sumSqrTab[] = static SumSqrFunc sumSqrTab[CV_DEPTH_MAX] =
{ {
(SumSqrFunc)GET_OPTIMIZED(sqsum8u), (SumSqrFunc)sqsum8s, (SumSqrFunc)sqsum16u, (SumSqrFunc)sqsum16s, (SumSqrFunc)GET_OPTIMIZED(sqsum8u), (SumSqrFunc)sqsum8s, (SumSqrFunc)sqsum16u, (SumSqrFunc)sqsum16s,
(SumSqrFunc)sqsum32s, (SumSqrFunc)GET_OPTIMIZED(sqsum32f), (SumSqrFunc)sqsum64f, 0 (SumSqrFunc)sqsum32s, (SumSqrFunc)GET_OPTIMIZED(sqsum32f), (SumSqrFunc)sqsum64f, 0

View File

@ -50,7 +50,7 @@ typedef void (*MergeFunc)(const uchar** src, uchar* dst, int len, int cn);
static MergeFunc getMergeFunc(int depth) 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::merge8u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge8u),
(MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u), (MergeFunc)GET_OPTIMIZED(cv::hal::merge16u),

View File

@ -834,7 +834,7 @@ typedef void (*MinMaxIdxFunc)(const uchar*, const uchar*, int*, int*, size_t*, s
static MinMaxIdxFunc getMinmaxTab(int depth) 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_8u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_8s),
(MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16s), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16u), (MinMaxIdxFunc)GET_OPTIMIZED(minMaxIdx_16s),

View File

@ -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); 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, (RandFunc)randi_8u, (RandFunc)randi_8s, (RandFunc)randi_16u, (RandFunc)randi_16s,

View File

@ -53,7 +53,7 @@ typedef void (*SplitFunc)(const uchar* src, uchar** dst, int len, int cn);
static SplitFunc getSplitFunc(int depth) 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::split8u), (SplitFunc)GET_OPTIMIZED(cv::hal::split8u),
(SplitFunc)GET_OPTIMIZED(cv::hal::split16u), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u), (SplitFunc)GET_OPTIMIZED(cv::hal::split16u),

View File

@ -434,7 +434,7 @@ static int sum64f( const double* src, const uchar* mask, double* dst, int len, i
SumFunc getSumFunc(int depth) SumFunc getSumFunc(int depth)
{ {
static SumFunc sumTab[] = static SumFunc sumTab[CV_DEPTH_MAX] =
{ {
(SumFunc)GET_OPTIMIZED(sum8u), (SumFunc)sum8s, (SumFunc)GET_OPTIMIZED(sum8u), (SumFunc)sum8s,
(SumFunc)sum16u, (SumFunc)sum16s, (SumFunc)sum16u, (SumFunc)sum16s,