[vlc-devel] [PATCH 2/2] i420_yuy2: fix using buffer areas not visible

Steve Lhomme robux4 at videolabs.io
Tue Mar 8 14:52:09 CET 2016


fixes #16686
--
should be backported on 2.2 as well
replaces https://patches.videolan.org/patch/12575/ by handling the offset, the height
and fixing the margin to apply to go to the next line
---
 modules/video_chroma/i420_yuy2.c | 127 ++++++++++++++++++++-------------------
 1 file changed, 65 insertions(+), 62 deletions(-)

diff --git a/modules/video_chroma/i420_yuy2.c b/modules/video_chroma/i420_yuy2.c
index ff0ddd3..a03aa21 100644
--- a/modules/video_chroma/i420_yuy2.c
+++ b/modules/video_chroma/i420_yuy2.c
@@ -119,8 +119,8 @@ static int Activate( vlc_object_t *p_this )
 
     if( !vlc_CPU_capable() )
         return VLC_EGENERIC;
-    if( p_filter->fmt_in.video.i_width & 1
-     || p_filter->fmt_in.video.i_height & 1 )
+    if( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) & 1
+     || (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) & 1 )
     {
         return -1;
     }
@@ -232,14 +232,14 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
     vector unsigned char uv_vec;
     vector unsigned char y_vec;
 
-    if( !( ( p_filter->fmt_in.video.i_width % 32 ) |
-           ( p_filter->fmt_in.video.i_height % 2 ) ) )
+    if( !( ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 32 ) |
+           ( (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) % 2 ) ) )
     {
         /* Width is a multiple of 32, we take 2 lines at a time */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             VEC_NEXT_LINES( );
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -249,15 +249,15 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
     }
 #warning FIXME: converting widths % 16 but !widths % 32 is broken on altivec
 #if 0
-    else if( !( ( p_filter->fmt_in.video.i_width % 16 ) |
-                ( p_filter->fmt_in.video.i_height % 4 ) ) )
+    else if( !( ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) |
+                ( (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) % 4 ) ) )
     {
         /* Width is only a multiple of 16, we take 4 lines at a time */
-        for( i_y = p_filter->fmt_in.video.i_height / 4 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 4 ; i_y-- ; )
         {
             /* Line 1 and 2, pixels 0 to ( width - 16 ) */
             VEC_NEXT_LINES( );
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -273,7 +273,7 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
             VEC_MERGE( vec_mergel );
 
             /* Line 3 and 4, pixels 16 to ( width ) */
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -291,14 +291,17 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
 #endif
 
     const int i_source_margin = p_source->p[0].i_pitch
-                                 - p_source->p[0].i_visible_pitch;
+                                 - p_source->p[0].i_visible_pitch
+                                 - p_filter->fmt_in.video.i_x_offset;
     const int i_source_margin_c = p_source->p[1].i_pitch
-                                 - p_source->p[1].i_visible_pitch;
+                                 - p_source->p[1].i_visible_pitch
+                                 - ( p_filter->fmt_in.video.i_x_offset / 2 );
     const int i_dest_margin = p_dest->p->i_pitch
-                               - p_dest->p->i_visible_pitch;
+                               - p_dest->p->i_visible_pitch
+                               - ( p_filter->fmt_out.video.i_x_offset * 2 );
 
 #if !defined(MODULE_NAME_IS_i420_yuy2_sse2)
-    for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
     {
         p_line1 = p_line2;
         p_line2 += p_dest->p->i_pitch;
@@ -307,7 +310,7 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
         p_y2 += p_source->p[Y_PLANE].i_pitch;
 
 #if !defined (MODULE_NAME_IS_i420_yuy2_mmx)
-        for( i_x = p_filter->fmt_in.video.i_width / 8; i_x-- ; )
+        for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8; i_x-- ; )
         {
             C_YUV420_YUYV( );
             C_YUV420_YUYV( );
@@ -315,12 +318,12 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
             C_YUV420_YUYV( );
         }
 #else
-        for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; )
+        for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
         {
             MMX_CALL( MMX_YUV420_YUYV );
         }
 #endif
-        for( i_x = ( p_filter->fmt_in.video.i_width % 8 ) / 2; i_x-- ; )
+        for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 8 ) / 2; i_x-- ; )
         {
             C_YUV420_YUYV( );
         }
@@ -350,7 +353,7 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
         ((intptr_t)p_line2|(intptr_t)p_y2))) )
     {
         /* use faster SSE2 aligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             p_line1 = p_line2;
             p_line2 += p_dest->p->i_pitch;
@@ -358,11 +361,11 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
             p_y1 = p_y2;
             p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-            for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
             {
                 SSE2_CALL( SSE2_YUV420_YUYV_ALIGNED );
             }
-            for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; )
+            for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
             {
                 C_YUV420_YUYV( );
             }
@@ -376,7 +379,7 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
     else
     {
         /* use slower SSE2 unaligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             p_line1 = p_line2;
             p_line2 += p_dest->p->i_pitch;
@@ -384,11 +387,11 @@ static void I420_YUY2( filter_t *p_filter, picture_t *p_source,
             p_y1 = p_y2;
             p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-            for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
             {
                 SSE2_CALL( SSE2_YUV420_YUYV_UNALIGNED );
             }
-            for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; )
+            for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
             {
                 C_YUV420_YUYV( );
             }
@@ -444,14 +447,14 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
     vector unsigned char vu_vec;
     vector unsigned char y_vec;
 
-    if( !( ( p_filter->fmt_in.video.i_width % 32 ) |
-           ( p_filter->fmt_in.video.i_height % 2 ) ) )
+    if( !( ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 32 ) |
+           ( (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) % 2 ) ) )
     {
         /* Width is a multiple of 32, we take 2 lines at a time */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             VEC_NEXT_LINES( );
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -459,15 +462,15 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
             }
         }
     }
-    else if( !( ( p_filter->fmt_in.video.i_width % 16 ) |
-                ( p_filter->fmt_in.video.i_height % 4 ) ) )
+    else if( !( ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) |
+                ( (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) % 4 ) ) )
     {
         /* Width is only a multiple of 16, we take 4 lines at a time */
-        for( i_y = p_filter->fmt_in.video.i_height / 4 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 4 ; i_y-- ; )
         {
             /* Line 1 and 2, pixels 0 to ( width - 16 ) */
             VEC_NEXT_LINES( );
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -483,7 +486,7 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
             VEC_MERGE( vec_mergel );
 
             /* Line 3 and 4, pixels 16 to ( width ) */
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -507,7 +510,7 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
                                - p_dest->p->i_visible_pitch;
 
 #if !defined(MODULE_NAME_IS_i420_yuy2_sse2)
-    for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
     {
         p_line1 = p_line2;
         p_line2 += p_dest->p->i_pitch;
@@ -515,7 +518,7 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
         p_y1 = p_y2;
         p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-        for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; )
+        for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
         {
 #if !defined (MODULE_NAME_IS_i420_yuy2_mmx)
             C_YUV420_YVYU( );
@@ -526,7 +529,7 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
             MMX_CALL( MMX_YUV420_YVYU );
 #endif
         }
-        for( i_x = ( p_filter->fmt_in.video.i_width % 8 ) / 2; i_x-- ; )
+        for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 8 ) / 2; i_x-- ; )
         {
             C_YUV420_YVYU( );
         }
@@ -557,7 +560,7 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
         ((intptr_t)p_line2|(intptr_t)p_y2))) )
     {
         /* use faster SSE2 aligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             p_line1 = p_line2;
             p_line2 += p_dest->p->i_pitch;
@@ -565,11 +568,11 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
             p_y1 = p_y2;
             p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-            for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
             {
                 SSE2_CALL( SSE2_YUV420_YVYU_ALIGNED );
             }
-            for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; )
+            for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
             {
                 C_YUV420_YVYU( );
             }
@@ -585,7 +588,7 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
     else
     {
         /* use slower SSE2 unaligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             p_line1 = p_line2;
             p_line2 += p_dest->p->i_pitch;
@@ -593,11 +596,11 @@ static void I420_YVYU( filter_t *p_filter, picture_t *p_source,
             p_y1 = p_y2;
             p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-            for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
             {
                 SSE2_CALL( SSE2_YUV420_YVYU_UNALIGNED );
             }
-            for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; )
+            for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
             {
                 C_YUV420_YVYU( );
             }
@@ -654,14 +657,14 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
     vector unsigned char uv_vec;
     vector unsigned char y_vec;
 
-    if( !( ( p_filter->fmt_in.video.i_width % 32 ) |
-           ( p_filter->fmt_in.video.i_height % 2 ) ) )
+    if( !( ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 32 ) |
+           ( (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) % 2 ) ) )
     {
         /* Width is a multiple of 32, we take 2 lines at a time */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             VEC_NEXT_LINES( );
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -669,15 +672,15 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
             }
         }
     }
-    else if( !( ( p_filter->fmt_in.video.i_width % 16 ) |
-                ( p_filter->fmt_in.video.i_height % 4 ) ) )
+    else if( !( ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) |
+                ( (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) % 4 ) ) )
     {
         /* Width is only a multiple of 16, we take 4 lines at a time */
-        for( i_y = p_filter->fmt_in.video.i_height / 4 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 4 ; i_y-- ; )
         {
             /* Line 1 and 2, pixels 0 to ( width - 16 ) */
             VEC_NEXT_LINES( );
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -693,7 +696,7 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
             VEC_MERGE( vec_mergel );
 
             /* Line 3 and 4, pixels 16 to ( width ) */
-            for( i_x = p_filter->fmt_in.video.i_width / 32 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 32 ; i_x-- ; )
             {
                 VEC_LOAD_UV( );
                 VEC_MERGE( vec_mergeh );
@@ -717,7 +720,7 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
                                - p_dest->p->i_visible_pitch;
 
 #if !defined(MODULE_NAME_IS_i420_yuy2_sse2)
-    for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
     {
         p_line1 = p_line2;
         p_line2 += p_dest->p->i_pitch;
@@ -725,7 +728,7 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
         p_y1 = p_y2;
         p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-        for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; )
+        for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
         {
 #if !defined (MODULE_NAME_IS_i420_yuy2_mmx)
             C_YUV420_UYVY( );
@@ -736,7 +739,7 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
             MMX_CALL( MMX_YUV420_UYVY );
 #endif
         }
-        for( i_x = ( p_filter->fmt_in.video.i_width % 8 ) / 2; i_x--; )
+        for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 8 ) / 2; i_x--; )
         {
             C_YUV420_UYVY( );
         }
@@ -767,7 +770,7 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
         ((intptr_t)p_line2|(intptr_t)p_y2))) )
     {
         /* use faster SSE2 aligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             p_line1 = p_line2;
             p_line2 += p_dest->p->i_pitch;
@@ -775,11 +778,11 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
             p_y1 = p_y2;
             p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-            for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
             {
                 SSE2_CALL( SSE2_YUV420_UYVY_ALIGNED );
             }
-            for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; )
+            for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
             {
                 C_YUV420_UYVY( );
             }
@@ -795,7 +798,7 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
     else
     {
         /* use slower SSE2 unaligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
         {
             p_line1 = p_line2;
             p_line2 += p_dest->p->i_pitch;
@@ -803,11 +806,11 @@ static void I420_UYVY( filter_t *p_filter, picture_t *p_source,
             p_y1 = p_y2;
             p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-            for( i_x = p_filter->fmt_in.video.i_width / 16 ; i_x-- ; )
+            for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 16 ; i_x-- ; )
             {
                 SSE2_CALL( SSE2_YUV420_UYVY_UNALIGNED );
             }
-            for( i_x = ( p_filter->fmt_in.video.i_width % 16 ) / 2; i_x-- ; )
+            for( i_x = ( (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) % 16 ) / 2; i_x-- ; )
             {
                 C_YUV420_UYVY( );
             }
@@ -859,7 +862,7 @@ static void I420_Y211( filter_t *p_filter, picture_t *p_source,
     const int i_dest_margin = p_dest->p->i_pitch
                                - p_dest->p->i_visible_pitch;
 
-    for( i_y = p_filter->fmt_in.video.i_height / 2 ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) / 2 ; i_y-- ; )
     {
         p_line1 = p_line2;
         p_line2 += p_dest->p->i_pitch;
@@ -867,7 +870,7 @@ static void I420_Y211( filter_t *p_filter, picture_t *p_source,
         p_y1 = p_y2;
         p_y2 += p_source->p[Y_PLANE].i_pitch;
 
-        for( i_x = p_filter->fmt_in.video.i_width / 8 ; i_x-- ; )
+        for( i_x = (p_filter->fmt_in.video.i_x_offset + p_filter->fmt_in.video.i_visible_width) / 8 ; i_x-- ; )
         {
             C_YUV420_Y211( );
             C_YUV420_Y211( );
-- 
2.7.2.windows.1



More information about the vlc-devel mailing list