]> git.sesse.net Git - vlc/blob - plugins/idct/idctaltivec.c
8a4e2ca8ef70fe0468a67e60d89d2bcb14eaee63
[vlc] / plugins / idct / idctaltivec.c
1 /*****************************************************************************
2  * idctaltivec.c : Altivec IDCT module
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: idctaltivec.c,v 1.6 2001/05/15 16:19:42 sam Exp $
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
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 idctaltivec
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 "vdec_block.h"
48 #include "vdec_idct.h"
49
50 #include "idctaltivec.h"
51
52 /*****************************************************************************
53  * Local prototypes.
54  *****************************************************************************/
55 static void idct_getfunctions( function_list_t * p_function_list );
56 static int  idct_Probe      ( probedata_t *p_data );
57 static void vdec_NormScan   ( u8 ppi_scan[2][64] );
58
59
60 /*****************************************************************************
61  * Build configuration tree.
62  *****************************************************************************/
63 MODULE_CONFIG_START
64 ADD_WINDOW( "Configuration for Altivec IDCT module" )
65     ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
66 MODULE_CONFIG_END
67
68 /*****************************************************************************
69  * InitModule: get the module structure and configuration.
70  *****************************************************************************
71  * We have to fill psz_name, psz_longname and psz_version. These variables
72  * will be strdup()ed later by the main application because the module can
73  * be unloaded later to save memory, and we want to be able to access this
74  * data even after the module has been unloaded.
75  *****************************************************************************/
76 MODULE_INIT
77 {
78     p_module->psz_name = MODULE_STRING;
79     p_module->psz_longname = "Altivec IDCT module";
80     p_module->psz_version = VERSION;
81
82     p_module->i_capabilities = MODULE_CAPABILITY_NULL
83                                 | MODULE_CAPABILITY_IDCT;
84
85     return( 0 );
86 }
87
88 /*****************************************************************************
89  * ActivateModule: set the module to an usable state.
90  *****************************************************************************
91  * This function fills the capability functions and the configuration
92  * structure. Once ActivateModule() has been called, the i_usage can
93  * be set to 0 and calls to NeedModule() be made to increment it. To unload
94  * the module, one has to wait until i_usage == 0 and call DeactivateModule().
95  *****************************************************************************/
96 MODULE_ACTIVATE
97 {
98     p_module->p_functions = malloc( sizeof( module_functions_t ) );
99     if( p_module->p_functions == NULL )
100     {
101         return( -1 );
102     }
103
104     idct_getfunctions( &p_module->p_functions->idct );
105
106     p_module->p_config = p_config;
107
108     return( 0 );
109 }
110
111 /*****************************************************************************
112  * DeactivateModule: make sure the module can be unloaded.
113  *****************************************************************************
114  * This function must only be called when i_usage == 0. If it successfully
115  * returns, i_usage can be set to -1 and the module unloaded. Be careful to
116  * lock usage_lock during the whole process.
117  *****************************************************************************/
118 MODULE_DEACTIVATE
119 {
120     free( p_module->p_functions );
121
122     return( 0 );
123 }
124
125 /* Following functions are local */
126
127 /*****************************************************************************
128  * Functions exported as capabilities.
129  *****************************************************************************/
130 static void idct_getfunctions( function_list_t * p_function_list )
131 {
132     p_function_list->pf_probe = idct_Probe;
133 #define F p_function_list->functions.idct
134     F.pf_idct_init = _M( vdec_InitIDCT );
135     F.pf_sparse_idct = _M( vdec_SparseIDCT );
136     F.pf_idct = _M( vdec_IDCT );
137     F.pf_norm_scan = vdec_NormScan;
138     F.pf_vdec_init = _M( vdec_Init );
139     F.pf_decode_mb_c = _M( vdec_DecodeMacroblockC );
140     F.pf_decode_mb_bw = _M( vdec_DecodeMacroblockBW );
141 #undef F
142 }
143
144 /*****************************************************************************
145  * idct_Probe: return a preference score
146  *****************************************************************************/
147 static int idct_Probe( probedata_t *p_data )
148 {
149     if( !TestCPU( CPU_CAPABILITY_ALTIVEC ) )
150     {
151         return( 0 );
152     }
153
154     if( TestMethod( IDCT_METHOD_VAR, "idctaltivec" ) )
155     {
156         return( 999 );
157     }
158
159     /* The Altivec iDCT is deactivated until it really works */
160     return( 0 /* 200 */ );
161 }
162
163 /*****************************************************************************
164  * vdec_NormScan : Soon, transpose
165  *****************************************************************************/
166 static void vdec_NormScan( u8 ppi_scan[2][64] )
167 {
168 }
169
170 /*****************************************************************************
171  * vdec_IDCT :
172  *****************************************************************************/
173 void _M( vdec_IDCT )( vdec_thread_t * p_vdec, dctelem_t * p_block,
174                 int i_idontcare )
175 {
176     IDCT( p_block, p_block );
177 }
178