1 /*****************************************************************************
2 * idctmmx.c : MMX IDCT module
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: idctmmx.c,v 1.1 2001/01/13 12:57:20 sam Exp $
7 * Authors: Gaƫl Hendryckx <jimmy@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 idctmmx
26 /*****************************************************************************
28 *****************************************************************************/
41 #include "stream_control.h"
42 #include "input_ext-dec.h"
45 #include "video_output.h"
47 #include "video_decoder.h"
50 #include "modules_inner.h"
54 /*****************************************************************************
56 *****************************************************************************/
57 static void idct_getfunctions( function_list_t * p_function_list );
59 static int idct_Probe ( probedata_t *p_data );
60 static void vdec_InitIDCT ( vdec_thread_t * p_vdec);
61 void vdec_SparseIDCT ( vdec_thread_t * p_vdec, dctelem_t * p_block,
63 void vdec_IDCT ( vdec_thread_t * p_vdec, dctelem_t * p_block,
67 /*****************************************************************************
68 * Build configuration tree.
69 *****************************************************************************/
71 ADD_WINDOW( "Configuration for MMX IDCT module" )
72 ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
75 /*****************************************************************************
76 * InitModule: get the module structure and configuration.
77 *****************************************************************************
78 * We have to fill psz_name, psz_longname and psz_version. These variables
79 * will be strdup()ed later by the main application because the module can
80 * be unloaded later to save memory, and we want to be able to access this
81 * data even after the module has been unloaded.
82 *****************************************************************************/
83 int InitModule( module_t * p_module )
85 p_module->psz_name = MODULE_STRING;
86 p_module->psz_longname = "MMX IDCT module";
87 p_module->psz_version = VERSION;
89 p_module->i_capabilities = MODULE_CAPABILITY_NULL
90 | MODULE_CAPABILITY_IDCT;
95 /*****************************************************************************
96 * ActivateModule: set the module to an usable state.
97 *****************************************************************************
98 * This function fills the capability functions and the configuration
99 * structure. Once ActivateModule() has been called, the i_usage can
100 * be set to 0 and calls to NeedModule() be made to increment it. To unload
101 * the module, one has to wait until i_usage == 0 and call DeactivateModule().
102 *****************************************************************************/
103 int ActivateModule( module_t * p_module )
105 p_module->p_functions = malloc( sizeof( module_functions_t ) );
106 if( p_module->p_functions == NULL )
111 idct_getfunctions( &p_module->p_functions->idct );
113 p_module->p_config = p_config;
118 /*****************************************************************************
119 * DeactivateModule: make sure the module can be unloaded.
120 *****************************************************************************
121 * This function must only be called when i_usage == 0. If it successfully
122 * returns, i_usage can be set to -1 and the module unloaded. Be careful to
123 * lock usage_lock during the whole process.
124 *****************************************************************************/
125 int DeactivateModule( module_t * p_module )
127 free( p_module->p_functions );
132 /* Following functions are local */
134 /*****************************************************************************
135 * Functions exported as capabilities. They are declared as static so that
136 * we don't pollute the namespace too much.
137 *****************************************************************************/
138 static void idct_getfunctions( function_list_t * p_function_list )
140 p_function_list->pf_probe = idct_Probe;
141 p_function_list->functions.idct.pf_init = vdec_InitIDCT;
142 p_function_list->functions.idct.pf_sparse_idct = vdec_SparseIDCT;
143 p_function_list->functions.idct.pf_idct = vdec_IDCT;
146 /*****************************************************************************
147 * idct_Probe: return a preference score
148 *****************************************************************************/
149 static int idct_Probe( probedata_t *p_data )
151 /* This plugin always works */
155 /*****************************************************************************
156 * vdec_InitIDCT : initialize datas for vdec_SparceIDCT
157 *****************************************************************************/
158 static void vdec_InitIDCT (vdec_thread_t * p_vdec)
162 dctelem_t * p_pre = p_vdec->p_pre_idct;
163 memset( p_pre, 0, 64*64*sizeof(dctelem_t) );
165 for( i=0 ; i < 64 ; i++ )
167 p_pre[i*64+i] = 1 << SPARSE_SCALE_FACTOR;
168 vdec_IDCT( p_vdec, &p_pre[i*64], 0) ;