1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

opencv: Use cv::AutoBuffer<>::data()

This commit is contained in:
Alexander Alekhin
2018-06-10 22:42:00 +00:00
committed by Alexander Alekhin
parent 135ea264ef
commit b09a4a98d4
90 changed files with 333 additions and 339 deletions
@@ -255,6 +255,7 @@ Cv64suf;
#ifdef __OPENCV_BUILD
# define DISABLE_OPENCV_24_COMPATIBILITY
# define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY
#endif
#ifdef CVAPI_EXPORTS
+7 -7
View File
@@ -282,7 +282,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
{
blocksize = std::min(blocksize, blocksize0);
_buf.allocate(blocksize*esz);
maskbuf = _buf;
maskbuf = _buf.data();
}
for( size_t i = 0; i < it.nplanes; i++, ++it )
@@ -312,7 +312,7 @@ static void binary_op( InputArray _src1, InputArray _src2, OutputArray _dst,
size_t total = it.size, blocksize = std::min(total, blocksize0);
_buf.allocate(blocksize*(haveMask ? 2 : 1)*esz + 32);
scbuf = _buf;
scbuf = _buf.data();
maskbuf = alignPtr(scbuf + blocksize*esz, 16);
convertAndUnrollScalar( src2, src1.type(), scbuf, blocksize);
@@ -754,7 +754,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
blocksize = std::min(blocksize, blocksize0);
_buf.allocate(bufesz*blocksize + 64);
buf = _buf;
buf = _buf.data();
if( cvtsrc1 )
buf1 = buf, buf = alignPtr(buf + blocksize*wsz, 16);
if( cvtsrc2 )
@@ -818,7 +818,7 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
size_t total = it.size, blocksize = std::min(total, blocksize0);
_buf.allocate(bufesz*blocksize + 64);
buf = _buf;
buf = _buf.data();
if( cvtsrc1 )
buf1 = buf, buf = alignPtr(buf + blocksize*wsz, 16);
buf2 = buf; buf = alignPtr(buf + blocksize*wsz, 16);
@@ -1309,7 +1309,7 @@ void cv::compare(InputArray _src1, InputArray _src2, OutputArray _dst, int op)
size_t total = it.size, blocksize = std::min(total, blocksize0);
AutoBuffer<uchar> _buf(blocksize*esz);
uchar *buf = _buf;
uchar *buf = _buf.data();
if( depth1 > CV_32S )
convertAndUnrollScalar( src2, depth1, buf, blocksize );
@@ -1700,7 +1700,7 @@ static bool ocl_inRange( InputArray _src, InputArray _lowerb,
size_t blocksize = 36;
AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128);
uchar *buf = alignPtr(_buf + blocksize*cn, 16);
uchar *buf = alignPtr(_buf.data() + blocksize*cn, 16);
if( ldepth != sdepth && sdepth < CV_32S )
{
@@ -1806,7 +1806,7 @@ void cv::inRange(InputArray _src, InputArray _lowerb,
size_t total = it.size, blocksize = std::min(total, blocksize0);
AutoBuffer<uchar> _buf(blocksize*(((int)lbScalar + (int)ubScalar)*esz + cn) + 2*cn*sizeof(int) + 128);
uchar *buf = _buf, *mbuf = buf, *lbuf = 0, *ubuf = 0;
uchar *buf = _buf.data(), *mbuf = buf, *lbuf = 0, *ubuf = 0;
buf = alignPtr(buf + blocksize*cn, 16);
if( lbScalar && ubScalar )
+1 -1
View File
@@ -179,7 +179,7 @@ struct BatchDistInvoker : public ParallelLoopBody
void operator()(const Range& range) const CV_OVERRIDE
{
AutoBuffer<int> buf(src2->rows);
int* bufptr = buf;
int* bufptr = buf.data();
for( int i = range.start; i < range.end; i++ )
{
+3 -3
View File
@@ -104,7 +104,7 @@ void cv::mixChannels( const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, cons
int depth = dst[0].depth();
AutoBuffer<uchar> buf((nsrcs + ndsts + 1)*(sizeof(Mat*) + sizeof(uchar*)) + npairs*(sizeof(uchar*)*2 + sizeof(int)*6));
const Mat** arrays = (const Mat**)(uchar*)buf;
const Mat** arrays = (const Mat**)(uchar*)buf.data();
uchar** ptrs = (uchar**)(arrays + nsrcs + ndsts);
const uchar** srcs = (const uchar**)(ptrs + nsrcs + ndsts + 1);
uchar** dsts = (uchar**)(srcs + npairs);
@@ -294,7 +294,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
CV_Assert(nsrc > 0 && ndst > 0);
cv::AutoBuffer<Mat> _buf(nsrc + ndst);
Mat* buf = _buf;
Mat* buf = _buf.data();
for( i = 0; i < nsrc; i++ )
buf[i] = src.getMat(src_is_mat ? -1 : i);
for( i = 0; i < ndst; i++ )
@@ -327,7 +327,7 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
CV_Assert(fromTo.size()%2 == 0 && nsrc > 0 && ndst > 0);
cv::AutoBuffer<Mat> _buf(nsrc + ndst);
Mat* buf = _buf;
Mat* buf = _buf.data();
for( i = 0; i < nsrc; i++ )
buf[i] = src.getMat(src_is_mat ? -1 : i);
for( i = 0; i < ndst; i++ )
+1 -1
View File
@@ -52,7 +52,7 @@ namespace cv
double eps = getGradientEps();
int i, n = getDims();
AutoBuffer<double> x_buf(n);
double* x_ = x_buf;
double* x_ = x_buf.data();
for( i = 0; i < n; i++ )
x_[i] = x[i];
for( i = 0; i < n; i++ )
+6 -6
View File
@@ -531,7 +531,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
int blockSize0 = std::min(totalsz, (int)((BLOCK_SIZE + esz-1)/esz));
blockSize0 -= blockSize0 % mcn; // must be divisible without remainder for unrolling and advancing
AutoBuffer<uchar> _scbuf(blockSize0*esz + 32);
uchar* scbuf = alignPtr((uchar*)_scbuf, (int)sizeof(double));
uchar* scbuf = alignPtr((uchar*)_scbuf.data(), (int)sizeof(double));
convertAndUnrollScalar( value, type(), scbuf, blockSize0/mcn );
for( size_t i = 0; i < it.nplanes; i++, ++it )
@@ -559,7 +559,7 @@ flipHoriz( const uchar* src, size_t sstep, uchar* dst, size_t dstep, Size size,
{
int i, j, limit = (int)(((size.width + 1)/2)*esz);
AutoBuffer<int> _tab(size.width*esz);
int* tab = _tab;
int* tab = _tab.data();
for( i = 0; i < size.width; i++ )
for( size_t k = 0; k < esz; k++ )
@@ -960,7 +960,7 @@ void copyMakeBorder_8u( const uchar* src, size_t srcstep, cv::Size srcroi,
}
cv::AutoBuffer<int> _tab((dstroi.width - srcroi.width)*cn);
int* tab = _tab;
int* tab = _tab.data();
int right = dstroi.width - srcroi.width - left;
int bottom = dstroi.height - srcroi.height - top;
@@ -1031,7 +1031,7 @@ void copyMakeConstBorder_8u( const uchar* src, size_t srcstep, cv::Size srcroi,
{
int i, j;
cv::AutoBuffer<uchar> _constBuf(dstroi.width*cn);
uchar* constBuf = _constBuf;
uchar* constBuf = _constBuf.data();
int right = dstroi.width - srcroi.width - left;
int bottom = dstroi.height - srcroi.height - top;
@@ -1224,10 +1224,10 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
CV_Assert( value[0] == value[1] && value[0] == value[2] && value[0] == value[3] );
cn1 = 1;
}
scalarToRawData(value, buf, CV_MAKETYPE(src.depth(), cn1), cn);
scalarToRawData(value, buf.data(), CV_MAKETYPE(src.depth(), cn1), cn);
copyMakeConstBorder_8u( src.ptr(), src.step, src.size(),
dst.ptr(), dst.step, dst.size(),
top, left, (int)src.elemSize(), (uchar*)(double*)buf );
top, left, (int)src.elemSize(), (uchar*)buf.data() );
}
}
+30 -30
View File
@@ -908,7 +908,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
int p, q, factor2 = (factor - 1)/2;
int d, dd, dw_f = c.tab_size/factor;
AutoBuffer<Complex<T> > buf(factor2 * 2);
Complex<T>* a = buf;
Complex<T>* a = buf.data();
Complex<T>* b = a + factor2;
for( i = 0; i < c.n; i += n )
@@ -2895,7 +2895,7 @@ protected:
uchar* dptr = dptr0;
if( needBufferA )
dptr = tmp_bufA;
dptr = tmp_bufA.data();
contextA->apply(sptr, dptr);
@@ -2921,12 +2921,12 @@ protected:
const uchar* sptr0 = src_data;
uchar* dptr0 = dst_data;
dbuf0 = buf0, dbuf1 = buf1;
dbuf0 = buf0.data(), dbuf1 = buf1.data();
if( needBufferB )
{
dbuf1 = tmp_bufB;
dbuf0 = buf1;
dbuf1 = tmp_bufB.data();
dbuf0 = buf1.data();
}
if( real_transform )
@@ -2937,42 +2937,42 @@ protected:
b = (count+1)/2;
if( !inv )
{
memset( buf0, 0, len*complex_elem_size );
CopyColumn( sptr0, src_step, buf0, complex_elem_size, len, elem_size );
memset( buf0.data(), 0, len*complex_elem_size );
CopyColumn( sptr0, src_step, buf0.data(), complex_elem_size, len, elem_size );
sptr0 += stage_dst_channels*elem_size;
if( even )
{
memset( buf1, 0, len*complex_elem_size );
memset( buf1.data(), 0, len*complex_elem_size );
CopyColumn( sptr0 + (count-2)*elem_size, src_step,
buf1, complex_elem_size, len, elem_size );
buf1.data(), complex_elem_size, len, elem_size );
}
}
else if( stage_src_channels == 1 )
{
CopyColumn( sptr0, src_step, buf0, elem_size, len, elem_size );
ExpandCCS( buf0, len, elem_size );
CopyColumn( sptr0, src_step, buf0.data(), elem_size, len, elem_size );
ExpandCCS( buf0.data(), len, elem_size );
if( even )
{
CopyColumn( sptr0 + (count-1)*elem_size, src_step,
buf1, elem_size, len, elem_size );
ExpandCCS( buf1, len, elem_size );
buf1.data(), elem_size, len, elem_size );
ExpandCCS( buf1.data(), len, elem_size );
}
sptr0 += elem_size;
}
else
{
CopyColumn( sptr0, src_step, buf0, complex_elem_size, len, complex_elem_size );
CopyColumn( sptr0, src_step, buf0.data(), complex_elem_size, len, complex_elem_size );
if( even )
{
CopyColumn( sptr0 + b*complex_elem_size, src_step,
buf1, complex_elem_size, len, complex_elem_size );
buf1.data(), complex_elem_size, len, complex_elem_size );
}
sptr0 += complex_elem_size;
}
if( even )
contextB->apply(buf1, dbuf1);
contextB->apply(buf0, dbuf0);
contextB->apply(buf1.data(), dbuf1);
contextB->apply(buf0.data(), dbuf0);
if( stage_dst_channels == 1 )
{
@@ -3019,13 +3019,13 @@ protected:
{
if( i+1 < b )
{
CopyFrom2Columns( sptr0, src_step, buf0, buf1, len, complex_elem_size );
contextB->apply(buf1, dbuf1);
CopyFrom2Columns( sptr0, src_step, buf0.data(), buf1.data(), len, complex_elem_size );
contextB->apply(buf1.data(), dbuf1);
}
else
CopyColumn( sptr0, src_step, buf0, complex_elem_size, len, complex_elem_size );
CopyColumn( sptr0, src_step, buf0.data(), complex_elem_size, len, complex_elem_size );
contextB->apply(buf0, dbuf0);
contextB->apply(buf0.data(), dbuf0);
if( i+1 < b )
CopyTo2Columns( dbuf0, dbuf1, dptr0, dst_step, len, complex_elem_size );
@@ -3134,9 +3134,9 @@ public:
if (len != prev_len || (!inplace_transform && opt.isInverse && real_transform))
{
wave_buf.allocate(opt.n*complex_elem_size);
opt.wave = wave_buf;
opt.wave = wave_buf.data();
itab_buf.allocate(opt.n);
opt.itab = itab_buf;
opt.itab = itab_buf.data();
DFTInit( opt.n, opt.nf, opt.factors, opt.itab, complex_elem_size,
opt.wave, stage == 0 && opt.isInverse && real_transform );
}
@@ -4152,31 +4152,31 @@ public:
bool inplace_transform = opt.factors[0] == opt.factors[opt.nf-1];
wave_buf.allocate(len*complex_elem_size);
opt.wave = wave_buf;
opt.wave = wave_buf.data();
itab_buf.allocate(len);
opt.itab = itab_buf;
opt.itab = itab_buf.data();
DFTInit( len, opt.nf, opt.factors, opt.itab, complex_elem_size, opt.wave, isInverse );
dct_wave.allocate((len/2 + 1)*complex_elem_size);
src_buf.allocate(len*elem_size);
src_dft_buf = src_buf;
src_dft_buf = src_buf.data();
if(!inplace_transform)
{
dst_buf.allocate(len*elem_size);
dst_dft_buf = dst_buf;
dst_dft_buf = dst_buf.data();
}
else
{
dst_dft_buf = src_buf;
dst_dft_buf = src_buf.data();
}
DCTInit( len, complex_elem_size, dct_wave, isInverse);
DCTInit( len, complex_elem_size, dct_wave.data(), isInverse);
prev_len = len;
}
// otherwise reuse the tables calculated on the previous stage
for(unsigned i = 0; i < static_cast<unsigned>(count); i++ )
{
dct_func( opt, sptr + i*sstep0, sstep1, src_dft_buf, dst_dft_buf,
dptr + i*dstep0, dstep1, dct_wave);
dptr + i*dstep0, dstep1, dct_wave.data());
}
src = dst;
src_step = dst_step;
+3 -3
View File
@@ -330,7 +330,7 @@ double cv::kmeans( InputArray _data, int K,
else
{
for (int k = 0; k < K; k++)
generateRandomCenter(dims, box, centers.ptr<float>(k), rng);
generateRandomCenter(dims, box.data(), centers.ptr<float>(k), rng);
}
}
else
@@ -429,14 +429,14 @@ double cv::kmeans( InputArray _data, int K,
if (isLastIter)
{
// don't re-assign labels to avoid creation of empty clusters
parallel_for_(Range(0, N), KMeansDistanceComputer<true>(dists, labels, data, centers), (double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY));
parallel_for_(Range(0, N), KMeansDistanceComputer<true>(dists.data(), labels, data, centers), (double)divUp((size_t)(dims * N), CV_KMEANS_PARALLEL_GRANULARITY));
compactness = sum(Mat(Size(N, 1), CV_64F, &dists[0]))[0];
break;
}
else
{
// assign labels
parallel_for_(Range(0, N), KMeansDistanceComputer<false>(dists, labels, data, centers), (double)divUp((size_t)(dims * N * K), CV_KMEANS_PARALLEL_GRANULARITY));
parallel_for_(Range(0, N), KMeansDistanceComputer<false>(dists.data(), labels, data, centers), (double)divUp((size_t)(dims * N * K), CV_KMEANS_PARALLEL_GRANULARITY));
}
}
+11 -11
View File
@@ -401,7 +401,7 @@ JacobiSVDImpl_(_Tp* At, size_t astep, _Tp* _W, _Tp* Vt, size_t vstep,
{
VBLAS<_Tp> vblas;
AutoBuffer<double> Wbuf(n);
double* W = Wbuf;
double* W = Wbuf.data();
int i, j, k, iter, max_iter = std::max(m, 30);
_Tp c, s;
double sd;
@@ -778,7 +778,7 @@ double cv::determinant( InputArray _mat )
{
size_t bufSize = rows*rows*sizeof(float);
AutoBuffer<uchar> buffer(bufSize);
Mat a(rows, rows, CV_32F, (uchar*)buffer);
Mat a(rows, rows, CV_32F, buffer.data());
mat.copyTo(a);
result = hal::LU32f(a.ptr<float>(), a.step, rows, 0, 0, 0);
@@ -801,7 +801,7 @@ double cv::determinant( InputArray _mat )
{
size_t bufSize = rows*rows*sizeof(double);
AutoBuffer<uchar> buffer(bufSize);
Mat a(rows, rows, CV_64F, (uchar*)buffer);
Mat a(rows, rows, CV_64F, buffer.data());
mat.copyTo(a);
result = hal::LU64f(a.ptr<double>(), a.step, rows, 0, 0, 0);
@@ -846,7 +846,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
int nm = std::min(m, n);
AutoBuffer<uchar> _buf((m*nm + nm + nm*n)*esz + sizeof(double));
uchar* buf = alignPtr((uchar*)_buf, (int)esz);
uchar* buf = alignPtr((uchar*)_buf.data(), (int)esz);
Mat u(m, nm, type, buf);
Mat w(nm, 1, type, u.ptr() + m*nm*esz);
Mat vt(nm, n, type, w.ptr() + nm*esz);
@@ -865,7 +865,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
if( method == DECOMP_EIG )
{
AutoBuffer<uchar> _buf((n*n*2 + n)*esz + sizeof(double));
uchar* buf = alignPtr((uchar*)_buf, (int)esz);
uchar* buf = alignPtr((uchar*)_buf.data(), (int)esz);
Mat u(n, n, type, buf);
Mat w(n, 1, type, u.ptr() + n*n*esz);
Mat vt(n, n, type, w.ptr() + n*esz);
@@ -1063,7 +1063,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
int elem_size = CV_ELEM_SIZE(type);
AutoBuffer<uchar> buf(n*n*elem_size);
Mat src1(n, n, type, (uchar*)buf);
Mat src1(n, n, type, buf.data());
src.copyTo(src1);
setIdentity(dst);
@@ -1267,7 +1267,7 @@ bool cv::solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int meth
bufsize += n*5*esz + n*vstep + nb*sizeof(double) + 32;
buffer.allocate(bufsize);
uchar* ptr = alignPtr((uchar*)buffer, 16);
uchar* ptr = alignPtr(buffer.data(), 16);
Mat a(m_, n, type, ptr, astep);
@@ -1445,7 +1445,7 @@ bool cv::eigen( InputArray _src, OutputArray _evals, OutputArray _evects )
size_t elemSize = src.elemSize(), astep = alignSize(n*elemSize, 16);
AutoBuffer<uchar> buf(n*astep + n*5*elemSize + 32);
uchar* ptr = alignPtr((uchar*)buf, 16);
uchar* ptr = alignPtr(buf.data(), 16);
Mat a(n, n, type, ptr, astep), w(n, 1, type, ptr + astep*n);
ptr += astep*n + elemSize*n;
src.copyTo(a);
@@ -1489,7 +1489,7 @@ static void _SVDcompute( InputArray _aarr, OutputArray _w,
int urows = full_uv ? m : n;
size_t esz = src.elemSize(), astep = alignSize(m*esz, 16), vstep = alignSize(n*esz, 16);
AutoBuffer<uchar> _buf(urows*astep + n*vstep + n*esz + 32);
uchar* buf = alignPtr((uchar*)_buf, 16);
uchar* buf = alignPtr(_buf.data(), 16);
Mat temp_a(n, m, type, buf, astep);
Mat temp_w(n, 1, type, buf + urows*astep);
Mat temp_u(urows, m, type, buf, astep), temp_v;
@@ -1568,11 +1568,11 @@ void SVD::backSubst( InputArray _w, InputArray _u, InputArray _vt,
if( type == CV_32F )
SVBkSb(m, n, w.ptr<float>(), wstep, u.ptr<float>(), u.step, false,
vt.ptr<float>(), vt.step, true, rhs.ptr<float>(), rhs.step, nb,
dst.ptr<float>(), dst.step, buffer);
dst.ptr<float>(), dst.step, buffer.data());
else if( type == CV_64F )
SVBkSb(m, n, w.ptr<double>(), wstep, u.ptr<double>(), u.step, false,
vt.ptr<double>(), vt.step, true, rhs.ptr<double>(), rhs.step, nb,
dst.ptr<double>(), dst.step, buffer);
dst.ptr<double>(), dst.step, buffer.data());
else
CV_Error( CV_StsUnsupportedFormat, "" );
}
+4 -4
View File
@@ -586,7 +586,7 @@ void polarToCart( InputArray src1, InputArray src2,
if( depth == CV_64F )
{
_buf.allocate(blockSize*2);
buf[0] = _buf;
buf[0] = _buf.data();
buf[1] = buf[0] + blockSize;
}
@@ -1278,8 +1278,8 @@ void pow( InputArray _src, double power, OutputArray _dst )
if( src.ptr() == dst.ptr() )
{
buf.allocate(blockSize*esz1);
fbuf = (float*)(uchar*)buf;
dbuf = (double*)(uchar*)buf;
fbuf = (float*)buf.data();
dbuf = (double*)buf.data();
}
for( size_t i = 0; i < it.nplanes; i++, ++it )
@@ -1901,7 +1901,7 @@ double cv::solvePoly( InputArray _coeffs0, OutputArray _roots0, int maxIters )
Mat roots0 = _roots0.getMat();
AutoBuffer<C> buf(n*2+2);
C *coeffs = buf, *roots = coeffs + n + 1;
C *coeffs = buf.data(), *roots = coeffs + n + 1;
Mat coeffs1(coeffs0.size(), CV_MAKETYPE(CV_64F, coeffs0.channels()), coeffs0.channels() == 2 ? coeffs : roots);
coeffs0.convertTo(coeffs1, coeffs1.type());
if( coeffs0.channels() == 1 )
+16 -17
View File
@@ -165,7 +165,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
if( a_step > 1 && n > 1 )
{
_a_buf.allocate(n);
a_buf = _a_buf;
a_buf = _a_buf.data();
}
}
@@ -177,7 +177,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
if( a_step > 1 && a_size.height > 1 )
{
_a_buf.allocate(drows);
a_buf = _a_buf;
a_buf = _a_buf.data();
for( k = 0; k < drows; k++ )
a_buf[k] = a_data[a_step*k];
a_data = a_buf;
@@ -186,7 +186,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
if( b_step > 1 )
{
_b_buf.allocate(d_size.width);
b_buf = _b_buf;
b_buf = _b_buf.data();
for( j = 0; j < d_size.width; j++ )
b_buf[j] = b_data[j*b_step];
b_data = b_buf;
@@ -326,7 +326,7 @@ GEMMSingleMul( const T* a_data, size_t a_step,
else
{
cv::AutoBuffer<WT> _d_buf(m);
WT* d_buf = _d_buf;
WT* d_buf = _d_buf.data();
for( i = 0; i < drows; i++, _a_data += a_step0, _c_data += c_step0, d_data += d_step )
{
@@ -404,7 +404,7 @@ GEMMBlockMul( const T* a_data, size_t a_step,
CV_SWAP( a_step0, a_step1, t_step );
n = a_size.height;
_a_buf.allocate(n);
a_buf = _a_buf;
a_buf = _a_buf.data();
}
if( flags & GEMM_2_T )
@@ -1354,7 +1354,7 @@ static void gemmImpl( Mat A, Mat B, double alpha,
}
buf.allocate(d_buf_size + b_buf_size + a_buf_size);
d_buf = (uchar*)buf;
d_buf = buf.data();
b_buf = d_buf + d_buf_size;
if( is_a_t )
@@ -2098,7 +2098,7 @@ void cv::transform( InputArray _src, OutputArray _dst, InputArray _mtx )
if( !m.isContinuous() || m.type() != mtype || m.cols != scn + 1 )
{
_mbuf.allocate(dcn*(scn+1));
mbuf = (double*)_mbuf;
mbuf = _mbuf.data();
Mat tmp(dcn, scn+1, mtype, mbuf);
memset(tmp.ptr(), 0, tmp.total()*tmp.elemSize());
if( m.cols == scn+1 )
@@ -2273,17 +2273,16 @@ void cv::perspectiveTransform( InputArray _src, OutputArray _dst, InputArray _mt
const int mtype = CV_64F;
AutoBuffer<double> _mbuf;
double* mbuf = _mbuf;
double* mbuf = m.ptr<double>();
if( !m.isContinuous() || m.type() != mtype )
{
_mbuf.allocate((dcn+1)*(scn+1));
Mat tmp(dcn+1, scn+1, mtype, (double*)_mbuf);
mbuf = _mbuf.data();
Mat tmp(dcn+1, scn+1, mtype, mbuf);
m.convertTo(tmp, mtype);
m = tmp;
}
else
mbuf = m.ptr<double>();
TransformFunc func = depth == CV_32F ?
(TransformFunc)perspectiveTransform_32f :
@@ -2612,7 +2611,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
const float* src2 = v2.ptr<float>();
size_t step1 = v1.step/sizeof(src1[0]);
size_t step2 = v2.step/sizeof(src2[0]);
double* diff = buf;
double* diff = buf.data();
const float* mat = icovar.ptr<float>();
size_t matstep = icovar.step/sizeof(mat[0]);
@@ -2622,7 +2621,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
diff[i] = src1[i] - src2[i];
}
diff = buf;
diff = buf.data();
for( i = 0; i < len; i++, mat += matstep )
{
double row_sum = 0;
@@ -2643,7 +2642,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
const double* src2 = v2.ptr<double>();
size_t step1 = v1.step/sizeof(src1[0]);
size_t step2 = v2.step/sizeof(src2[0]);
double* diff = buf;
double* diff = buf.data();
const double* mat = icovar.ptr<double>();
size_t matstep = icovar.step/sizeof(mat[0]);
@@ -2653,7 +2652,7 @@ double cv::Mahalanobis( InputArray _v1, InputArray _v2, InputArray _icovar )
diff[i] = src1[i] - src2[i];
}
diff = buf;
diff = buf.data();
for( i = 0; i < len; i++, mat += matstep )
{
double row_sum = 0;
@@ -2705,7 +2704,7 @@ MulTransposedR( const Mat& srcmat, Mat& dstmat, const Mat& deltamat, double scal
buf_size *= 5;
}
buf.allocate(buf_size);
col_buf = (dT*)(uchar*)buf;
col_buf = (dT*)buf.data();
if( delta && delta_cols < size.width )
{
@@ -2834,7 +2833,7 @@ MulTransposedL( const Mat& srcmat, Mat& dstmat, const Mat& deltamat, double scal
dT delta_buf[4];
int delta_shift = delta_cols == size.width ? 4 : 0;
AutoBuffer<uchar> buf(size.width*sizeof(dT));
dT* row_buf = (dT*)(uchar*)buf;
dT* row_buf = (dT*)buf.data();
for( i = 0; i < size.height; i++, tdst += dststep )
{
+2 -2
View File
@@ -410,7 +410,7 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange)
rs[1] = _colRange;
for( int i = 2; i < m.dims; i++ )
rs[i] = Range::all();
*this = m(rs);
*this = m(rs.data());
return;
}
@@ -897,7 +897,7 @@ Mat Mat::reshape(int _cn, int _newndims, const int* _newsz) const
Mat hdr = *this;
hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((_cn-1) << CV_CN_SHIFT);
setSize(hdr, _newndims, (int*)newsz_buf, NULL, true);
setSize(hdr, _newndims, newsz_buf.data(), NULL, true);
return hdr;
}
+1 -1
View File
@@ -169,7 +169,7 @@ Mat cvarrToMat(const CvArr* arr, bool copyData,
if( abuf )
{
abuf->allocate(((size_t)total*esz + sizeof(double)-1)/sizeof(double));
double* bufdata = *abuf;
double* bufdata = abuf->data();
cvCvtSeqToArray(seq, bufdata, CV_WHOLE_SEQ);
return Mat(total, 1, type, bufdata);
}
+1 -1
View File
@@ -206,7 +206,7 @@ QRImpl(_Tp* A, size_t astep, int m, int n, int k, _Tp* b, size_t bstep, _Tp* hFa
cv::AutoBuffer<_Tp> buffer;
size_t buf_size = m ? m + n : hFactors != NULL;
buffer.allocate(buf_size);
_Tp* vl = buffer;
_Tp* vl = buffer.data();
if (hFactors == NULL)
hFactors = vl + m;
+8 -9
View File
@@ -606,7 +606,7 @@ reduceR_( const Mat& srcmat, Mat& dstmat )
Size size = srcmat.size();
size.width *= srcmat.channels();
AutoBuffer<WT> buffer(size.width);
WT* buf = buffer;
WT* buf = buffer.data();
ST* dst = dstmat.ptr<ST>();
const T* src = srcmat.ptr<T>();
size_t srcstep = srcmat.step/sizeof(src[0]);
@@ -1125,7 +1125,6 @@ namespace cv
template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
{
AutoBuffer<T> buf;
T* bptr;
int n, len;
bool sortRows = (flags & 1) == CV_SORT_EVERY_ROW;
bool inplace = src.data == dst.data;
@@ -1138,7 +1137,7 @@ template<typename T> static void sort_( const Mat& src, Mat& dst, int flags )
n = src.cols, len = src.rows;
buf.allocate(len);
}
bptr = (T*)buf;
T* bptr = buf.data();
for( int i = 0; i < n; i++ )
{
@@ -1223,7 +1222,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags)
for(int i = 0; i < dst.rows; i++)
{
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)dst.ptr(i), dst.cols, buffer) < 0)
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)dst.ptr(i), dst.cols, buffer.data()) < 0)
return false;
}
}
@@ -1248,7 +1247,7 @@ static bool ipp_sort(const Mat& src, Mat& dst, int flags)
dstSub = Mat(dst, subRect);
srcSub.copyTo(row);
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)row.ptr(), dst.rows, buffer) < 0)
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadix_I, (void*)row.ptr(), dst.rows, buffer.data()) < 0)
return false;
row = row.reshape(1, dstSub.rows);
@@ -1286,8 +1285,8 @@ template<typename T> static void sortIdx_( const Mat& src, Mat& dst, int flags )
buf.allocate(len);
ibuf.allocate(len);
}
T* bptr = (T*)buf;
int* _iptr = (int*)ibuf;
T* bptr = buf.data();
int* _iptr = ibuf.data();
for( int i = 0; i < n; i++ )
{
@@ -1365,7 +1364,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags )
for(int i = 0; i < src.rows; i++)
{
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(i), (Ipp32s)src.step[1], (Ipp32s*)dst.ptr(i), src.cols, buffer) < 0)
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(i), (Ipp32s)src.step[1], (Ipp32s*)dst.ptr(i), src.cols, buffer.data()) < 0)
return false;
}
}
@@ -1388,7 +1387,7 @@ static bool ipp_sortIdx( const Mat& src, Mat& dst, int flags )
subRect.x = i;
dstSub = Mat(dst, subRect);
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(0, i), srcStep, (Ipp32s*)dstRow.ptr(), src.rows, buffer) < 0)
if(CV_INSTRUMENT_FUN_IPP(ippsSortRadixIndex, (const void*)src.ptr(0, i), srcStep, (Ipp32s*)dstRow.ptr(), src.rows, buffer.data()) < 0)
return false;
dstRow = dstRow.reshape(1, dstSub.rows);
+2 -2
View File
@@ -135,7 +135,7 @@ cv::Scalar cv::mean( InputArray _src, InputArray _mask )
intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15);
blockSize = std::min(blockSize, intSumBlockSize);
_buf.allocate(cn);
buf = _buf;
buf = _buf.data();
for( k = 0; k < cn; k++ )
buf[k] = 0;
@@ -789,7 +789,7 @@ void cv::meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv, Input
int total = (int)it.size, blockSize = total, intSumBlockSize = 0;
int j, count = 0, nz0 = 0;
AutoBuffer<double> _buf(cn*4);
double *s = (double*)_buf, *sq = s + cn;
double *s = (double*)_buf.data(), *sq = s + cn;
int *sbuf = (int*)s, *sqbuf = (int*)sq;
bool blockSum = depth <= CV_16S, blockSqSum = depth <= CV_8S;
size_t esz = 0;
+1 -1
View File
@@ -496,7 +496,7 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
size_t esz = dst.elemSize(), esz1 = dst.elemSize1();
size_t blocksize0 = (int)((BLOCK_SIZE + esz-1)/esz);
AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16);
const Mat** arrays = (const Mat**)(uchar*)_buf;
const Mat** arrays = (const Mat**)_buf.data();
uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16);
arrays[0] = &dst;
+19 -19
View File
@@ -617,12 +617,12 @@ public:
if (fileSourceSignatureSize == sourceSignatureSize_)
{
cv::AutoBuffer<char> fileSourceSignature(fileSourceSignatureSize + 1);
f.read((char*)fileSourceSignature, fileSourceSignatureSize);
f.read(fileSourceSignature.data(), fileSourceSignatureSize);
if (f.eof())
{
CV_LOG_ERROR(NULL, "Unexpected EOF");
}
else if (memcmp(sourceSignature, (const char*)fileSourceSignature, fileSourceSignatureSize) == 0)
else if (memcmp(sourceSignature, fileSourceSignature.data(), fileSourceSignatureSize) == 0)
{
isValid = true;
}
@@ -696,10 +696,10 @@ public:
{
if (entry.keySize > 0)
{
f.read((char*)fileKey, entry.keySize);
f.read(fileKey.data(), entry.keySize);
CV_Assert(!f.fail());
}
if (memcmp((const char*)fileKey, key.c_str(), entry.keySize) == 0)
if (memcmp(fileKey.data(), key.c_str(), entry.keySize) == 0)
{
buf.resize(entry.dataSize);
f.read(&buf[0], entry.dataSize);
@@ -786,10 +786,10 @@ public:
{
if (entry.keySize > 0)
{
f.read((char*)fileKey, entry.keySize);
f.read(fileKey.data(), entry.keySize);
CV_Assert(!f.fail());
}
if (0 == memcmp((const char*)fileKey, key.c_str(), entry.keySize))
if (0 == memcmp(fileKey.data(), key.c_str(), entry.keySize))
{
// duplicate
CV_LOG_VERBOSE(NULL, 0, "Duplicate key ignored: " << fileName_);
@@ -1634,7 +1634,7 @@ inline cl_int getStringInfo(Functor f, ObjectType obj, cl_uint name, std::string
if (required > 0)
{
AutoBuffer<char> buf(required + 1);
char* ptr = (char*)buf; // cleanup is not needed
char* ptr = buf.data(); // cleanup is not needed
err = f(obj, name, required, ptr, NULL);
if (err != CL_SUCCESS)
return err;
@@ -2002,7 +2002,7 @@ struct Context::Impl
CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, 0, 0, &nd0));
AutoBuffer<void*> dlistbuf(nd0*2+1);
cl_device_id* dlist = (cl_device_id*)(void**)dlistbuf;
cl_device_id* dlist = (cl_device_id*)dlistbuf.data();
cl_device_id* dlist_new = dlist + nd0;
CV_OCL_DBG_CHECK(clGetDeviceIDs(pl, dtype, nd0, dlist, &nd0));
String name0;
@@ -2465,12 +2465,12 @@ static void get_platform_name(cl_platform_id id, String& name)
// get platform name string
AutoBuffer<char> buf(sz + 1);
CV_OCL_CHECK(clGetPlatformInfo(id, CL_PLATFORM_NAME, sz, buf, 0));
CV_OCL_CHECK(clGetPlatformInfo(id, CL_PLATFORM_NAME, sz, buf.data(), 0));
// just in case, ensure trailing zero for ASCIIZ string
buf[sz] = 0;
name = (const char*)buf;
name = buf.data();
}
/*
@@ -3654,7 +3654,7 @@ struct Program::Impl
{
buffer.resize(retsz + 16);
log_retval = clGetProgramBuildInfo(handle, deviceList[0],
CL_PROGRAM_BUILD_LOG, retsz+1, (char*)buffer, &retsz);
CL_PROGRAM_BUILD_LOG, retsz+1, buffer.data(), &retsz);
if (log_retval == CL_SUCCESS)
{
if (retsz < buffer.size())
@@ -3668,7 +3668,7 @@ struct Program::Impl
}
}
errmsg = String(buffer);
errmsg = String(buffer.data());
printf("OpenCL program build log: %s/%s\nStatus %d: %s\n%s\n%s\n",
sourceModule_.c_str(), sourceName_.c_str(),
result, getOpenCLErrorString(result),
@@ -3701,7 +3701,7 @@ struct Program::Impl
{
size_t n = ctx.ndevices();
AutoBuffer<cl_device_id, 4> deviceListBuf(n + 1);
cl_device_id* deviceList = deviceListBuf;
cl_device_id* deviceList = deviceListBuf.data();
for (size_t i = 0; i < n; i++)
{
deviceList[i] = (cl_device_id)(ctx.device(i).ptr());
@@ -3770,9 +3770,9 @@ struct Program::Impl
AutoBuffer<const uchar*> binaryPtrs_(ndevices);
AutoBuffer<size_t> binarySizes_(ndevices);
cl_device_id* devices = devices_;
const uchar** binaryPtrs = binaryPtrs_;
size_t* binarySizes = binarySizes_;
cl_device_id* devices = devices_.data();
const uchar** binaryPtrs = binaryPtrs_.data();
size_t* binarySizes = binarySizes_.data();
for (size_t i = 0; i < ndevices; i++)
{
devices[i] = (cl_device_id)ctx.device(i).ptr();
@@ -3781,7 +3781,7 @@ struct Program::Impl
}
cl_int result = 0;
handle = clCreateProgramWithBinary((cl_context)ctx.ptr(), (cl_uint)ndevices, (cl_device_id*)devices_,
handle = clCreateProgramWithBinary((cl_context)ctx.ptr(), (cl_uint)ndevices, devices_.data(),
binarySizes, binaryPtrs, NULL, &result);
if (result != CL_SUCCESS)
{
@@ -3798,7 +3798,7 @@ struct Program::Impl
}
// call clBuildProgram()
{
result = clBuildProgram(handle, (cl_uint)ndevices, (cl_device_id*)devices_, buildflags.c_str(), 0, 0);
result = clBuildProgram(handle, (cl_uint)ndevices, devices_.data(), buildflags.c_str(), 0, 0);
CV_OCL_DBG_CHECK_RESULT(result, cv::format("clBuildProgram(binary: %s/%s)", sourceModule_.c_str(), sourceName_.c_str()).c_str());
if (result != CL_SUCCESS)
{
@@ -6318,7 +6318,7 @@ struct Image2D::Impl
AutoBuffer<cl_image_format> formats(numFormats);
err = clGetSupportedImageFormats(context, CL_MEM_READ_WRITE,
CL_MEM_OBJECT_IMAGE2D, numFormats,
formats, NULL);
formats.data(), NULL);
CV_OCL_DBG_CHECK_RESULT(err, "clGetSupportedImageFormats(CL_MEM_OBJECT_IMAGE2D, formats)");
for (cl_uint i = 0; i < numFormats; ++i)
{
+2 -2
View File
@@ -222,7 +222,7 @@ String FileStorage::getDefaultObjectName(const String& _filename)
if( ptr == ptr2 )
CV_Error( CV_StsBadArg, "Invalid filename" );
char* name = name_buf;
char* name = name_buf.data();
// name must start with letter or '_'
if( !cv_isalpha(*ptr) && *ptr!= '_' ){
@@ -237,7 +237,7 @@ String FileStorage::getDefaultObjectName(const String& _filename)
*name++ = c;
}
*name = '\0';
name = name_buf;
name = name_buf.data();
if( strcmp( name, "_" ) == 0 )
strcpy( name, stubname );
return String(name);
+4 -4
View File
@@ -542,7 +542,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
if( disttype == UNIFORM )
{
_parambuf.allocate(cn*8 + n1 + n2);
double* parambuf = _parambuf;
double* parambuf = _parambuf.data();
double* p1 = _param1.ptr<double>();
double* p2 = _param2.ptr<double>();
@@ -651,7 +651,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
else if( disttype == CV_RAND_NORMAL )
{
_parambuf.allocate(MAX(n1, cn) + MAX(n2, cn));
double* parambuf = _parambuf;
double* parambuf = _parambuf.data();
int ptype = depth == CV_64F ? CV_64F : CV_32F;
int esz = (int)CV_ELEM_SIZE(ptype);
@@ -701,7 +701,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
if( disttype == UNIFORM )
{
buf.allocate(blockSize*cn*4);
param = (uchar*)(double*)buf;
param = (uchar*)(double*)buf.data();
if( depth <= CV_32S )
{
@@ -738,7 +738,7 @@ void RNG::fill( InputOutputArray _mat, int disttype,
else
{
buf.allocate((blockSize*cn+1)/2);
nbuf = (float*)(double*)buf;
nbuf = (float*)(double*)buf.data();
}
for( size_t i = 0; i < it.nplanes; i++, ++it )
+1 -1
View File
@@ -485,7 +485,7 @@ void cv::split(const Mat& src, Mat* mv)
size_t esz = src.elemSize(), esz1 = src.elemSize1();
size_t blocksize0 = (BLOCK_SIZE + esz-1)/esz;
AutoBuffer<uchar> _buf((cn+1)*(sizeof(Mat*) + sizeof(uchar*)) + 16);
const Mat** arrays = (const Mat**)(uchar*)_buf;
const Mat** arrays = (const Mat**)_buf.data();
uchar** ptrs = (uchar**)alignPtr(arrays + cn + 1, 16);
arrays[0] = &src;
+1 -1
View File
@@ -617,7 +617,7 @@ cv::Scalar cv::sum( InputArray _src )
intSumBlockSize = depth <= CV_8S ? (1 << 23) : (1 << 15);
blockSize = std::min(blockSize, intSumBlockSize);
_buf.allocate(cn);
buf = _buf;
buf = _buf.data();
for( k = 0; k < cn; k++ )
buf[k] = 0;
+2 -2
View File
@@ -807,7 +807,7 @@ String format( const char* fmt, ... )
va_list va;
va_start(va, fmt);
int bsize = static_cast<int>(buf.size());
int len = cv_vsnprintf((char *)buf, bsize, fmt, va);
int len = cv_vsnprintf(buf.data(), bsize, fmt, va);
va_end(va);
CV_Assert(len >= 0 && "Check format string for errors");
@@ -817,7 +817,7 @@ String format( const char* fmt, ... )
continue;
}
buf[bsize - 1] = 0;
return String((char *)buf, len);
return String(buf.data(), len);
}
}
+2 -2
View File
@@ -502,7 +502,7 @@ UMat::UMat(const UMat& m, const Range& _rowRange, const Range& _colRange)
rs[1] = _colRange;
for( int i = 2; i < m.dims; i++ )
rs[i] = Range::all();
*this = m(rs);
*this = m(rs.data());
return;
}
@@ -805,7 +805,7 @@ UMat UMat::reshape(int _cn, int _newndims, const int* _newsz) const
UMat hdr = *this;
hdr.flags = (hdr.flags & ~CV_MAT_CN_MASK) | ((_cn-1) << CV_CN_SHIFT);
setSize(hdr, _newndims, (int*)newsz_buf, NULL, true);
setSize(hdr, _newndims, newsz_buf.data(), NULL, true);
return hdr;
}
+4 -4
View File
@@ -158,13 +158,13 @@ cv::String getcwd()
#else
DWORD sz = GetCurrentDirectoryA(0, NULL);
buf.allocate((size_t)sz);
sz = GetCurrentDirectoryA((DWORD)buf.size(), (char*)buf);
return cv::String((char*)buf, (size_t)sz);
sz = GetCurrentDirectoryA((DWORD)buf.size(), buf.data());
return cv::String(buf.data(), (size_t)sz);
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__
for(;;)
{
char* p = ::getcwd((char*)buf, buf.size());
char* p = ::getcwd(buf.data(), buf.size());
if (p == NULL)
{
if (errno == ERANGE)
@@ -176,7 +176,7 @@ cv::String getcwd()
}
break;
}
return cv::String((char*)buf, (size_t)strlen((char*)buf));
return cv::String(buf.data(), (size_t)strlen(buf.data()));
#else
return cv::String();
#endif
+3 -3
View File
@@ -374,9 +374,9 @@ TEST(Core_Rand, Regression_Stack_Corruption)
int bufsz = 128; //enough for 14 doubles
AutoBuffer<uchar> buffer(bufsz);
size_t offset = 0;
cv::Mat_<cv::Point2d> x(2, 3, (cv::Point2d*)(buffer+offset)); offset += x.total()*x.elemSize();
double& param1 = *(double*)(buffer+offset); offset += sizeof(double);
double& param2 = *(double*)(buffer+offset); offset += sizeof(double);
cv::Mat_<cv::Point2d> x(2, 3, (cv::Point2d*)(buffer.data()+offset)); offset += x.total()*x.elemSize();
double& param1 = *(double*)(buffer.data()+offset); offset += sizeof(double);
double& param2 = *(double*)(buffer.data()+offset); offset += sizeof(double);
param1 = -9; param2 = 2;
cv::theRNG().fill(x, cv::RNG::NORMAL, param1, param2);