Move big objects (>20k) from stack to heap.
authorVincent Rabaud <vrabaud@google.com>
Wed, 16 Dec 2020 16:27:55 +0000 (17:27 +0100)
committerVincent Rabaud <vrabaud@google.com>
Thu, 17 Dec 2020 08:36:51 +0000 (09:36 +0100)
modules/imgproc/src/clahe.cpp
modules/imgproc/src/imgwarp.cpp
modules/imgproc/src/pyramids.cpp

index 45658ef..677b6a0 100644 (file)
@@ -162,7 +162,9 @@ namespace
 
             // calc histogram
 
-            int tileHist[histSize] = {0, };
+            cv::AutoBuffer<int> _tileHist(histSize);
+            int* tileHist = _tileHist.data();
+            std::fill(tileHist, tileHist + histSize, 0);
 
             int height = tileROI.height;
             const size_t sstep = src_.step / sizeof(T);
index 1575ffb..1665e0a 100644 (file)
@@ -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<short, 0> __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;
index ab6c8fd..4f77329 100644 (file)
@@ -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<int> _tabM(dsize.width*cn);
-    int* tabM = _tabM.data();
+    AutoBuffer<int> _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 &&