]> git.sesse.net Git - vlc/blob - plugins/idct/idctaltivec.c
* Altivec IDCT and motion compensation, based on Paul Mackerras's mpeg2dec
[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.12 2001/09/05 16:07:49 massiot 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 #include "modules_inner.h"
26
27 /*****************************************************************************
28  * Preamble
29  *****************************************************************************/
30 #include "defs.h"
31
32 #include <stdlib.h>
33
34 #include "config.h"
35 #include "common.h"
36 #include "threads.h"
37 #include "mtime.h"
38 #include "tests.h"                                              /* TestCPU() */
39
40 #include "idct.h"
41
42 #include "modules.h"
43 #include "modules_export.h"
44
45 /*****************************************************************************
46  * Local prototypes.
47  *****************************************************************************/
48 static void idct_getfunctions( function_list_t * p_function_list );
49 void idct_block_copy_altivec( dctelem_t *, yuv_data_t *, int, void *, int );
50 void idct_block_add_altivec( dctelem_t *, yuv_data_t *, int, void *, int );
51
52 /*****************************************************************************
53  * Build configuration tree.
54  *****************************************************************************/
55 MODULE_CONFIG_START
56 ADD_WINDOW( "Configuration for Altivec IDCT module" )
57     ADD_COMMENT( "Ha, ha -- nothing to configure yet" )
58 MODULE_CONFIG_STOP
59
60 MODULE_INIT_START
61     p_module->i_capabilities = MODULE_CAPABILITY_NULL
62                                 | MODULE_CAPABILITY_IDCT;
63     p_module->psz_longname = "Altivec IDCT module";
64 MODULE_INIT_STOP
65
66 MODULE_ACTIVATE_START
67     idct_getfunctions( &p_module->p_functions->idct );
68 MODULE_ACTIVATE_STOP
69
70 MODULE_DEACTIVATE_START
71 MODULE_DEACTIVATE_STOP
72
73 /* Following functions are local */
74
75 /*****************************************************************************
76  * idct_Probe: return a preference score
77  *****************************************************************************/
78 static int idct_Probe( probedata_t *p_data )
79 {
80     if( !TestCPU( CPU_CAPABILITY_ALTIVEC ) )
81     {
82         return( 0 );
83     }
84
85     if( TestMethod( IDCT_METHOD_VAR, "idctaltivec" )
86          || TestMethod( IDCT_METHOD_VAR, "altivec" ) )
87     {
88         return( 999 );
89     }
90
91     return( 200 );
92 }
93
94 /*****************************************************************************
95  * Placeholders for unused functions
96  *****************************************************************************/
97 static void NormScan( u8 ppi_scan[2][64] )
98 {
99 }
100
101 static void InitIDCT( void * p_idct_data )
102 {
103 }
104
105
106 /*****************************************************************************
107  * Functions exported as capabilities. They are declared as static so that
108  * we don't pollute the namespace too much.
109  *****************************************************************************/
110 static void idct_getfunctions( function_list_t * p_function_list )
111 {
112     p_function_list->pf_probe = idct_Probe;
113 #define F p_function_list->functions.idct
114     F.pf_idct_init = InitIDCT;
115     F.pf_norm_scan = NormScan;
116     /* FIXME : it would be a nice idea to use sparse IDCT functions */
117     F.pf_sparse_idct_add = idct_block_add_altivec;
118     F.pf_sparse_idct_copy = idct_block_copy_altivec;
119     F.pf_idct_add = idct_block_add_altivec;
120     F.pf_idct_copy = idct_block_copy_altivec;
121 #undef F
122 }
123