]> git.sesse.net Git - vlc/blobdiff - plugins/motion/motion3dnow.c
* ALL: new module API. Makes a few things a lot simpler, and we gain
[vlc] / plugins / motion / motion3dnow.c
index cff28d99e262a672a8948678759d31515e9c6ed8..a94ebcd19c1a8380e604095920851459902ef7eb 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * motion3dnow.c : 3DNow! motion compensation module for vlc
+ * motion3dnow.c : 3D Now! motion compensation module for vlc
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: motion3dnow.c,v 1.5 2001/12/09 17:01:36 sam Exp $
+ * $Id: motion3dnow.c,v 1.12 2002/07/31 20:56:52 sam Exp $
  *
  * Authors: Aaron Holtzman <aholtzma@ess.engr.uvic.ca>
  *          Michel Lespinasse <walken@zoy.org>
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define MODULE_NAME motion3dnow
-#include "modules_inner.h"
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
 #include <stdlib.h>                                      /* malloc(), free() */
 #include <string.h>
 
-#include "common.h"                                     /* boolean_t, byte_t */
-#include "intf_msg.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"
+#include <vlc/vlc.h>
 
 #include "mmx.h"
 
-#include "modules.h"
-#include "modules_export.h"
-
 /*****************************************************************************
- * Local and extern prototypes.
+ * Local prototype.
  *****************************************************************************/
-static void motion_getfunctions( function_list_t * p_function_list );
+static int Open ( vlc_object_t * );
 
 /*****************************************************************************
- * Build configuration tree.
+ * Module descriptor
  *****************************************************************************/
-MODULE_CONFIG_START
-ADD_WINDOW( "Configuration for 3DNow! motion compensation module" )
-    ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
-MODULE_CONFIG_STOP
-
-MODULE_INIT_START
-    p_module->i_capabilities = MODULE_CAPABILITY_NULL
-                                | MODULE_CAPABILITY_MOTION;
-    p_module->psz_longname = "3DNow! motion compensation module";
-MODULE_INIT_STOP
-
-MODULE_ACTIVATE_START
-    motion_getfunctions( &p_module->p_functions->motion );
-MODULE_ACTIVATE_STOP
-
-MODULE_DEACTIVATE_START
-MODULE_DEACTIVATE_STOP
+vlc_module_begin();
+    set_description( _("3D Now! motion compensation module") );
+    set_capability( "motion compensation", 150 );
+    add_requirement( 3DNOW );
+    add_shortcut( "3dn" );
+    add_shortcut( "3dnow" );
+    set_callbacks( Open, NULL );
+vlc_module_end();
 
 /*****************************************************************************
- * motion_Probe: tests probe the CPU and return a score
- *****************************************************************************/
-static int motion_Probe( probedata_t *p_data )
-{
-    if( !TestCPU( CPU_CAPABILITY_3DNOW ) )
-    {
-        return( 0 );
-    }
-
-    if( TestMethod( MOTION_METHOD_VAR, "motion3dnow" )
-         || TestMethod( MOTION_METHOD_VAR, "3dnow" ) )
-    {
-        return( 999 );
-    }
-
-    return( 250 );
-}
-
-/*****************************************************************************
- * Motion compensation in 3DNow (OK I know this does MMXEXT too and it's ugly)
+ * Motion compensation in 3D Now! (OK I know this does MMXEXT too and it's ugly)
  *****************************************************************************/
 
 #define CPU_MMXEXT 0
@@ -119,7 +79,7 @@ do {                                                                        \
 //CPU_MMXEXT code
 
 
-static __inline__ void MC_put1_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_put1_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
                               int stride)
 {
     do {
@@ -130,7 +90,7 @@ static __inline__ void MC_put1_8 (int height, yuv_data_t * dest, yuv_data_t * re
     } while (--height);
 }
 
-static __inline__ void MC_put1_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_put1_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
                                int stride)
 {
     do {
@@ -143,7 +103,7 @@ static __inline__ void MC_put1_16 (int height, yuv_data_t * dest, yuv_data_t * r
     } while (--height);
 }
 
-static __inline__ void MC_avg1_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_avg1_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
                               int stride, int cpu)
 {
     do {
@@ -155,7 +115,7 @@ static __inline__ void MC_avg1_8 (int height, yuv_data_t * dest, yuv_data_t * re
     } while (--height);
 }
 
-static __inline__ void MC_avg1_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_avg1_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
                                int stride, int cpu)
 {
     do {
@@ -170,7 +130,7 @@ static __inline__ void MC_avg1_16 (int height, yuv_data_t * dest, yuv_data_t * r
     } while (--height);
 }
 
-static __inline__ void MC_put2_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_put2_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
                               int stride, int offset, int cpu)
 {
     do {
@@ -182,7 +142,7 @@ static __inline__ void MC_put2_8 (int height, yuv_data_t * dest, yuv_data_t * re
     } while (--height);
 }
 
-static __inline__ void MC_put2_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_put2_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
                                int stride, int offset, int cpu)
 {
     do {
@@ -197,7 +157,7 @@ static __inline__ void MC_put2_16 (int height, yuv_data_t * dest, yuv_data_t * r
     } while (--height);
 }
 
-static __inline__ void MC_avg2_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_avg2_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
                               int stride, int offset, int cpu)
 {
     do {
@@ -210,7 +170,7 @@ static __inline__ void MC_avg2_8 (int height, yuv_data_t * dest, yuv_data_t * re
     } while (--height);
 }
 
-static __inline__ void MC_avg2_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_avg2_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
                                int stride, int offset, int cpu)
 {
     do {
@@ -229,7 +189,7 @@ static __inline__ void MC_avg2_16 (int height, yuv_data_t * dest, yuv_data_t * r
 
 static mmx_t mask_one = {0x0101010101010101LL};
 
-static __inline__ void MC_put4_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_put4_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
                               int stride, int cpu)
 {
     movq_m2r (*ref, mm0);
@@ -268,7 +228,7 @@ static __inline__ void MC_put4_8 (int height, yuv_data_t * dest, yuv_data_t * re
     } while (--height);
 }
 
-static __inline__ void MC_put4_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_put4_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
                                int stride, int cpu)
 {
     do {
@@ -314,7 +274,7 @@ static __inline__ void MC_put4_16 (int height, yuv_data_t * dest, yuv_data_t * r
     } while (--height);
 }
 
-static __inline__ void MC_avg4_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_avg4_8 (int height, yuv_data_t * dest, yuv_data_t * ref,
                               int stride, int cpu)
 {
     do {
@@ -343,7 +303,7 @@ static __inline__ void MC_avg4_8 (int height, yuv_data_t * dest, yuv_data_t * re
     } while (--height);
 }
 
-static __inline__ void MC_avg4_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
+static inline void MC_avg4_16 (int height, yuv_data_t * dest, yuv_data_t * ref,
                                int stride, int cpu)
 {
     do {
@@ -590,41 +550,27 @@ static void MC_put_xy8_3dnow (yuv_data_t * dest, yuv_data_t * ref,
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-static void motion_getfunctions( function_list_t * p_function_list )
+static void (* ppppf_motion[2][2][4])( yuv_data_t *, yuv_data_t *, int, int ) =
 {
-    static void (* ppppf_motion[2][2][4])( yuv_data_t *, yuv_data_t *,
-                                           int, int ) =
+    /* Copying functions */
+    {
+        /* Width == 16 */
+        { MC_put_16_3dnow, MC_put_x16_3dnow, MC_put_y16_3dnow, MC_put_xy16_3dnow },
+        /* Width == 8 */
+        { MC_put_8_3dnow,  MC_put_x8_3dnow,  MC_put_y8_3dnow, MC_put_xy8_3dnow }
+    },
+    /* Averaging functions */
     {
-        {
-            /* Copying functions */
-            {
-                /* Width == 16 */
-                MC_put_16_3dnow, MC_put_x16_3dnow, MC_put_y16_3dnow, MC_put_xy16_3dnow
-            },
-            {
-                /* Width == 8 */
-                MC_put_8_3dnow,  MC_put_x8_3dnow,  MC_put_y8_3dnow, MC_put_xy8_3dnow
-            }
-        },
-        {
-            /* Averaging functions */
-            {
-                /* Width == 16 */
-                MC_avg_16_3dnow, MC_avg_x16_3dnow, MC_avg_y16_3dnow, MC_avg_xy16_3dnow
-            },
-            {
-                /* Width == 8 */
-                MC_avg_8_3dnow,  MC_avg_x8_3dnow,  MC_avg_y8_3dnow,  MC_avg_xy8_3dnow
-            }
-        }
-    };
-
-    p_function_list->pf_probe = motion_Probe;
-
-#define list p_function_list->functions.motion
-    memcpy( list.ppppf_motion, ppppf_motion, sizeof( void * ) * 16 );
-#undef list
-
-    return;
+        /* Width == 16 */
+        { MC_avg_16_3dnow, MC_avg_x16_3dnow, MC_avg_y16_3dnow, MC_avg_xy16_3dnow },
+        /* Width == 8 */
+        { MC_avg_8_3dnow,  MC_avg_x8_3dnow,  MC_avg_y8_3dnow,  MC_avg_xy8_3dnow }
+    }
+};
+
+static int Open ( vlc_object_t *p_this )
+{
+    p_this->p_private = ppppf_motion;
+    return VLC_SUCCESS;
 }