From ec3ef520e67b0d6c166e0f83bfa14130cf2ee135 Mon Sep 17 00:00:00 2001 From: Vincent Rabaud Date: Wed, 16 Dec 2020 17:27:55 +0100 Subject: [PATCH] Move big objects (>20k) from stack to heap. --- modules/imgproc/src/clahe.cpp | 4 +++- modules/imgproc/src/imgwarp.cpp | 3 ++- modules/imgproc/src/pyramids.cpp | 6 +++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/imgproc/src/clahe.cpp b/modules/imgproc/src/clahe.cpp index 45658ef..677b6a0 100644 --- a/modules/imgproc/src/clahe.cpp +++ b/modules/imgproc/src/clahe.cpp @@ -162,7 +162,9 @@ namespace // calc histogram - int tileHist[histSize] = {0, }; + cv::AutoBuffer _tileHist(histSize); + int* tileHist = _tileHist.data(); + std::fill(tileHist, tileHist + histSize, 0); int height = tileROI.height; const size_t sstep = src_.step / sizeof(T); diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 1575ffb..1665e0a 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -2167,7 +2167,8 @@ public: virtual void operator() (const Range& range) const CV_OVERRIDE { const int BLOCK_SZ = 64; - short XY[BLOCK_SZ*BLOCK_SZ*2], A[BLOCK_SZ*BLOCK_SZ]; + AutoBuffer __XY(BLOCK_SZ * BLOCK_SZ * 2), __A(BLOCK_SZ * BLOCK_SZ); + short *XY = __XY.data(), *A = __A.data(); const int AB_BITS = MAX(10, (int)INTER_BITS); const int AB_SCALE = 1 << AB_BITS; int round_delta = interpolation == INTER_NEAREST ? AB_SCALE/2 : AB_SCALE/INTER_TAB_SIZE/2, x, y, x1, y1; diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index ab6c8fd..4f77329 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -750,9 +750,9 @@ pyrDown_( const Mat& _src, Mat& _dst, int borderType ) Size ssize = _src.size(), dsize = _dst.size(); int cn = _src.channels(); - int tabL[CV_CN_MAX*(PD_SZ+2)], tabR[CV_CN_MAX*(PD_SZ+2)]; - AutoBuffer _tabM(dsize.width*cn); - int* tabM = _tabM.data(); + AutoBuffer _tabM(dsize.width * cn), _tabL(cn * (PD_SZ + 2)), + _tabR(cn * (PD_SZ + 2)); + int *tabM = _tabM.data(), *tabL = _tabL.data(), *tabR = _tabR.data(); CV_Assert( ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && -- 2.7.4