copy: do one big memcpy when possible
authorSteve Lhomme <robUx4@videolabs.io>
Thu, 28 Jul 2016 12:45:39 +0000 (14:45 +0200)
committerJean-Baptiste Kempf <jb@videolan.org>
Thu, 28 Jul 2016 22:32:38 +0000 (00:32 +0200)
modules/video_chroma/copy.c

index cdeb96c..fa0a212 100644 (file)
@@ -270,6 +270,9 @@ static void SSE_CopyPlane(uint8_t *dst, size_t dst_pitch,
     const unsigned hstep = cache_size / w16;
     assert(hstep > 0);
 
+    if (src_pitch == dst_pitch)
+        memcpy(dst, src, width * height);
+    else
     for (unsigned y = 0; y < height; y += hstep) {
         const unsigned hblock =  __MIN(hstep, height - y);
 
@@ -407,6 +410,9 @@ static void CopyPlane(uint8_t *dst, size_t dst_pitch,
                       const uint8_t *src, size_t src_pitch,
                       unsigned width, unsigned height)
 {
+    if (src_pitch == dst_pitch)
+        memcpy(dst, src, width * height);
+    else
     for (unsigned y = 0; y < height; y++) {
         memcpy(dst, src, width);
         src += src_pitch;