]> git.sesse.net Git - vlc/blobdiff - modules/video_chroma/i420_yuy2.c
* modules/video_chroma/*: use .p2align instead of .align for data alignment,
[vlc] / modules / video_chroma / i420_yuy2.c
index 3aa2e995f0961df0fecaa3f6a0c5e62e39abaab1..37c2fd879090593adab0db03e9873f2d42c6ac7c 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * i420_yuy2.c : YUV to YUV conversion module for vlc
  *****************************************************************************
- * Copyright (C) 2000, 2001 VideoLAN
- * $Id: i420_yuy2.c,v 1.7 2004/01/27 03:22:03 titer Exp $
+ * Copyright (C) 2000, 2001 the VideoLAN team
+ * $Id$
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
 #include <vlc/vlc.h>
 #include <vlc/vout.h>
 
+#if defined (MODULE_NAME_IS_i420_yuy2_altivec) && defined(HAVE_ALTIVEC_H)
+#   include <altivec.h>
+#endif
+
 #include "i420_yuy2.h"
 
 #define SRC_FOURCC  "I420,IYUV,YV12"
@@ -79,7 +83,7 @@ vlc_module_begin();
     i_80w   = 0x0000000080808080ULL;
 #elif defined (MODULE_NAME_IS_i420_yuy2_altivec)
     set_description(
-            _("Altivec conversions from " SRC_FOURCC " to " DEST_FOURCC) );
+            _("AltiVec conversions from " SRC_FOURCC " to " DEST_FOURCC) );
     set_capability( "chroma", 100 );
     add_requirement( ALTIVEC );
 #endif
@@ -165,38 +169,7 @@ static void I420_YUY2( vout_thread_t *p_vout, picture_t *p_source,
 
     int i_x, i_y;
 
-#if !defined (MODULE_NAME_IS_i420_yuy2_altivec)
-    const int i_source_margin = p_source->p->i_pitch
-                                 - p_source->p->i_visible_pitch;
-    const int i_dest_margin = p_dest->p->i_pitch
-                               - p_dest->p->i_visible_pitch;
-
-    for( i_y = p_vout->render.i_height / 2 ; i_y-- ; )
-    {
-        p_line1 = p_line2;
-        p_line2 += p_dest->p->i_pitch;
-
-        p_y1 = p_y2;
-        p_y2 += p_source->p[Y_PLANE].i_pitch;
-
-        for( i_x = p_vout->render.i_width / 8 ; i_x-- ; )
-        {
-#if defined (MODULE_NAME_IS_i420_yuy2)
-            C_YUV420_YUYV( );
-            C_YUV420_YUYV( );
-            C_YUV420_YUYV( );
-            C_YUV420_YUYV( );
-#else
-            MMX_CALL( MMX_YUV420_YUYV );
-#endif
-        }
-
-        p_y1 += i_source_margin;
-        p_y2 += i_source_margin;
-        p_line1 += i_dest_margin;
-        p_line2 += i_dest_margin;
-    }
-#else
+#if defined (MODULE_NAME_IS_i420_yuy2_altivec)
 #define VEC_NEXT_LINES( ) \
     p_line1  = p_line2; \
     p_line2 += p_dest->p->i_pitch; \
@@ -221,7 +194,8 @@ static void I420_YUY2( vout_thread_t *p_vout, picture_t *p_source,
     vector unsigned char uv_vec;
     vector unsigned char y_vec;
 
-    if( !( p_vout->render.i_width % 32 ) )
+    if( !( ( p_vout->render.i_width % 32 ) |
+           ( p_vout->render.i_height % 2 ) ) )
     {
         /* Width is a multiple of 32, we take 2 lines at a time */
         for( i_y = p_vout->render.i_height / 2 ; i_y-- ; )
@@ -235,7 +209,8 @@ static void I420_YUY2( vout_thread_t *p_vout, picture_t *p_source,
             }
         }
     }
-    else
+    else if( !( ( p_vout->render.i_width % 16 ) |
+                ( p_vout->render.i_height % 4 ) ) )
     {
         /* Width is only a multiple of 16, we take 4 lines at a time */
         for( i_y = p_vout->render.i_height / 4 ; i_y-- ; )
@@ -266,9 +241,55 @@ static void I420_YUY2( vout_thread_t *p_vout, picture_t *p_source,
             }
         }
     }
+    else
+    {
+        /* Crap, use the C version */
 #undef VEC_NEXT_LINES
 #undef VEC_LOAD_UV
 #undef VEC_MERGE
+#endif
+
+    const int i_source_margin = p_source->p[0].i_pitch
+                                 - p_source->p[0].i_visible_pitch;
+    const int i_source_margin_c = p_source->p[1].i_pitch
+                                 - p_source->p[1].i_visible_pitch;
+    const int i_dest_margin = p_dest->p->i_pitch
+                               - p_dest->p->i_visible_pitch;
+
+    for( i_y = p_vout->render.i_height / 2 ; i_y-- ; )
+    {
+        p_line1 = p_line2;
+        p_line2 += p_dest->p->i_pitch;
+
+        p_y1 = p_y2;
+        p_y2 += p_source->p[Y_PLANE].i_pitch;
+
+#if !defined (MODULE_NAME_IS_i420_yuy2_mmx)
+        for( i_x = p_vout->render.i_width / 2 ; i_x-- ; )
+        {
+            C_YUV420_YUYV( );
+        }
+#else
+        for( i_x = p_vout->render.i_width / 8 ; i_x-- ; )
+        {
+            MMX_CALL( MMX_YUV420_YUYV );
+        }
+        for( i_x = ( p_vout->render.i_width % 8 ) / 2; i_x-- ; )
+        {
+            C_YUV420_YUYV( );
+        }
+#endif
+
+        p_y1 += i_source_margin;
+        p_y2 += i_source_margin;
+        p_u += i_source_margin_c;
+        p_v += i_source_margin_c;
+        p_line1 += i_dest_margin;
+        p_line2 += i_dest_margin;
+    }
+
+#if defined (MODULE_NAME_IS_i420_yuy2_altivec)
+    }
 #endif
 }
 
@@ -286,8 +307,10 @@ static void I420_YVYU( vout_thread_t *p_vout, picture_t *p_source,
 
     int i_x, i_y;
 
-    const int i_source_margin = p_source->p->i_pitch
-                                 - p_source->p->i_visible_pitch;
+    const int i_source_margin = p_source->p[0].i_pitch
+                                 - p_source->p[0].i_visible_pitch;
+    const int i_source_margin_c = p_source->p[1].i_pitch
+                                 - p_source->p[1].i_visible_pitch;
     const int i_dest_margin = p_dest->p->i_pitch
                                - p_dest->p->i_visible_pitch;
 
@@ -313,6 +336,8 @@ static void I420_YVYU( vout_thread_t *p_vout, picture_t *p_source,
 
         p_y1 += i_source_margin;
         p_y2 += i_source_margin;
+        p_u += i_source_margin_c;
+        p_v += i_source_margin_c;
         p_line1 += i_dest_margin;
         p_line2 += i_dest_margin;
     }
@@ -331,8 +356,10 @@ static void I420_UYVY( vout_thread_t *p_vout, picture_t *p_source,
 
     int i_x, i_y;
 
-    const int i_source_margin = p_source->p->i_pitch
-                                 - p_source->p->i_visible_pitch;
+    const int i_source_margin = p_source->p[0].i_pitch
+                                 - p_source->p[0].i_visible_pitch;
+    const int i_source_margin_c = p_source->p[1].i_pitch
+                                 - p_source->p[1].i_visible_pitch;
     const int i_dest_margin = p_dest->p->i_pitch
                                - p_dest->p->i_visible_pitch;
 
@@ -358,6 +385,8 @@ static void I420_UYVY( vout_thread_t *p_vout, picture_t *p_source,
 
         p_y1 += i_source_margin;
         p_y2 += i_source_margin;
+        p_u += i_source_margin_c;
+        p_v += i_source_margin_c;
         p_line1 += i_dest_margin;
         p_line2 += i_dest_margin;
     }
@@ -380,18 +409,20 @@ static void I420_cyuv( vout_thread_t *p_vout, picture_t *p_source,
                                               picture_t *p_dest )
 {
     uint8_t *p_line1 = p_dest->p->p_pixels +
-                       p_dest->p->i_lines * p_dest->p->i_pitch
+                       p_dest->p->i_visible_lines * p_dest->p->i_pitch
                        + p_dest->p->i_pitch;
     uint8_t *p_line2 = p_dest->p->p_pixels +
-                       p_dest->p->i_lines * p_dest->p->i_pitch;
+                       p_dest->p->i_visible_lines * p_dest->p->i_pitch;
     uint8_t *p_y1, *p_y2 = p_source->Y_PIXELS;
     uint8_t *p_u = p_source->U_PIXELS;
     uint8_t *p_v = p_source->V_PIXELS;
 
     int i_x, i_y;
 
-    const int i_source_margin = p_source->p->i_pitch
-                                 - p_source->p->i_visible_pitch;
+    const int i_source_margin = p_source->p[0].i_pitch
+                                 - p_source->p[0].i_visible_pitch;
+    const int i_source_margin_c = p_source->p[1].i_pitch
+                                 - p_source->p[1].i_visible_pitch;
     const int i_dest_margin = p_dest->p->i_pitch
                                - p_dest->p->i_visible_pitch;
 
@@ -417,6 +448,8 @@ static void I420_cyuv( vout_thread_t *p_vout, picture_t *p_source,
 
         p_y1 += i_source_margin;
         p_y2 += i_source_margin;
+        p_u += i_source_margin_c;
+        p_v += i_source_margin_c;
         p_line1 += i_dest_margin;
         p_line2 += i_dest_margin;
     }
@@ -437,8 +470,10 @@ static void I420_Y211( vout_thread_t *p_vout, picture_t *p_source,
 
     int i_x, i_y;
 
-    const int i_source_margin = p_source->p->i_pitch
-                                 - p_source->p->i_visible_pitch;
+    const int i_source_margin = p_source->p[0].i_pitch
+                                 - p_source->p[0].i_visible_pitch;
+    const int i_source_margin_c = p_source->p[1].i_pitch
+                                 - p_source->p[1].i_visible_pitch;
     const int i_dest_margin = p_dest->p->i_pitch
                                - p_dest->p->i_visible_pitch;
 
@@ -458,6 +493,8 @@ static void I420_Y211( vout_thread_t *p_vout, picture_t *p_source,
 
         p_y1 += i_source_margin;
         p_y2 += i_source_margin;
+        p_u += i_source_margin_c;
+        p_v += i_source_margin_c;
         p_line1 += i_dest_margin;
         p_line2 += i_dest_margin;
     }