Fixed vc1 packetizer.
[vlc.git] / modules / video_chroma / yuy2_i420.c
index 37023af..3f3e882 100644 (file)
@@ -29,8 +29,9 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#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_I420           ( vout_thread_t *, picture_t *, picture_t * );
-static void YVYU_I420           ( vout_thread_t *, picture_t *, picture_t * );
-static void UYVY_I420           ( vout_thread_t *, picture_t *, picture_t * );
-static void cyuv_I420           ( vout_thread_t *, picture_t *, picture_t * );
+static void YUY2_I420           ( filter_t *, picture_t *, picture_t * );
+static void YVYU_I420           ( filter_t *, picture_t *, picture_t * );
+static void UYVY_I420           ( filter_t *, picture_t *, picture_t * );
+static void cyuv_I420           ( filter_t *, picture_t *, picture_t * );
+
+static picture_t *YUY2_I420_Filter    ( filter_t *, picture_t * );
+static picture_t *YVYU_I420_Filter    ( filter_t *, picture_t * );
+static picture_t *UYVY_I420_Filter    ( filter_t *, picture_t * );
+static picture_t *cyuv_I420_Filter    ( filter_t *, picture_t * );
 
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( _("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 +68,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','0'):
-            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_I420;
+                    p_filter->pf_video_filter = YUY2_I420_Filter;
                     break;
 
                 case VLC_FOURCC('Y','V','Y','U'):
-                    p_vout->chroma.pf_convert = YVYU_I420;
+                    p_filter->pf_video_filter = YVYU_I420_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_I420;
+                    p_filter->pf_video_filter = UYVY_I420_Filter;
                     break;
 
                 case VLC_FOURCC('c','y','u','v'):
-                    p_vout->chroma.pf_convert = cyuv_I420;
+                    p_filter->pf_video_filter = cyuv_I420_Filter;
                     break;
 
                 default:
@@ -105,12 +116,16 @@ static int Activate( vlc_object_t *p_this )
 }
 
 /* Following functions are local */
+VIDEO_FILTER_WRAPPER( YUY2_I420 )
+VIDEO_FILTER_WRAPPER( YVYU_I420 )
+VIDEO_FILTER_WRAPPER( UYVY_I420 )
+VIDEO_FILTER_WRAPPER( cyuv_I420 )
 
 /*****************************************************************************
  * YUY2_I420: packed YUY2 4:2:2 to planar YUV 4:2:0
  *****************************************************************************/
-static void YUY2_I420( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void YUY2_I420( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -129,11 +144,11 @@ static void YUY2_I420( vout_thread_t *p_vout, picture_t *p_source,
 
     bool b_skip = false;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
         if( b_skip )
         {
-            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_skip( p_line, p_y, p_u, p_v )      \
                 *p_y++ = *p_line++; p_line++; \
@@ -143,14 +158,14 @@ static void YUY2_I420( vout_thread_t *p_vout, picture_t *p_source,
                 C_YUYV_YUV422_skip( p_line, p_y, p_u, p_v );
                 C_YUYV_YUV422_skip( 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_skip( p_line, p_y, p_u, p_v );
             }
         }
         else
         {
-            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++; \
@@ -160,7 +175,7 @@ static void YUY2_I420( 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 );
             }
@@ -177,8 +192,8 @@ static void YUY2_I420( vout_thread_t *p_vout, picture_t *p_source,
 /*****************************************************************************
  * YVYU_I420: packed YVYU 4:2:2 to planar YUV 4:2:0
  *****************************************************************************/
-static void YVYU_I420( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void YVYU_I420( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -197,11 +212,11 @@ static void YVYU_I420( vout_thread_t *p_vout, picture_t *p_source,
 
     bool b_skip = false;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
         if( b_skip )
         {
-            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_skip( p_line, p_y, p_u, p_v )      \
                 *p_y++ = *p_line++; p_line++; \
@@ -211,14 +226,14 @@ static void YVYU_I420( vout_thread_t *p_vout, picture_t *p_source,
                 C_YVYU_YUV422_skip( p_line, p_y, p_u, p_v );
                 C_YVYU_YUV422_skip( 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_skip( p_line, p_y, p_u, p_v );
             }
         }
         else
         {
-            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++; \
@@ -228,7 +243,7 @@ static void YVYU_I420( 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 );
             }
@@ -245,8 +260,8 @@ static void YVYU_I420( vout_thread_t *p_vout, picture_t *p_source,
 /*****************************************************************************
  * UYVY_I420: packed UYVY 4:2:2 to planar YUV 4:2:0
  *****************************************************************************/
-static void UYVY_I420( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void UYVY_I420( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -265,11 +280,11 @@ static void UYVY_I420( vout_thread_t *p_vout, picture_t *p_source,
 
     bool b_skip = false;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
         if( b_skip )
         {
-            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_skip( p_line, p_y, p_u, p_v )      \
                 *p_u++ = *p_line++; p_line++; \
@@ -279,14 +294,14 @@ static void UYVY_I420( vout_thread_t *p_vout, picture_t *p_source,
                 C_UYVY_YUV422_skip( p_line, p_y, p_u, p_v );
                 C_UYVY_YUV422_skip( 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_skip( p_line, p_y, p_u, p_v );
             }
         }
         else
         {
-            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++; \
@@ -296,7 +311,7 @@ static void UYVY_I420( 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 );
             }
@@ -314,8 +329,8 @@ static void UYVY_I420( vout_thread_t *p_vout, picture_t *p_source,
  * cyuv_I420: upside-down packed UYVY 4:2:2 to planar YUV 4:2:0
  * FIXME
  *****************************************************************************/
-static void cyuv_I420( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void cyuv_I420( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
 
@@ -334,11 +349,11 @@ static void cyuv_I420( vout_thread_t *p_vout, picture_t *p_source,
 
     bool b_skip = false;
 
-    for( i_y = p_vout->output.i_height ; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height ; i_y-- ; )
     {
         if( b_skip )
         {
-            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_skip( p_line, p_y, p_u, p_v )      \
                 *p_y++ = *p_line++; p_line++; \
@@ -348,14 +363,14 @@ static void cyuv_I420( vout_thread_t *p_vout, picture_t *p_source,
                 C_cyuv_YUV422_skip( p_line, p_y, p_u, p_v );
                 C_cyuv_YUV422_skip( 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_skip( p_line, p_y, p_u, p_v );
             }
         }
         else
         {
-            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++; \
@@ -365,7 +380,7 @@ static void cyuv_I420( 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 );
             }