1 /*****************************************************************************
2 * idctaltivec.c : Altivec IDCT module
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: idctaltivec.c,v 1.4 2001/04/15 04:19:57 sam Exp $
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
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.
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.
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 *****************************************************************************/
24 #define MODULE_NAME idctaltivec
26 /*****************************************************************************
28 *****************************************************************************/
37 #include "tests.h" /* TestCPU() */
40 #include "video_output.h"
42 #include "video_decoder.h"
45 #include "modules_inner.h"
49 #include "idctaltivec.h"
51 /*****************************************************************************
53 *****************************************************************************/
54 static void idct_getfunctions( function_list_t * p_function_list );
55 static int idct_Probe ( probedata_t *p_data );
56 static void vdec_NormScan ( u8 ppi_scan[2][64] );
59 /*****************************************************************************
60 * Build configuration tree.
61 *****************************************************************************/
63 ADD_WINDOW( "Configuration for Altivec IDCT module" )
64 ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
67 /*****************************************************************************
68 * InitModule: get the module structure and configuration.
69 *****************************************************************************
70 * We have to fill psz_name, psz_longname and psz_version. These variables
71 * will be strdup()ed later by the main application because the module can
72 * be unloaded later to save memory, and we want to be able to access this
73 * data even after the module has been unloaded.
74 *****************************************************************************/
77 p_module->psz_name = MODULE_STRING;
78 p_module->psz_longname = "Altivec IDCT module";
79 p_module->psz_version = VERSION;
81 p_module->i_capabilities = MODULE_CAPABILITY_NULL
82 | MODULE_CAPABILITY_IDCT;
87 /*****************************************************************************
88 * ActivateModule: set the module to an usable state.
89 *****************************************************************************
90 * This function fills the capability functions and the configuration
91 * structure. Once ActivateModule() has been called, the i_usage can
92 * be set to 0 and calls to NeedModule() be made to increment it. To unload
93 * the module, one has to wait until i_usage == 0 and call DeactivateModule().
94 *****************************************************************************/
97 p_module->p_functions = malloc( sizeof( module_functions_t ) );
98 if( p_module->p_functions == NULL )
103 idct_getfunctions( &p_module->p_functions->idct );
105 p_module->p_config = p_config;
110 /*****************************************************************************
111 * DeactivateModule: make sure the module can be unloaded.
112 *****************************************************************************
113 * This function must only be called when i_usage == 0. If it successfully
114 * returns, i_usage can be set to -1 and the module unloaded. Be careful to
115 * lock usage_lock during the whole process.
116 *****************************************************************************/
119 free( p_module->p_functions );
124 /* Following functions are local */
126 /*****************************************************************************
127 * Functions exported as capabilities.
128 *****************************************************************************/
129 static void idct_getfunctions( function_list_t * p_function_list )
131 p_function_list->pf_probe = idct_Probe;
132 p_function_list->functions.idct.pf_init = _M( vdec_InitIDCT );
133 p_function_list->functions.idct.pf_sparse_idct = _M( vdec_SparseIDCT );
134 p_function_list->functions.idct.pf_idct = _M( vdec_IDCT );
135 p_function_list->functions.idct.pf_norm_scan = vdec_NormScan;
138 /*****************************************************************************
139 * idct_Probe: return a preference score
140 *****************************************************************************/
141 static int idct_Probe( probedata_t *p_data )
143 if( TestCPU( CPU_CAPABILITY_ALTIVEC ) )
145 if( TestMethod( IDCT_METHOD_VAR, "idctaltivec" ) )
151 /* The Altivec iDCT is deactivated until it really works */
152 return( 0 /* 200 */ );
161 /*****************************************************************************
162 * vdec_NormScan : Soon, transpose
163 *****************************************************************************/
164 static void vdec_NormScan( u8 ppi_scan[2][64] )
168 /*****************************************************************************
170 *****************************************************************************/
171 void _M( vdec_IDCT )( vdec_thread_t * p_vdec, dctelem_t * p_block,
174 IDCT( p_block, p_block );