Browse Source

no memcpy for small size copy_cut_border/copy_make_boder

tags/20171225
peng nihui 8 years ago
parent
commit
39445b5233
1 changed files with 59 additions and 9 deletions
  1. +59
    -9
      src/mat.cpp

+ 59
- 9
src/mat.cpp View File

@@ -348,8 +348,18 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = v;
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
if (src.w < 12)
{
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
}
else
{
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
}
for (; x < w; x++)
{
outptr[x] = v;
@@ -379,8 +389,18 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = ptr[0];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
if(src.w < 12)
{
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
}
else
{
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
}
for (; x < w; x++)
{
outptr[x] = ptr[src.w - 1];
@@ -395,8 +415,18 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = ptr[0];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
if(src.w < 12)
{
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
}
else
{
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
}
for (; x < w; x++)
{
outptr[x] = ptr[src.w - 1];
@@ -413,8 +443,18 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = ptr[0];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
if(src.w < 12)
{
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
}
else
{
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
}
for (; x < w; x++)
{
outptr[x] = ptr[src.w - 1];
@@ -473,7 +513,17 @@ static void copy_cut_border_image(const Mat& src, Mat& dst, int top, int left)

for (int y = 0; y < h; y++)
{
memcpy(outptr, ptr, w*sizeof(float));
if(w < 12)
{
for (int x = 0; x < w; x++)
{
outptr[x] = ptr[x];
}
}
else
{
memcpy(outptr, ptr, w*sizeof(float));
}
outptr += w;
ptr += src.w;
}


Loading…
Cancel
Save