[vlc-commits] copy: do not copy more than the cache width on cache

Thomas Guillem git at videolan.org
Tue Jul 24 17:11:15 CEST 2018


vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Jul 24 11:09:41 2018 +0200| [ff4078ec719d7d99fa47a513a8fc0dd75e808bc2] | committer: Thomas Guillem

copy: do not copy more than the cache width on cache

(cherry picked from commit 09d421a20851e1c49aa98e117957dd118620fae4)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=ff4078ec719d7d99fa47a513a8fc0dd75e808bc2
---

 modules/video_chroma/copy.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
index a314ddf7a9..2baf076d53 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -469,6 +469,7 @@ static void SSE_CopyPlane(uint8_t *dst, size_t dst_pitch,
     const size_t copy_pitch = __MIN(src_pitch, dst_pitch);
     const unsigned w16 = (copy_pitch+15) & ~15;
     const unsigned hstep = cache_size / w16;
+    const unsigned cache_width = __MIN(src_pitch, hstep);
     assert(hstep > 0);
 
     /* If SSE4.1: CopyFromUswc is faster than memcpy */
@@ -479,7 +480,7 @@ static void SSE_CopyPlane(uint8_t *dst, size_t dst_pitch,
         const unsigned hblock =  __MIN(hstep, height - y);
 
         /* Copy a bunch of line into our cache */
-        CopyFromUswc(cache, w16, src, src_pitch, src_pitch, hblock, bitshift);
+        CopyFromUswc(cache, w16, src, src_pitch, cache_width, hblock, bitshift);
 
         /* Copy from our cache to the destination */
         Copy2d(dst, dst_pitch, cache, w16, copy_pitch, hblock);
@@ -501,6 +502,8 @@ SSE_InterleavePlanes(uint8_t *dst, size_t dst_pitch,
     size_t copy_pitch = __MIN(dst_pitch / 2, srcu_pitch);
     unsigned int const  w16 = (srcu_pitch+15) & ~15;
     unsigned int const  hstep = (cache_size) / (2*w16);
+    const unsigned cacheu_width = __MIN(srcu_pitch, hstep);
+    const unsigned cachev_width = __MIN(srcv_pitch, hstep);
     assert(hstep > 0);
 
     for (unsigned int y = 0; y < height; y += hstep)
@@ -508,9 +511,9 @@ SSE_InterleavePlanes(uint8_t *dst, size_t dst_pitch,
         unsigned int const      hblock = __MIN(hstep, height - y);
 
         /* Copy a bunch of line into our cache */
-        CopyFromUswc(cache, w16, srcu, srcu_pitch, srcu_pitch, hblock, bitshift);
+        CopyFromUswc(cache, w16, srcu, srcu_pitch, cacheu_width, hblock, bitshift);
         CopyFromUswc(cache+w16*hblock, w16, srcv, srcv_pitch,
-                     srcv_pitch, hblock, bitshift);
+                     cachev_width, hblock, bitshift);
 
         /* Copy from our cache to the destination */
         SSE_InterleaveUV(dst, dst_pitch, cache, w16,
@@ -533,13 +536,14 @@ static void SSE_SplitPlanes(uint8_t *dstu, size_t dstu_pitch,
     size_t copy_pitch = __MIN(__MIN(src_pitch / 2, dstu_pitch), dstv_pitch);
     const unsigned w16 = (src_pitch+15) & ~15;
     const unsigned hstep = cache_size / w16;
+    const unsigned cache_width = __MIN(src_pitch, hstep);
     assert(hstep > 0);
 
     for (unsigned y = 0; y < height; y += hstep) {
         const unsigned hblock =  __MIN(hstep, height - y);
 
         /* Copy a bunch of line into our cache */
-        CopyFromUswc(cache, w16, src, src_pitch, src_pitch, hblock, bitshift);
+        CopyFromUswc(cache, w16, src, src_pitch, cache_width, hblock, bitshift);
 
         /* Copy from our cache to the destination */
         SSE_SplitUV(dstu, dstu_pitch, dstv, dstv_pitch,



More information about the vlc-commits mailing list