]> git.sesse.net Git - vlc/blobdiff - plugins/yuv/yuv.c
The motion compensation routines are now modules as well ; choose your
[vlc] / plugins / yuv / yuv.c
index 712266250803cf7f1b9abd3f7246de5349e87cfd..772665ea44cc2bd779844d1e0db9ba9020d22ab6 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * yuv.c : C YUV functions for vlc
+ * yuv.c : C YUV module for vlc
  *****************************************************************************
  * Copyright (C) 2000 VideoLAN
  *
@@ -20,6 +20,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME yuv
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
 #include "common.h"                                     /* boolean_t, byte_t */
 #include "threads.h"
 #include "mtime.h"
-#include "tests.h"
-#include "plugins.h"
 
-#include "interface.h"
-#include "audio_output.h"
 #include "video.h"
 #include "video_output.h"
 
+#include "modules.h"
+#include "modules_inner.h"
+
 /*****************************************************************************
- * Exported prototypes
+ * Local and extern prototypes.
  *****************************************************************************/
-static void yuv_GetPlugin( p_vout_thread_t p_vout );
+extern void yuv_getfunctions( function_list_t * p_function_list );
 
-/* YUV transformations */
-int     yuv_CInit          ( p_vout_thread_t p_vout );
-int     yuv_CReset         ( p_vout_thread_t p_vout );
-void    yuv_CEnd           ( p_vout_thread_t p_vout );
+/*****************************************************************************
+ * Build configuration tree.
+ *****************************************************************************/
+MODULE_CONFIG_START
+ADD_WINDOW( "Configuration for YUV module" )
+    ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
+MODULE_CONFIG_END
 
 /*****************************************************************************
- * GetConfig: get the plugin structure and configuration
+ * InitModule: get the module structure and configuration.
+ *****************************************************************************
+ * We have to fill psz_name, psz_longname and psz_version. These variables
+ * will be strdup()ed later by the main application because the module can
+ * be unloaded later to save memory, and we want to be able to access this
+ * data even after the module has been unloaded.
  *****************************************************************************/
-plugin_info_t * GetConfig( void )
+int InitModule( module_t * p_module )
 {
-    plugin_info_t * p_info = (plugin_info_t *) malloc( sizeof(plugin_info_t) );
-
-    p_info->psz_name    = "C YUV to RGB transformations";
-    p_info->psz_version = VERSION;
-    p_info->psz_author  = "the VideoLAN team <vlc@videolan.org>";
+    p_module->psz_name = MODULE_STRING;
+    p_module->psz_longname = "YUV transformations module";
+    p_module->psz_version = VERSION;
 
-    p_info->aout_GetPlugin = NULL;
-    p_info->vout_GetPlugin = NULL;
-    p_info->intf_GetPlugin = NULL;
-    p_info->yuv_GetPlugin  = yuv_GetPlugin;
+    p_module->i_capabilities = MODULE_CAPABILITY_NULL
+                                | MODULE_CAPABILITY_YUV;
 
-    /* The C YUV functions should always work */
-    p_info->i_score = 0x100;
+    return( 0 );
+}
 
-    /* If this plugin was requested, score it higher */
-    if( TestMethod( YUV_METHOD_VAR, "nommx" ) )
+/*****************************************************************************
+ * ActivateModule: set the module to an usable state.
+ *****************************************************************************
+ * This function fills the capability functions and the configuration
+ * structure. Once ActivateModule() has been called, the i_usage can
+ * be set to 0 and calls to NeedModule() be made to increment it. To unload
+ * the module, one has to wait until i_usage == 0 and call DeactivateModule().
+ *****************************************************************************/
+int ActivateModule( module_t * p_module )
+{
+    p_module->p_functions = malloc( sizeof( module_functions_t ) );
+    if( p_module->p_functions == NULL )
     {
-        p_info->i_score += 0x200;
+        return( -1 );
     }
 
-    return( p_info );
+    yuv_getfunctions( &p_module->p_functions->yuv );
+
+    p_module->p_config = p_config;
+
+    return( 0 );
 }
 
 /*****************************************************************************
- * Following functions are only called through the p_info structure
+ * DeactivateModule: make sure the module can be unloaded.
+ *****************************************************************************
+ * This function must only be called when i_usage == 0. If it successfully
+ * returns, i_usage can be set to -1 and the module unloaded. Be careful to
+ * lock usage_lock during the whole process.
  *****************************************************************************/
-
-static void yuv_GetPlugin( p_vout_thread_t p_vout )
+int DeactivateModule( module_t * p_module )
 {
-    p_vout->p_yuv_init   = yuv_CInit;
-    p_vout->p_yuv_reset  = yuv_CReset;
-    p_vout->p_yuv_end    = yuv_CEnd;
+    free( p_module->p_functions );
+
+    return( 0 );
 }