mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge pull request #8064 from terfendail:sgbm_bigbuffer
This commit is contained in:
@@ -1418,6 +1418,14 @@ public:
|
||||
*/
|
||||
void reserve(size_t sz);
|
||||
|
||||
/** @brief Reserves space for the certain number of bytes.
|
||||
|
||||
The method reserves space for sz bytes. If the matrix already has enough space to store sz bytes,
|
||||
nothing happens. If matrix has to be reallocated its previous content could be lost.
|
||||
@param sz Number of bytes.
|
||||
*/
|
||||
void reserveBuffer(size_t sz);
|
||||
|
||||
/** @brief Changes the number of matrix rows.
|
||||
|
||||
The methods change the number of matrix rows. If the matrix is reallocated, the first
|
||||
|
||||
@@ -830,6 +830,32 @@ void Mat::reserve(size_t nelems)
|
||||
dataend = data + step.p[0]*r;
|
||||
}
|
||||
|
||||
void Mat::reserveBuffer(size_t nbytes)
|
||||
{
|
||||
size_t esz = 1;
|
||||
int mtype = CV_8UC1;
|
||||
if (!empty())
|
||||
{
|
||||
if (!isSubmatrix() && data + nbytes <= dataend)//Should it be datalimit?
|
||||
return;
|
||||
esz = elemSize();
|
||||
mtype = type();
|
||||
}
|
||||
|
||||
size_t nelems = (nbytes - 1) / esz + 1;
|
||||
|
||||
#if SIZE_MAX > UINT_MAX
|
||||
CV_Assert(nelems <= size_t(INT_MAX)*size_t(INT_MAX));
|
||||
int newrows = nelems > size_t(INT_MAX) ? nelems > 0x400*size_t(INT_MAX) ? nelems > 0x100000 * size_t(INT_MAX) ? nelems > 0x40000000 * size_t(INT_MAX) ?
|
||||
size_t(INT_MAX) : 0x40000000 : 0x100000 : 0x400 : 1;
|
||||
#else
|
||||
int newrows = nelems > size_t(INT_MAX) ? 2 : 1;
|
||||
#endif
|
||||
int newcols = (int)((nelems - 1) / newrows + 1);
|
||||
|
||||
create(newrows, newcols, mtype);
|
||||
}
|
||||
|
||||
|
||||
void Mat::resize(size_t nelems)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user