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

core: rework code locality

- to reduce binaries size of FFmpeg Windows wrapper
- MinGW linker doesn't support -ffunction-sections (used for FFmpeg Windows wrapper)
- move code to improve locality with its used dependencies
- move UMat::dot() to matmul.dispatch.cpp (Mat::dot() is already there)
- move UMat::inv() to lapack.cpp
- move UMat::mul() to arithm.cpp
- move UMat:eye() to matrix_operations.cpp (near setIdentity() implementation)
- move normalize(): convert_scale.cpp => norm.cpp
- move convertAndUnrollScalar(): arithm.cpp => copy.cpp
- move scalarToRawData(): array.cpp => copy.cpp
- move transpose(): matrix_operations.cpp => matrix_transform.cpp
- move flip(), rotate(): copy.cpp => matrix_transform.cpp (rotate90 uses flip and transpose)
- add 'OPENCV_CORE_EXCLUDE_C_API' CMake variable to exclude compilation of C-API functions from the core module
- matrix_wrap.cpp: add compile-time checks for CUDA/OpenGL calls
- the steps above allow to reduce FFmpeg wrapper size for ~1.5Mb (initial size of OpenCV part is about 3Mb)

backport is done to improve merge experience (less conflicts)
backport of commit: 65eb946756
This commit is contained in:
Alexander Alekhin
2021-02-23 00:22:06 +00:00
parent 2ab1f3f166
commit cbfd38bd41
20 changed files with 1251 additions and 1145 deletions
+15 -10
View File
@@ -753,8 +753,6 @@ SVBkSb( int m, int n, const double* w, size_t wstep,
(double*)alignPtr(buffer, sizeof(double)), DBL_EPSILON*2 );
}
}
/****************************************************************************************\
* Determinant of the matrix *
\****************************************************************************************/
@@ -764,7 +762,7 @@ SVBkSb( int m, int n, const double* w, size_t wstep,
m(0,1)*((double)m(1,0)*m(2,2) - (double)m(1,2)*m(2,0)) + \
m(0,2)*((double)m(1,0)*m(2,1) - (double)m(1,1)*m(2,0)))
double cv::determinant( InputArray _mat )
double determinant( InputArray _mat )
{
CV_INSTRUMENT_REGION();
@@ -842,7 +840,7 @@ double cv::determinant( InputArray _mat )
#define Df( y, x ) ((float*)(dstdata + y*dststep))[x]
#define Dd( y, x ) ((double*)(dstdata + y*dststep))[x]
double cv::invert( InputArray _src, OutputArray _dst, int method )
double invert( InputArray _src, OutputArray _dst, int method )
{
CV_INSTRUMENT_REGION();
@@ -1069,13 +1067,19 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
return result;
}
UMat UMat::inv(int method) const
{
UMat m;
invert(*this, m, method);
return m;
}
/****************************************************************************************\
* Solving a linear system *
\****************************************************************************************/
bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int method )
bool solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int method )
{
CV_INSTRUMENT_REGION();
@@ -1374,7 +1378,7 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth
/////////////////// finding eigenvalues and eigenvectors of a symmetric matrix ///////////////
bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
bool eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
{
CV_INSTRUMENT_REGION();
@@ -1396,7 +1400,7 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
const bool evecNeeded = _evects.needed();
const int esOptions = evecNeeded ? Eigen::ComputeEigenvectors : Eigen::EigenvaluesOnly;
_evals.create(n, 1, type);
cv::Mat evals = _evals.getMat();
Mat evals = _evals.getMat();
if ( type == CV_64F )
{
Eigen::MatrixXd src_eig, zeros_eig;
@@ -1448,9 +1452,6 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
#endif
}
namespace cv
{
static void _SVDcompute( InputArray _aarr, OutputArray _w,
OutputArray _u, OutputArray _vt, int flags )
{
@@ -1598,6 +1599,9 @@ void cv::SVBackSubst(InputArray w, InputArray u, InputArray vt, InputArray rhs,
}
#ifndef OPENCV_EXCLUDE_C_API
CV_IMPL double
cvDet( const CvArr* arr )
{
@@ -1789,3 +1793,4 @@ cvSVBkSb( const CvArr* warr, const CvArr* uarr,
cv::SVD::backSubst(w, u, v, rhs, dst);
CV_Assert( dst.data == dst0.data );
}
#endif // OPENCV_EXCLUDE_C_API