[vlc-devel] [PATCH 1/4] chroma: copy: fix copies which may lose the last line if it's an odd number.

Steve Lhomme robux4 at ycbcr.xyz
Tue Apr 17 15:02:14 CEST 2018


---
 modules/video_chroma/copy.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
index 9dcaf414e6..2857733c1d 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -572,7 +572,7 @@ static void SSE_Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2],
     SSE_CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch, src[0], src_pitch[0],
                   cache->buffer, cache->size, height, 0);
     SSE_CopyPlane(dst->p[1].p_pixels, dst->p[1].i_pitch, src[1], src_pitch[1],
-                  cache->buffer, cache->size, height / 2, 0);
+                  cache->buffer, cache->size, (height+1) / 2, 0);
     asm volatile ("emms");
 }
 
@@ -587,7 +587,7 @@ SSE_Copy420_SP_to_P(picture_t *dest, const uint8_t *src[static 2],
     SSE_SplitPlanes(dest->p[1].p_pixels, dest->p[1].i_pitch,
                     dest->p[2].p_pixels, dest->p[2].i_pitch,
                     src[1], src_pitch[1], cache->buffer, cache->size,
-                    height / 2, pixel_size, bitshift);
+                    (height+1) / 2, pixel_size, bitshift);
     asm volatile ("emms");
 }
 
@@ -601,7 +601,7 @@ static void SSE_Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3],
     SSE_InterleavePlanes(dst->p[1].p_pixels, dst->p[1].i_pitch,
                          src[U_PLANE], src_pitch[U_PLANE],
                          src[V_PLANE], src_pitch[V_PLANE],
-                         cache->buffer, cache->size, height / 2, pixel_size, bitshift);
+                         cache->buffer, cache->size, (height+1) / 2, pixel_size, bitshift);
     asm volatile ("emms");
 }
 #undef COPY64
@@ -672,7 +672,7 @@ void Copy420_SP_to_SP(picture_t *dst, const uint8_t *src[static 2],
     CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
               src[0], src_pitch[0], height, 0);
     CopyPlane(dst->p[1].p_pixels, dst->p[1].i_pitch,
-              src[1], src_pitch[1], height/2, 0);
+              src[1], src_pitch[1], (height+1)/2, 0);
 }
 
 #define SPLIT_PLANES(type, pitch_den) do { \
@@ -747,7 +747,7 @@ void Copy420_SP_to_P(picture_t *dst, const uint8_t *src[static 2],
               src[0], src_pitch[0], height, 0);
     SplitPlanes(dst->p[1].p_pixels, dst->p[1].i_pitch,
                 dst->p[2].p_pixels, dst->p[2].i_pitch,
-                src[1], src_pitch[1], height/2);
+                src[1], src_pitch[1], (height+1)/2);
 }
 
 void Copy420_16_SP_to_P(picture_t *dst, const uint8_t *src[static 2],
@@ -768,7 +768,7 @@ void Copy420_16_SP_to_P(picture_t *dst, const uint8_t *src[static 2],
               src[0], src_pitch[0], height, bitshift);
     SplitPlanes16(dst->p[1].p_pixels, dst->p[1].i_pitch,
                   dst->p[2].p_pixels, dst->p[2].i_pitch,
-                  src[1], src_pitch[1], height/2, bitshift);
+                  src[1], src_pitch[1], (height+1)/2, bitshift);
 }
 
 #define INTERLEAVE_UV() do { \
@@ -822,7 +822,7 @@ void Copy420_P_to_SP(picture_t *dst, const uint8_t *src[static 3],
     CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
               src[0], src_pitch[0], height, 0);
 
-    const unsigned copy_lines = height / 2;
+    const unsigned copy_lines = (height+1) / 2;
     const unsigned copy_pitch = src_pitch[1];
 
     const int i_extra_pitch_uv = dst->p[1].i_pitch - 2 * copy_pitch;
@@ -851,7 +851,7 @@ void Copy420_16_P_to_SP(picture_t *dst, const uint8_t *src[static 3],
     CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
               src[0], src_pitch[0], height, bitshift);
 
-    const unsigned copy_lines = height / 2;
+    const unsigned copy_lines = (height+1) / 2;
     const unsigned copy_pitch = src_pitch[1] / 2;
 
     const int i_extra_pitch_uv = dst->p[1].i_pitch / 2 - 2 * copy_pitch;
@@ -885,9 +885,9 @@ void Copy420_P_to_P(picture_t *dst, const uint8_t *src[static 3],
      CopyPlane(dst->p[0].p_pixels, dst->p[0].i_pitch,
                src[0], src_pitch[0], height, 0);
      CopyPlane(dst->p[1].p_pixels, dst->p[1].i_pitch,
-               src[1], src_pitch[1], height / 2, 0);
+               src[1], src_pitch[1], (height+1) / 2, 0);
      CopyPlane(dst->p[2].p_pixels, dst->p[2].i_pitch,
-               src[2], src_pitch[2], height / 2, 0);
+               src[2], src_pitch[2], (height+1) / 2, 0);
 }
 
 int picture_UpdatePlanes(picture_t *picture, uint8_t *data, unsigned pitch)
-- 
2.16.2



More information about the vlc-devel mailing list