]> git.sesse.net Git - vlc/blobdiff - modules/video_chroma/i422_yuy2.c
* all: use the data_packet_count from the asf header when the server
[vlc] / modules / video_chroma / i422_yuy2.c
index 2b50b840a359bc4e0464661fc7ca6162902ed3c1..7d22e982ad071c358f9d969717c03240d14cb629 100644 (file)
@@ -2,7 +2,7 @@
  * i422_yuy2.c : YUV to YUV conversion module for vlc
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: i422_yuy2.c,v 1.1 2002/08/04 17:23:43 sam Exp $
+ * $Id: i422_yuy2.c,v 1.5 2004/01/25 17:20:18 kuehne Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -24,7 +24,6 @@
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <errno.h>                                                 /* ENOMEM */
 #include <string.h>                                            /* strerror() */
 #include <stdlib.h>                                      /* malloc(), free() */
 
@@ -52,6 +51,8 @@ static void I422_IUYV           ( vout_thread_t *, picture_t *, picture_t * );
 static void I422_cyuv           ( vout_thread_t *, picture_t *, picture_t * );
 #if defined (MODULE_NAME_IS_i422_yuy2)
 static void I422_Y211           ( vout_thread_t *, picture_t *, picture_t * );
+static void I422_Y211           ( vout_thread_t *, picture_t *, picture_t * );
+static void I422_YV12           ( vout_thread_t *, picture_t *, picture_t * );
 #endif
 
 /*****************************************************************************
@@ -59,7 +60,7 @@ static void I422_Y211           ( vout_thread_t *, picture_t *, picture_t * );
  *****************************************************************************/
 vlc_module_begin();
 #if defined (MODULE_NAME_IS_i422_yuy2)
-    set_description( _("conversions from " SRC_FOURCC " to " DEST_FOURCC) );
+    set_description( _("Conversions from " SRC_FOURCC " to " DEST_FOURCC) );
     set_capability( "chroma", 80 );
 #elif defined (MODULE_NAME_IS_i422_yuy2_mmx)
     set_description( _("MMX conversions from " SRC_FOURCC " to " DEST_FOURCC) );
@@ -115,6 +116,10 @@ static int Activate( vlc_object_t *p_this )
                 case VLC_FOURCC('Y','2','1','1'):
                     p_vout->chroma.pf_convert = I422_Y211;
                     break;
+
+                case VLC_FOURCC('Y','V','1','2'):
+                    p_vout->chroma.pf_convert = I422_YV12;
+                    break;
 #endif
 
                 default:
@@ -137,10 +142,10 @@ static int Activate( vlc_object_t *p_this )
 static void I422_YUY2( vout_thread_t *p_vout, picture_t *p_source,
                                               picture_t *p_dest )
 {
-    u8 *p_line = p_dest->p->p_pixels;
-    u8 *p_y = p_source->Y_PIXELS;
-    u8 *p_u = p_source->U_PIXELS;
-    u8 *p_v = p_source->V_PIXELS;
+    uint8_t *p_line = p_dest->p->p_pixels;
+    uint8_t *p_y = 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;
 
@@ -174,10 +179,10 @@ static void I422_YUY2( vout_thread_t *p_vout, picture_t *p_source,
 static void I422_YVYU( vout_thread_t *p_vout, picture_t *p_source,
                                               picture_t *p_dest )
 {
-    u8 *p_line = p_dest->p->p_pixels;
-    u8 *p_y = p_source->Y_PIXELS;
-    u8 *p_u = p_source->U_PIXELS;
-    u8 *p_v = p_source->V_PIXELS;
+    uint8_t *p_line = p_dest->p->p_pixels;
+    uint8_t *p_y = 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;
 
@@ -211,10 +216,10 @@ static void I422_YVYU( vout_thread_t *p_vout, picture_t *p_source,
 static void I422_UYVY( vout_thread_t *p_vout, picture_t *p_source,
                                               picture_t *p_dest )
 {
-    u8 *p_line = p_dest->p->p_pixels;
-    u8 *p_y = p_source->Y_PIXELS;
-    u8 *p_u = p_source->U_PIXELS;
-    u8 *p_v = p_source->V_PIXELS;
+    uint8_t *p_line = p_dest->p->p_pixels;
+    uint8_t *p_y = 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;
 
@@ -258,10 +263,10 @@ static void I422_IUYV( vout_thread_t *p_vout, picture_t *p_source,
 static void I422_cyuv( vout_thread_t *p_vout, picture_t *p_source,
                                               picture_t *p_dest )
 {
-    u8 *p_line = p_dest->p->p_pixels + p_dest->p->i_lines * p_dest->p->i_pitch;
-    u8 *p_y = p_source->Y_PIXELS;
-    u8 *p_u = p_source->U_PIXELS;
-    u8 *p_v = p_source->V_PIXELS;
+    uint8_t *p_line = p_dest->p->p_pixels + p_dest->p->i_lines * p_dest->p->i_pitch;
+    uint8_t *p_y = 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;
 
@@ -298,10 +303,10 @@ static void I422_cyuv( vout_thread_t *p_vout, picture_t *p_source,
 static void I422_Y211( vout_thread_t *p_vout, picture_t *p_source,
                                               picture_t *p_dest )
 {
-    u8 *p_line = p_dest->p->p_pixels + p_dest->p->i_lines * p_dest->p->i_pitch;
-    u8 *p_y = p_source->Y_PIXELS;
-    u8 *p_u = p_source->U_PIXELS;
-    u8 *p_v = p_source->V_PIXELS;
+    uint8_t *p_line = p_dest->p->p_pixels + p_dest->p->i_lines * p_dest->p->i_pitch;
+    uint8_t *p_y = 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;
 
@@ -316,3 +321,35 @@ static void I422_Y211( vout_thread_t *p_vout, picture_t *p_source,
 }
 #endif
 
+
+/*****************************************************************************
+ * I422_YV12: planar YUV 4:2:2 to planar YV12
+ *****************************************************************************/
+#if defined (MODULE_NAME_IS_i422_yuy2)
+static void I422_YV12( vout_thread_t *p_vout, picture_t *p_source,
+                                              picture_t *p_dest )
+{
+    uint16_t i_dpy = p_dest->p[Y_PLANE].i_pitch;
+    uint16_t i_spy = p_source->p[Y_PLANE].i_pitch;
+    uint16_t i_dpuv = p_dest->p[U_PLANE].i_pitch;
+    uint16_t i_spuv = p_source->p[U_PLANE].i_pitch;
+    uint16_t i_width = p_vout->render.i_width;
+    uint16_t i_y = p_vout->render.i_height;
+    uint8_t *p_dy = p_dest->Y_PIXELS + (i_y-1)*i_dpy;
+    uint8_t *p_y = p_source->Y_PIXELS + (i_y-1)*i_spy;
+    uint8_t *p_du = p_dest->U_PIXELS + (i_y/2-1)*i_dpuv;
+    uint8_t *p_u = p_source->U_PIXELS + (i_y-1)*i_spuv;
+    uint8_t *p_dv = p_dest->V_PIXELS + (i_y/2-1)*i_dpuv;
+    uint8_t *p_v = p_source->V_PIXELS + (i_y-1)*i_spuv;
+    i_y /= 2;
+
+    for ( ; i_y--; )
+    {
+        memcpy(p_dy, p_y, i_width); p_dy -= i_dpy; p_y -= i_spy;
+        memcpy(p_dy, p_y, i_width); p_dy -= i_dpy; p_y -= i_spy;
+        memcpy(p_du, p_u, i_width/2); p_du -= i_dpuv; p_u -= 2*i_spuv;
+        memcpy(p_dv, p_v, i_width/2); p_dv -= i_dpuv; p_v -= 2*i_spuv;
+    }
+
+}
+#endif