Fixed vc1 packetizer.
[vlc.git] / modules / video_chroma / grey_yuv.c
index 95a3b67..99e150c 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * grey_yuv.c : grayscale to others conversion module for vlc
  *****************************************************************************
- * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2007, 2008 the VideoLAN team
  * $Id$
  *
  * Authors: Sam Hocevar <sam@zoy.org>
@@ -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  "GREY"
  *****************************************************************************/
 static int  Activate ( vlc_object_t * );
 
-static void GREY_I420           ( vout_thread_t *, picture_t *, picture_t * );
-static void GREY_YUY2           ( vout_thread_t *, picture_t *, picture_t * );
+static void GREY_I420( filter_t *, picture_t *, picture_t * );
+static void GREY_YUY2( filter_t *, picture_t *, picture_t * );
+
+static picture_t *GREY_I420_Filter( filter_t *, picture_t * );
+static picture_t *GREY_YUY2_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
@@ -60,25 +64,30 @@ 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_out.video.i_width & 1
+     || p_filter->fmt_out.video.i_height & 1 )
     {
         return -1;
     }
 
-    switch( p_vout->render.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_in.video.i_chroma )
     {
         case VLC_FOURCC('Y','8','0','0'):
-            p_vout->render.i_chroma = VLC_FOURCC('G','R','E','Y');
+            p_filter->fmt_in.video.i_chroma = VLC_FOURCC('G','R','E','Y');
         case VLC_FOURCC('G','R','E','Y'):
-            switch( p_vout->output.i_chroma )
+            switch( p_filter->fmt_out.video.i_chroma )
             {
                 case VLC_FOURCC('I','4','2','0'):
-                    p_vout->chroma.pf_convert = GREY_I420;
+                    p_filter->pf_video_filter = GREY_I420_Filter;
                     break;
                 case VLC_FOURCC('Y','U','Y','2'):
-                    p_vout->chroma.pf_convert = GREY_YUY2;
+                    p_filter->pf_video_filter = GREY_YUY2_Filter;
                     break;
                 default:
                     return -1;
@@ -92,13 +101,16 @@ static int Activate( vlc_object_t *p_this )
     return 0;
 }
 
+VIDEO_FILTER_WRAPPER( GREY_I420 )
+VIDEO_FILTER_WRAPPER( GREY_YUY2 )
+
 /* Following functions are local */
 
 /*****************************************************************************
  * GREY_I420: 8-bit grayscale to planar YUV 4:2:0
  *****************************************************************************/
-static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void GREY_I420( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_line = p_source->p->p_pixels;
     uint8_t *p_y = p_dest->Y_PIXELS;
@@ -114,7 +126,7 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
     const int i_dest_margin_c = p_dest->p[1].i_pitch
                                  - p_dest->p[1].i_visible_pitch;
 
-    for( i_y = p_vout->render.i_height / 2; i_y-- ; )
+    for( i_y = p_filter->fmt_in.video.i_height / 2; i_y-- ; )
     {
         memset(p_u, 0x80, p_dest->p[1].i_visible_pitch);
         p_u += i_dest_margin_c;
@@ -123,9 +135,9 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
         p_v += i_dest_margin_c;
     }
 
-    for( i_y = p_vout->render.i_height; i_y-- ; )
+    for( i_y = p_filter->fmt_in.video.i_height; i_y-- ; )
     {
-        for( i_x = p_vout->render.i_width / 8; i_x-- ; )
+        for( i_x = p_filter->fmt_in.video.i_width / 8; i_x-- ; )
         {
             *p_y++ = *p_line++; *p_y++ = *p_line++;
             *p_y++ = *p_line++; *p_y++ = *p_line++;
@@ -133,7 +145,7 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
             *p_y++ = *p_line++; *p_y++ = *p_line++;
         }
 
-        for( i_x = p_vout->render.i_width % 8; i_x-- ; )
+        for( i_x = p_filter->fmt_in.video.i_width % 8; i_x-- ; )
         {
             *p_y++ = *p_line++;
         }
@@ -146,8 +158,8 @@ static void GREY_I420( vout_thread_t *p_vout, picture_t *p_source,
 /*****************************************************************************
  * GREY_YUY2: 8-bit grayscale to packed YUY2
  *****************************************************************************/
-static void GREY_YUY2( vout_thread_t *p_vout, picture_t *p_source,
-                                              picture_t *p_dest )
+static void GREY_YUY2( filter_t *p_filter, picture_t *p_source,
+                                           picture_t *p_dest )
 {
     uint8_t *p_in = p_source->p->p_pixels;
     uint8_t *p_out = p_dest->p->p_pixels;
@@ -159,9 +171,9 @@ static void GREY_YUY2( vout_thread_t *p_vout, picture_t *p_source,
     const int i_dest_margin = p_dest->p->i_pitch
                                - p_dest->p->i_visible_pitch;
 
-    for( i_y = p_vout->render.i_height; i_y-- ; )
+    for( i_y = p_filter->fmt_out.video.i_height; i_y-- ; )
     {
-        for( i_x = p_vout->render.i_width / 8; i_x-- ; )
+        for( i_x = p_filter->fmt_out.video.i_width / 8; i_x-- ; )
         {
             *p_out++ = *p_in++; *p_out++ = 0x80;
             *p_out++ = *p_in++; *p_out++ = 0x80;
@@ -173,7 +185,7 @@ static void GREY_YUY2( vout_thread_t *p_vout, picture_t *p_source,
             *p_out++ = *p_in++; *p_out++ = 0x80;
         }
 
-        for( i_x = (p_vout->render.i_width % 8) / 2; i_x-- ; )
+        for( i_x = (p_filter->fmt_out.video.i_width % 8) / 2; i_x-- ; )
         {
             *p_out++ = *p_in++; *p_out++ = 0x80;
             *p_out++ = *p_in++; *p_out++ = 0x80;