]> git.sesse.net Git - vlc/blob - plugins/idct/idctmmxext.c
f09005c3b4f43b0fa301b6e9c1599cf0bc247d22
[vlc] / plugins / idct / idctmmxext.c
1 /*****************************************************************************
2  * idctmmxext.c : MMX EXT IDCT module
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: idctmmxext.c,v 1.3 2001/01/16 16:09:52 sam Exp $
6  *
7  * Authors:
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #define MODULE_NAME idctmmxext
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include "defs.h"
30
31 #include <stdlib.h>
32
33 #include "config.h"
34 #include "common.h"
35 #include "threads.h"
36 #include "mtime.h"
37 #include "tests.h"                                              /* TestCPU() */
38
39 #include "video.h"
40 #include "video_output.h"
41
42 #include "video_decoder.h"
43
44 #include "modules.h"
45 #include "modules_inner.h"
46
47 #include "idct.h"
48
49 /*****************************************************************************
50  * Local prototypes.
51  *****************************************************************************/
52 static void idct_getfunctions( function_list_t * p_function_list );
53
54 static int  idct_Probe      ( probedata_t *p_data );
55
56        void vdec_InitIDCT   ( vdec_thread_t * p_vdec);
57        void vdec_SparseIDCT ( vdec_thread_t * p_vdec, dctelem_t * p_block,
58                               int i_sparse_pos);
59        void vdec_IDCT       ( vdec_thread_t * p_vdec, dctelem_t * p_block,
60                               int i_idontcare );
61
62
63 /*****************************************************************************
64  * Build configuration tree.
65  *****************************************************************************/
66 MODULE_CONFIG_START
67 ADD_WINDOW( "Configuration for MMX EXT IDCT module" )
68     ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
69 MODULE_CONFIG_END
70
71 /*****************************************************************************
72  * InitModule: get the module structure and configuration.
73  *****************************************************************************
74  * We have to fill psz_name, psz_longname and psz_version. These variables
75  * will be strdup()ed later by the main application because the module can
76  * be unloaded later to save memory, and we want to be able to access this
77  * data even after the module has been unloaded.
78  *****************************************************************************/
79 int InitModule( module_t * p_module )
80 {
81     p_module->psz_name = MODULE_STRING;
82     p_module->psz_longname = "MMX EXT IDCT module";
83     p_module->psz_version = VERSION;
84
85     p_module->i_capabilities = MODULE_CAPABILITY_NULL
86                                 | MODULE_CAPABILITY_IDCT;
87
88     return( 0 );
89 }
90
91 /*****************************************************************************
92  * ActivateModule: set the module to an usable state.
93  *****************************************************************************
94  * This function fills the capability functions and the configuration
95  * structure. Once ActivateModule() has been called, the i_usage can
96  * be set to 0 and calls to NeedModule() be made to increment it. To unload
97  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
98  *****************************************************************************/
99 int ActivateModule( module_t * p_module )
100 {
101     p_module->p_functions = malloc( sizeof( module_functions_t ) );
102     if( p_module->p_functions == NULL )
103     {
104         return( -1 );
105     }
106
107     idct_getfunctions( &p_module->p_functions->idct );
108
109     p_module->p_config = p_config;
110
111     return( 0 );
112 }
113
114 /*****************************************************************************
115  * DeactivateModule: make sure the module can be unloaded.
116  *****************************************************************************
117  * This function must only be called when i_usage == 0. If it successfully
118  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
119  * lock usage_lock during the whole process.
120  *****************************************************************************/
121 int DeactivateModule( module_t * p_module )
122 {
123     free( p_module->p_functions );
124
125     return( 0 );
126 }
127
128 /* Following functions are local */
129
130 /*****************************************************************************
131  * Functions exported as capabilities.
132  *****************************************************************************/
133 static void idct_getfunctions( function_list_t * p_function_list )
134 {
135     p_function_list->pf_probe = idct_Probe;
136     p_function_list->functions.idct.pf_init = vdec_InitIDCT;
137     p_function_list->functions.idct.pf_sparse_idct = vdec_SparseIDCT;
138     p_function_list->functions.idct.pf_idct = vdec_IDCT;
139 }
140
141 /*****************************************************************************
142  * idct_Probe: return a preference score
143  *****************************************************************************/
144 static int idct_Probe( probedata_t *p_data )
145 {
146     if( 0/*TestCPU( CPU_CAPABILITY_MMXEXT )*/ )
147     {
148         if( TestMethod( IDCT_METHOD_VAR, "idctmmxext" ) )
149         {
150             return( 999 );
151         }
152         else
153         {
154             return( 200 );
155         }
156     }
157     else
158     {
159         return( 0 );
160     }
161 }
162