Browse Source

memcpy optimize copy_cut_border/copy_make_boder (#179)

* memcpy optimize copy_cut_border/copy_make_boder

* copy small border memcpy may slow

* remove unuse line

* code style
tags/20171225
nihui 8 years ago
parent
commit
a86cc8f620
1 changed files with 9 additions and 20 deletions
  1. +9
    -20
      src/mat.cpp

+ 9
- 20
src/mat.cpp View File

@@ -348,10 +348,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = v;
}
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
for (; x < w; x++)
{
outptr[x] = v;
@@ -381,10 +379,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = ptr[0];
}
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
for (; x < w; x++)
{
outptr[x] = ptr[src.w - 1];
@@ -399,10 +395,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = ptr[0];
}
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
for (; x < w; x++)
{
outptr[x] = ptr[src.w - 1];
@@ -419,10 +413,8 @@ static void copy_make_border_image(const Mat& src, Mat& dst, int top, int left,
{
outptr[x] = ptr[0];
}
for (; x < (left + src.w); x++)
{
outptr[x] = ptr[x - left];
}
memcpy(outptr + left, ptr, src.w * sizeof(float));
x += src.w;
for (; x < w; x++)
{
outptr[x] = ptr[src.w - 1];
@@ -481,10 +473,7 @@ static void copy_cut_border_image(const Mat& src, Mat& dst, int top, int left)

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


Loading…
Cancel
Save