]> git.sesse.net Git - vlc/blobdiff - plugins/filter/clone.c
* ALL: changed "struct foo_s" into "struct foo_t" to make greppers happy.
[vlc] / plugins / filter / clone.c
index 2a85275a35aa1439e61d58bdee1268f068377693..2cd20cc0ae7eee27d4dd4e54643f99d6dbc23d21 100644 (file)
@@ -2,7 +2,7 @@
  * clone.c : Clone video plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: clone.c,v 1.2 2002/05/19 12:57:32 gbazin Exp $
+ * $Id: clone.c,v 1.8 2002/07/20 18:01:42 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
 #include <stdlib.h>                                      /* malloc(), free() */
 #include <string.h>
 
-#include <videolan/vlc.h>
-
-#include "video.h"
-#include "video_output.h"
+#include <vlc/vlc.h>
+#include <vlc/vout.h>
 
 #include "filter_common.h"
 
@@ -43,14 +41,20 @@ static void vout_getfunctions( function_list_t * p_function_list );
 /*****************************************************************************
  * Build configuration tree.
  *****************************************************************************/
+#define COUNT_TEXT N_("Number of clones")
+#define COUNT_LONGTEXT N_("Select the number of video windows in which to "\
+    "clone the video")
+
 MODULE_CONFIG_START
+ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
+ADD_INTEGER ( "clone-count", 2, NULL, COUNT_TEXT, COUNT_LONGTEXT )
 MODULE_CONFIG_STOP
 
 MODULE_INIT_START
     SET_DESCRIPTION( _("image clone video module") )
     /* Capability score set to 0 because we don't want to be spawned
      * as a video output unless explicitly requested to */
-    ADD_CAPABILITY( VOUT, 0 )
+    ADD_CAPABILITY( VOUT_FILTER, 0 )
     ADD_SHORTCUT( "clone" )
 MODULE_INIT_STOP
 
@@ -67,12 +71,11 @@ MODULE_DEACTIVATE_STOP
  * This structure is part of the video output thread descriptor.
  * It describes the Clone specific properties of an output thread.
  *****************************************************************************/
-typedef struct vout_sys_s
+struct vout_sys_t
 {
     int    i_clones;
     vout_thread_t **pp_vout;
-
-} vout_sys_t;
+};
 
 /*****************************************************************************
  * Local prototypes
@@ -109,56 +112,31 @@ static void vout_getfunctions( function_list_t * p_function_list )
  *****************************************************************************/
 static int vout_Create( vout_thread_t *p_vout )
 {
-    char *psz_method, *psz_method_orig;
 
     /* Allocate structure */
     p_vout->p_sys = malloc( sizeof( vout_sys_t ) );
     if( p_vout->p_sys == NULL )
     {
-        intf_ErrMsg( "vout error: out of memory" );
+        msg_Err( p_vout, "out of memory" );
         return( 1 );
     }
 
     /* Look what method was requested */
-    if( !(psz_method = psz_method_orig = config_GetPszVariable( "filter" )) )
-    {
-        intf_ErrMsg( "vout error: configuration variable %s empty", "filter" );
-        return( 1 );
-    }
-
-    while( *psz_method && *psz_method != ':' )
-    {
-        psz_method++;
-    }
-
-    if( *psz_method )
-    {
-        p_vout->p_sys->i_clones = atoi( psz_method + 1 );
-    }
-    else
-    {
-        intf_ErrMsg( "vout error: "
-                     "no valid clone count provided, using clone:2" );
-        p_vout->p_sys->i_clones = 2;
-    }
+    p_vout->p_sys->i_clones = config_GetInt( p_vout, "clone-count" );
 
     p_vout->p_sys->i_clones = __MAX( 1, __MIN( 99, p_vout->p_sys->i_clones ) );
 
-    intf_WarnMsg( 3, "vout info: spawning %i clone(s)",
-                  p_vout->p_sys->i_clones );
+    msg_Dbg( p_vout, "spawning %i clone(s)", p_vout->p_sys->i_clones );
 
     p_vout->p_sys->pp_vout = malloc( p_vout->p_sys->i_clones *
                                      sizeof(vout_thread_t *) );
     if( p_vout->p_sys->pp_vout == NULL )
     {
-        intf_ErrMsg( "vout error: out of memory" );
-        free( psz_method_orig );
+        msg_Err( p_vout, "out of memory" );
         free( p_vout->p_sys );
         return( 1 );
     }
 
-    free( psz_method_orig );
-
     return( 0 );
 }
 
@@ -168,7 +146,6 @@ static int vout_Create( vout_thread_t *p_vout )
 static int vout_Init( vout_thread_t *p_vout )
 {
     int   i_index, i_vout;
-    char *psz_filter;
     picture_t *p_pic;
     
     I_OUTPUTPICTURES = 0;
@@ -180,32 +157,24 @@ static int vout_Init( vout_thread_t *p_vout )
     p_vout->output.i_aspect = p_vout->render.i_aspect;
 
     /* Try to open the real video output */
-    psz_filter = config_GetPszVariable( "filter" );
-    config_PutPszVariable( "filter", NULL );
-
-    intf_WarnMsg( 3, "vout info: spawning the real video outputs" );
+    msg_Dbg( p_vout, "spawning the real video outputs" );
 
     for( i_vout = 0; i_vout < p_vout->p_sys->i_clones; i_vout++ )
     {
         p_vout->p_sys->pp_vout[ i_vout ] =
-                vout_CreateThread( NULL,
+                vout_CreateThread( p_vout,
                             p_vout->render.i_width, p_vout->render.i_height,
                             p_vout->render.i_chroma, p_vout->render.i_aspect );
         if( p_vout->p_sys->pp_vout[ i_vout ] == NULL )
         {
-            intf_ErrMsg( "vout error: failed to clone %i vout threads",
-                         p_vout->p_sys->i_clones );
+            msg_Err( p_vout, "failed to clone %i vout threads",
+                             p_vout->p_sys->i_clones );
             p_vout->p_sys->i_clones = i_vout;
             RemoveAllVout( p_vout );
-            config_PutPszVariable( "filter", psz_filter );
-            if( psz_filter ) free( psz_filter );
             return 0;
         }
     }
 
-    config_PutPszVariable( "filter", psz_filter );
-    if( psz_filter ) free( psz_filter );
-
     ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
 
     return( 0 );
@@ -297,7 +266,7 @@ static void vout_Render( vout_thread_t *p_vout, picture_t *p_pic )
 
             while( p_in < p_in_end )
             {
-                FAST_MEMCPY( p_out, p_in, i_out_pitch );
+                p_vout->p_vlc->pf_memcpy( p_out, p_in, i_out_pitch );
                 p_in += i_in_pitch;
                 p_out += i_out_pitch;
             }
@@ -328,8 +297,7 @@ static void RemoveAllVout( vout_thread_t *p_vout )
     while( p_vout->p_sys->i_clones )
     {
          --p_vout->p_sys->i_clones;
-         vout_DestroyThread(
-                   p_vout->p_sys->pp_vout[ p_vout->p_sys->i_clones ], NULL );
+         vout_DestroyThread( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
     }
 }