Fixed vc1 packetizer.
[vlc.git] / modules / video_chroma / yuy2_i422.c
index a4e00ce..03d47fd 100644 (file)
@@ -31,6 +31,7 @@
 
 #include <vlc_common.h>
 #include <vlc_plugin.h>
+#include <vlc_filter.h>
 #include <vlc_vout.h>
 
 #define SRC_FOURCC "YUY2,YUNV,YVYU,UYVY,UYNV,Y422,cyuv"
  *****************************************************************************/
 static int  Activate ( vlc_object_t * );
 
-static void YUY2_I422           ( vout_thread_t *, picture_t *, picture_t * );
-static void YVYU_I422           ( vout_thread_t *, picture_t *, picture_t * );
-static void UYVY_I422           ( vout_thread_t *, picture_t *, picture_t * );
-static void cyuv_I422           ( vout_thread_t *, picture_t *, picture_t * );
+static void YUY2_I422           ( filter_t *, picture_t *, picture_t * );
+static void YVYU_I422           ( filter_t *, picture_t *, picture_t * );
+static void UYVY_I422           ( filter_t *, picture_t *, picture_t * );
+static void cyuv_I422           ( filter_t *, picture_t *, picture_t * );
+static picture_t *YUY2_I422_Filter    ( filter_t *, picture_t * );
+static picture_t *YVYU_I422_Filter    ( filter_t *, picture_t * );
+static picture_t *UYVY_I422_Filter    ( filter_t *, picture_t * );
+static picture_t *cyuv_I422_Filter    ( filter_t *, picture_t * );
 
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) );
-    set_capability( "chroma", 80 );
-    set_callbacks( Activate, NULL );
-vlc_module_end();
+vlc_module_begin ()
+    set_description( N_("Conversions from " SRC_FOURCC " to " DEST_FOURCC) )
+    set_capability( "video filter2", 80 )
+    set_callbacks( Activate, NULL )
+vlc_module_end ()
 
 /*****************************************************************************
  * Activate: allocate a chroma function
@@ -62,35 +67,40 @@ vlc_module_end();
  *****************************************************************************/
 static int Activate( vlc_object_t *p_this )
 {
-    vout_thread_t *p_vout = (vout_thread_t *)p_this;
+    filter_t *p_filter = (filter_t *)p_this;
 
-    if( p_vout->render.i_width & 1 || p_vout->render.i_height & 1 )
+    if( p_filter->fmt_in.video.i_width & 1
+     || p_filter->fmt_in.video.i_height & 1 )
     {
         return -1;
     }
 
-    switch( p_vout->output.i_chroma )
+    if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width
+     || p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height )
+        return -1;
+
+    switch( p_filter->fmt_out.video.i_chroma )
     {
         case VLC_FOURCC('I','4','2','2'):
-            switch( p_vout->render.i_chroma )
+            switch( p_filter->fmt_in.video.i_chroma )
             {
                 case VLC_FOURCC('Y','U','Y','2'):
                 case VLC_FOURCC('Y','U','N','V'):
-                    p_vout->chroma.pf_convert = YUY2_I422;
+                    p_filter->pf_video_filter = YUY2_I422_Filter;
                     break;
 
                 case VLC_FOURCC('Y','V','Y','U'):
-                    p_vout->chroma.pf_convert = YVYU_I422;
+                    p_filter->pf_video_filter = YVYU_I422_Filter;
                     break;
 
                 case VLC_FOURCC('U','Y','V','Y'):
                 case VLC_FOURCC('U','Y','N','V'):
                 case VLC_FOURCC('Y','4','2','2'):
-                    p_vout->chroma.pf_convert = UYVY_I422;
+                    p_filter->pf_video_filter = UYVY_I422_Filter;
                     break;
 
                 case VLC_FOURCC('c','y','u','v'):
-                    p_vout->chroma.pf_convert = cyuv_I422;
+                    p_filter->pf_video_filter = cyuv_I422_Filter;
                     break;
 
                 default:
@@ -106,11 +116,16 @@ static int Activate( vlc_object_t *p_this )
 
 /* Following functions are local */
 
+VIDEO_FILTER_WRAPPER( YUY2_I422 )
+VIDEO_FILTER_WRAPPER( YVYU_I422 )
+VIDEO_FILTER_WRAPPER( UYVY_I422 )
+VIDEO_FILTER_WRAPPER( cyuv_I422 )
+
 /*****************************************************************************
  * YUY2_I422: packed YUY2 4:2:2 to planar YUV 4:2:2
  *****************************************************************************/
-static void YUY2_I422( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void YUY2_I422( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -127,9 +142,9 @@ static void YUY2_I422( vout_thread_t *p_vout, picture_t *p_source,
     const int i_source_margin = p_source->p->i_pitch
                                - p_source->p->i_visible_pitch;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
-        for( i_x = p_vout->output.i_width / 8 ; i_x-- ; )
+        for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
         {
 #define C_YUYV_YUV422( p_line, p_y, p_u, p_v )      \
             *p_y++ = *p_line++; *p_u++ = *p_line++; \
@@ -139,7 +154,7 @@ static void YUY2_I422( vout_thread_t *p_vout, picture_t *p_source,
             C_YUYV_YUV422( p_line, p_y, p_u, p_v );
             C_YUYV_YUV422( p_line, p_y, p_u, p_v );
         }
-        for( i_x = ( p_vout->output.i_width % 8 ) / 2; i_x-- ; )
+        for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
         {
             C_YUYV_YUV422( p_line, p_y, p_u, p_v );
         }
@@ -153,8 +168,8 @@ static void YUY2_I422( vout_thread_t *p_vout, picture_t *p_source,
 /*****************************************************************************
  * YVYU_I422: packed YVYU 4:2:2 to planar YUV 4:2:2
  *****************************************************************************/
-static void YVYU_I422( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void YVYU_I422( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -171,9 +186,9 @@ static void YVYU_I422( vout_thread_t *p_vout, picture_t *p_source,
     const int i_source_margin = p_source->p->i_pitch
                                - p_source->p->i_visible_pitch;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
-        for( i_x = p_vout->output.i_width / 8 ; i_x-- ; )
+        for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
         {
 #define C_YVYU_YUV422( p_line, p_y, p_u, p_v )      \
             *p_y++ = *p_line++; *p_v++ = *p_line++; \
@@ -183,7 +198,7 @@ static void YVYU_I422( vout_thread_t *p_vout, picture_t *p_source,
             C_YVYU_YUV422( p_line, p_y, p_u, p_v );
             C_YVYU_YUV422( p_line, p_y, p_u, p_v );
         }
-        for( i_x = ( p_vout->output.i_width % 8 ) / 2; i_x-- ; )
+        for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
         {
             C_YVYU_YUV422( p_line, p_y, p_u, p_v );
         }
@@ -197,8 +212,8 @@ static void YVYU_I422( vout_thread_t *p_vout, picture_t *p_source,
 /*****************************************************************************
  * UYVY_I422: packed UYVY 4:2:2 to planar YUV 4:2:2
  *****************************************************************************/
-static void UYVY_I422( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void UYVY_I422( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -215,9 +230,9 @@ static void UYVY_I422( vout_thread_t *p_vout, picture_t *p_source,
     const int i_source_margin = p_source->p->i_pitch
                                - p_source->p->i_visible_pitch;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
-        for( i_x = p_vout->output.i_width / 8 ; i_x-- ; )
+        for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
         {
 #define C_UYVY_YUV422( p_line, p_y, p_u, p_v )      \
             *p_u++ = *p_line++; *p_y++ = *p_line++; \
@@ -227,7 +242,7 @@ static void UYVY_I422( vout_thread_t *p_vout, picture_t *p_source,
             C_UYVY_YUV422( p_line, p_y, p_u, p_v );
             C_UYVY_YUV422( p_line, p_y, p_u, p_v );
         }
-        for( i_x = ( p_vout->output.i_width % 8 ) / 2; i_x-- ; )
+        for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
         {
             C_UYVY_YUV422( p_line, p_y, p_u, p_v );
         }
@@ -242,8 +257,8 @@ static void UYVY_I422( vout_thread_t *p_vout, picture_t *p_source,
  * cyuv_I422: upside-down packed UYVY 4:2:2 to planar YUV 4:2:2
  * FIXME
  *****************************************************************************/
-static void cyuv_I422( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void cyuv_I422( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -260,9 +275,9 @@ static void cyuv_I422( vout_thread_t *p_vout, picture_t *p_source,
     const int i_source_margin = p_source->p->i_pitch
                                - p_source->p->i_visible_pitch;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
-        for( i_x = p_vout->output.i_width / 8 ; i_x-- ; )
+        for( i_x = p_filter->fmt_out.video.i_width / 8 ; i_x-- ; )
         {
 #define C_cyuv_YUV422( p_line, p_y, p_u, p_v )      \
             *p_y++ = *p_line++; *p_v++ = *p_line++; \
@@ -272,7 +287,7 @@ static void cyuv_I422( vout_thread_t *p_vout, picture_t *p_source,
             C_cyuv_YUV422( p_line, p_y, p_u, p_v );
             C_cyuv_YUV422( p_line, p_y, p_u, p_v );
         }
-        for( i_x = ( p_vout->output.i_width % 8 ) / 2; i_x-- ; )
+        for( i_x = ( p_filter->fmt_out.video.i_width % 8 ) / 2; i_x-- ; )
         {
             C_cyuv_YUV422( p_line, p_y, p_u, p_v );
         }