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
This commit is contained in:
彭
2017-11-02 10:20:23 +08:00
committed by nihui
parent 1635460c50
commit a86cc8f620
+9 -20
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;
}