Skip to content

Commit 0df8fb7

Browse files
committed
use bufferarea for allocating buffer
1 parent 920c180 commit 0df8fb7

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

modules/features2d/src/sift.simd.hpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373

7474
#include <opencv2/core/hal/hal.hpp>
7575
#include "opencv2/core/hal/intrin.hpp"
76+
#include <opencv2/core/utils/buffer_area.private.hpp>
7677

7778
namespace cv {
7879

@@ -167,23 +168,17 @@ float calcOrientationHist(
167168
int i, j, k, len = (radius*2+1)*(radius*2+1);
168169

169170
float expf_scale = -1.f/(2.f * sigma * sigma);
170-
#if CV_SIMD
171-
AutoBuffer<float> bufX(len + v_float32::nlanes);
172-
AutoBuffer<float> bufY(len + v_float32::nlanes);
173-
AutoBuffer<float> bufO(len + v_float32::nlanes);
174-
AutoBuffer<float> bufW(len + v_float32::nlanes);
175-
AutoBuffer<float> bufT(n+4 + v_float32::nlanes);
176-
float *X = alignPtr(bufX.data(), CV_SIMD_WIDTH);
177-
float *Y = alignPtr(bufY.data(), CV_SIMD_WIDTH);
178-
float *Mag = X;
179-
float *Ori = alignPtr(bufO.data(), CV_SIMD_WIDTH);
180-
float *W = alignPtr(bufW.data(), CV_SIMD_WIDTH);
181-
float *temphist = alignPtr(bufT.data(), CV_SIMD_WIDTH)+2;
182-
#else
183-
AutoBuffer<float> buf(len*4 + n+4);
184-
float *X = buf.data(), *Y = X + len, *Mag = X, *Ori = Y + len, *W = Ori + len;
185-
float* temphist = W + len + 2;
186-
#endif
171+
172+
cv::utils::BufferArea area;
173+
float *X = 0, *Y = 0, *Mag, *Ori = 0, *W = 0, *temphist = 0;
174+
area.allocate(X, len, CV_SIMD_WIDTH);
175+
area.allocate(Y, len, CV_SIMD_WIDTH);
176+
area.allocate(Ori, len, CV_SIMD_WIDTH);
177+
area.allocate(W, len, CV_SIMD_WIDTH);
178+
area.allocate(temphist, n+4, CV_SIMD_WIDTH);
179+
area.commit();
180+
temphist += 2;
181+
Mag = X;
187182

188183
for( i = 0; i < n; i++ )
189184
temphist[i] = 0.f;

0 commit comments

Comments
 (0)