[vlc-devel] [PATCH 2/2] i420_yuy2: only handle visible pixels

Steve Lhomme robux4 at videolabs.io
Tue Mar 8 16:45:22 CET 2016


---
 modules/video_chroma/i422_yuy2.c | 89 ++++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 40 deletions(-)

diff --git a/modules/video_chroma/i422_yuy2.c b/modules/video_chroma/i422_yuy2.c
index 9099cfc..e23c163 100644
--- a/modules/video_chroma/i422_yuy2.c
+++ b/modules/video_chroma/i422_yuy2.c
@@ -96,8 +96,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;
     }
@@ -170,11 +170,14 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
     int i_x, i_y;
 
     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 );
     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_i422_yuy2_sse2)
 
@@ -182,13 +185,13 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
         ((intptr_t)p_line|(intptr_t)p_y))) )
     {
         /* use faster SSE2 aligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
         {
-            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_YUV422_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_YUV422_YUYV( p_line, p_y, p_u, p_v );
             }
@@ -200,13 +203,13 @@ static void I422_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 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
         {
-            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_YUV422_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_YUV422_YUYV( p_line, p_y, p_u, p_v );
             }
@@ -220,9 +223,9 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
 
 #else
 
-    for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
     {
-        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_i422_yuy2)
             C_YUV422_YUYV( p_line, p_y, p_u, p_v );
@@ -233,7 +236,7 @@ static void I422_YUY2( filter_t *p_filter, picture_t *p_source,
             MMX_CALL( MMX_YUV422_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_YUV422_YUYV( p_line, p_y, p_u, p_v );
         }
@@ -264,11 +267,14 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
     int i_x, i_y;
 
     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 );
     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_i422_yuy2_sse2)
 
@@ -276,13 +282,13 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
         ((intptr_t)p_line|(intptr_t)p_y))) )
     {
         /* use faster SSE2 aligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
         {
-            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_YUV422_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_YUV422_YVYU( p_line, p_y, p_u, p_v );
             }
@@ -294,13 +300,13 @@ static void I422_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 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
         {
-            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_YUV422_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_YUV422_YVYU( p_line, p_y, p_u, p_v );
             }
@@ -314,9 +320,9 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
 
 #else
 
-    for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
     {
-        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_i422_yuy2)
             C_YUV422_YVYU( p_line, p_y, p_u, p_v );
@@ -327,7 +333,7 @@ static void I422_YVYU( filter_t *p_filter, picture_t *p_source,
             MMX_CALL( MMX_YUV422_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_YUV422_YVYU( p_line, p_y, p_u, p_v );
         }
@@ -358,11 +364,14 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
     int i_x, i_y;
 
     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 );
     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_i422_yuy2_sse2)
 
@@ -370,13 +379,13 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
         ((intptr_t)p_line|(intptr_t)p_y))) )
     {
         /* use faster SSE2 aligned fetch and store */
-        for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
         {
-            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_YUV422_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_YUV422_UYVY( p_line, p_y, p_u, p_v );
             }
@@ -388,13 +397,13 @@ static void I422_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 ; i_y-- ; )
+        for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
         {
-            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_YUV422_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_YUV422_UYVY( p_line, p_y, p_u, p_v );
             }
@@ -408,9 +417,9 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
 
 #else
 
-    for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
     {
-        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_i422_yuy2)
             C_YUV422_UYVY( p_line, p_y, p_u, p_v );
@@ -421,7 +430,7 @@ static void I422_UYVY( filter_t *p_filter, picture_t *p_source,
             MMX_CALL( MMX_YUV422_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_YUV422_UYVY( p_line, p_y, p_u, p_v );
         }
@@ -462,9 +471,9 @@ static void I422_Y211( filter_t *p_filter, picture_t *p_source,
 
     int i_x, i_y;
 
-    for( i_y = p_filter->fmt_in.video.i_height ; i_y-- ; )
+    for( i_y = (p_filter->fmt_in.video.i_y_offset + p_filter->fmt_in.video.i_visible_height) ; i_y-- ; )
     {
-        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_YUV422_Y211( p_line, p_y, p_u, p_v );
             C_YUV422_Y211( p_line, p_y, p_u, p_v );
-- 
2.7.2.windows.1



More information about the vlc-devel mailing list