]> git.sesse.net Git - vlc/blobdiff - plugins/idct/idctmmxext.c
Found bug in configure.in script Qt Embedded definition used $(QTDIR) i.s.o ${QTDIR}
[vlc] / plugins / idct / idctmmxext.c
index 017f177effc15c7464e4b4ca4f0577cc492629d9..36cc71782244a83db11b38297dbd8e2ad4467012 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * idctmmxext.c : MMX EXT IDCT module
  *****************************************************************************
- * Copyright (C) 1999, 2000 VideoLAN
- * $Id: idctmmxext.c,v 1.4 2001/01/17 18:17:30 massiot Exp $
+ * Copyright (C) 1999-2001 VideoLAN
+ * $Id: idctmmxext.c,v 1.23 2002/05/18 17:47:46 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 idctmmxext
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "defs.h"
-
 #include <stdlib.h>
+#include <string.h>
 
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
-#include "tests.h"                                              /* TestCPU() */
-
-#include "video.h"
-#include "video_output.h"
+#include <videolan/vlc.h>
 
-#include "video_decoder.h"
-
-#include "modules.h"
-#include "modules_inner.h"
+#include "mmx.h"
 
 #include "idct.h"
-
-#include "attributes.h"
-#include "mmx.h"
+#include "block_mmx.h"
 
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
 static void idct_getfunctions( function_list_t * p_function_list );
-static int  idct_Probe      ( probedata_t *p_data );
-static void vdec_NormScan   ( u8 ppi_scan[2][64] );
-
 
 /*****************************************************************************
  * Build configuration tree.
  *****************************************************************************/
 MODULE_CONFIG_START
-ADD_WINDOW( "Configuration for MMX EXT IDCT module" )
-    ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
-MODULE_CONFIG_END
-
-/*****************************************************************************
- * 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.
- *****************************************************************************/
-int InitModule( module_t * p_module )
-{
-    p_module->psz_name = MODULE_STRING;
-    p_module->psz_longname = "MMX EXT IDCT module";
-    p_module->psz_version = VERSION;
-
-    p_module->i_capabilities = MODULE_CAPABILITY_NULL
-                                | MODULE_CAPABILITY_IDCT;
-
-    return( 0 );
-}
+MODULE_CONFIG_STOP
 
-/*****************************************************************************
- * 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 )
-    {
-        return( -1 );
-    }
+MODULE_INIT_START
+    SET_DESCRIPTION( _("MMX EXT IDCT module") )
+    ADD_CAPABILITY( IDCT, 200 )
+    ADD_REQUIREMENT( MMXEXT )
+    ADD_SHORTCUT( "mmxext" )
+    ADD_SHORTCUT( "idctmmxext" )
+MODULE_INIT_STOP
 
+MODULE_ACTIVATE_START
     idct_getfunctions( &p_module->p_functions->idct );
+MODULE_ACTIVATE_STOP
 
-    p_module->p_config = p_config;
-
-    return( 0 );
-}
-
-/*****************************************************************************
- * 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.
- *****************************************************************************/
-int DeactivateModule( module_t * p_module )
-{
-    free( p_module->p_functions );
-
-    return( 0 );
-}
+MODULE_DEACTIVATE_START
+MODULE_DEACTIVATE_STOP
 
 /* Following functions are local */
 
 /*****************************************************************************
- * Functions exported as capabilities.
- *****************************************************************************/
-static void idct_getfunctions( function_list_t * p_function_list )
-{
-    p_function_list->pf_probe = idct_Probe;
-    p_function_list->functions.idct.pf_init = vdec_InitIDCT;
-    p_function_list->functions.idct.pf_sparse_idct = vdec_SparseIDCT;
-    p_function_list->functions.idct.pf_idct = vdec_IDCT;
-    p_function_list->functions.idct.pf_norm_scan = vdec_NormScan;
-}
-
-/*****************************************************************************
- * idct_Probe: return a preference score
+ * NormScan : This IDCT uses reordered coeffs, so we patch the scan table
  *****************************************************************************/
-static int idct_Probe( probedata_t *p_data )
-{
-    if( TestCPU( CPU_CAPABILITY_MMXEXT ) )
-    {
-        if( TestMethod( IDCT_METHOD_VAR, "idctmmxext" ) )
-        {
-            return( 999 );
-        }
-        else
-        {
-            return( 200 );
-        }
-    }
-    else
-    {
-        return( 0 );
-    }
-}
-
-/*****************************************************************************
- * vdec_NormScan : This IDCT uses reordered coeffs, so we patch the scan table
- *****************************************************************************/
-static void vdec_NormScan( u8 ppi_scan[2][64] )
+static void NormScan( u8 ppi_scan[2][64] )
 {
     int     i, j;
 
@@ -180,7 +84,7 @@ static void vdec_NormScan( u8 ppi_scan[2][64] )
 }
 
 /*****************************************************************************
- * vdec_IDCT :
+ * IDCT :
  *****************************************************************************/
 #define ROW_SHIFT 11
 #define COL_SHIFT 6
@@ -197,7 +101,7 @@ static void vdec_NormScan( u8 ppi_scan[2][64] )
                                             c5, -c1,  c3, -c1,   \
                                             c7,  c3,  c7, -c5 }
 
-static __inline__ void RowHead( dctelem_t * row, int offset, dctelem_t * table )
+static inline void RowHead( dctelem_t * row, int offset, dctelem_t * table )
 {
     movq_m2r (*(row+offset), mm2);      // mm2 = x6 x4 x2 x0
 
@@ -213,7 +117,7 @@ static __inline__ void RowHead( dctelem_t * row, int offset, dctelem_t * table )
     pshufw_r2r (mm2, mm2, 0x4e);        // mm2 = x2 x0 x6 x4
 }
 
-static __inline__ void Row( dctelem_t * table, s32 * rounder )
+static inline void Row( dctelem_t * table, s32 * rounder )
 {
     movq_m2r (*(table+8), mm1);         // mm1 = -C5 -C1 C3 C1
     pmaddwd_r2r (mm2, mm4);             // mm4 = C4*x0+C6*x2 C4*x4+C6*x6
@@ -252,7 +156,7 @@ static __inline__ void Row( dctelem_t * table, s32 * rounder )
     psubd_r2r (mm5, mm4);               // mm4 = a3-b3 a2-b2 + rounder
 }
 
-static __inline__ void RowTail( dctelem_t * row, int store )
+static inline void RowTail( dctelem_t * row, int store )
 {
     psrad_i2r (ROW_SHIFT, mm0);         // mm0 = y3 y2
 
@@ -269,8 +173,8 @@ static __inline__ void RowTail( dctelem_t * row, int store )
     movq_r2m (mm4, *(row+store+4));     // save y7 y6 y5 y4
 }
 
-static __inline__ void RowMid( dctelem_t * row, int store,
-                               int offset, dctelem_t * table)
+static inline void RowMid( dctelem_t * row, int store,
+                           int offset, dctelem_t * table)
 {
     movq_m2r (*(row+offset), mm2);      // mm2 = x6 x4 x2 x0
     psrad_i2r (ROW_SHIFT, mm0);         // mm0 = y3 y2
@@ -296,7 +200,7 @@ static __inline__ void RowMid( dctelem_t * row, int store,
     pshufw_r2r (mm2, mm2, 0x4e);        // mm2 = x2 x0 x6 x4
 }
 
-static __inline__ void Col( dctelem_t * col, int offset )
+static inline void Col( dctelem_t * col, int offset )
 {
 #define T1 13036
 #define T2 27146
@@ -457,8 +361,7 @@ static s32 rounder3[] ATTR_ALIGN(8) =
 static s32 rounder5[] ATTR_ALIGN(8) =
     rounder (-0.441341716183);  // C3*(-C5/C4+C5-C3)/2
 
-void vdec_IDCT( vdec_thread_t * p_vdec, dctelem_t * p_block,
-                int i_idontcare )
+static void IDCT( dctelem_t * p_block )
 {
     static dctelem_t table04[] ATTR_ALIGN(16) =
         table (22725, 21407, 19266, 16384, 12873,  8867, 4520);
@@ -491,3 +394,11 @@ void vdec_IDCT( vdec_thread_t * p_vdec, dctelem_t * p_block,
     Col( p_block, 4 );
 }
 
+static inline void RestoreCPUState( )
+{
+    /* reenables the FPU */
+    __asm__ __volatile__ ("emms");
+}
+
+#include "idct_sparse.h"
+#include "idct_decl.h"