]> git.sesse.net Git - vlc/blob - include/modules.h
* Altivec IDCT and motion compensation, based on Paul Mackerras's mpeg2dec
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: modules.h,v 1.29 2001/09/05 16:07:49 massiot Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
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 #ifdef WIN32
25 #include <sys/types.h>                                              /* off_t */
26 #endif
27
28 /*****************************************************************************
29  * module_bank_t, p_module_bank (global variable)
30  *****************************************************************************
31  * This global variable is accessed by any function using modules.
32  *****************************************************************************/
33 typedef struct
34 {
35     struct module_s *   first; /* First module of the bank */
36
37     vlc_mutex_t         lock;  /* Global lock -- you can't imagine how awful it
38                                   is to design thread-safe linked lists. */
39 } module_bank_t;
40
41 extern module_bank_t *p_module_bank;
42
43 /*****************************************************************************
44  * Module #defines.
45  *****************************************************************************/
46
47 /* Number of tries before we unload an unused module */
48 #define MODULE_HIDE_DELAY 100
49
50 /* The module handle type. */
51 #ifdef SYS_BEOS
52 typedef int     module_handle_t;
53 #else
54 typedef void *  module_handle_t;
55 #endif
56
57 /*****************************************************************************
58  * Module capabilities.
59  *****************************************************************************/
60
61 #define MODULE_CAPABILITY_NULL     0        /* The Module can't do anything */
62 #define MODULE_CAPABILITY_INTF     1 <<  0  /* Interface */
63 #define MODULE_CAPABILITY_ACCESS   1 <<  1  /* Input */
64 #define MODULE_CAPABILITY_INPUT    1 <<  2  /* Input */
65 #define MODULE_CAPABILITY_DECAPS   1 <<  3  /* Decaps */
66 #define MODULE_CAPABILITY_ADEC     1 <<  4  /* Audio decoder */
67 #define MODULE_CAPABILITY_VDEC     1 <<  5  /* Video decoder */
68 #define MODULE_CAPABILITY_MOTION   1 <<  6  /* Motion compensation */
69 #define MODULE_CAPABILITY_IDCT     1 <<  7  /* IDCT transformation */
70 #define MODULE_CAPABILITY_AOUT     1 <<  8  /* Audio output */
71 #define MODULE_CAPABILITY_VOUT     1 <<  9  /* Video output */
72 #define MODULE_CAPABILITY_YUV      1 << 10  /* YUV colorspace conversion */
73 #define MODULE_CAPABILITY_IMDCT    1 << 11  /* IMDCT transformation */
74 #define MODULE_CAPABILITY_DOWNMIX  1 << 12  /* AC3 downmix */
75
76 /* FIXME: kludge */
77 struct input_area_s;
78 struct imdct_s;
79 struct complex_s;
80 struct dm_par_s;
81 struct bit_stream_s;
82 struct decoder_fifo_s;
83
84 /* FIXME: not yet used */
85 typedef struct probedata_s
86 {
87     struct
88     {
89         char * psz_data;
90     } aout;
91 } probedata_t;
92
93 /* FIXME: find a nicer way to do this. */
94 typedef struct function_list_s
95 {
96     int ( * pf_probe ) ( probedata_t * p_data );
97
98     union
99     {
100         /* Interface plugin */
101         struct
102         {
103             int  ( * pf_open ) ( struct intf_thread_s * );
104             void ( * pf_close )( struct intf_thread_s * );
105             void ( * pf_run )  ( struct intf_thread_s * );
106         } intf;
107
108         /* Input plugin */
109         struct
110         {
111             void ( * pf_init ) ( struct input_thread_s * );
112             void ( * pf_open ) ( struct input_thread_s * );
113             void ( * pf_close )( struct input_thread_s * );
114             void ( * pf_end )  ( struct input_thread_s * );
115             void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
116                                             struct decoder_fifo_s *,
117                       void (* pf_bitstream_callback)( struct bit_stream_s *,
118                                                       boolean_t ),
119                                            void * );
120
121             int  ( * pf_read ) ( struct input_thread_s *,
122                                  struct data_packet_s *
123                                         pp_packets[] );
124             void ( * pf_demux )( struct input_thread_s *,
125                                  struct data_packet_s * );
126
127             struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
128             struct pes_packet_s *  ( * pf_new_pes )    ( void * );
129             void ( * pf_delete_packet )  ( void *, struct data_packet_s * );
130             void ( * pf_delete_pes )     ( void *, struct pes_packet_s * );
131
132
133             int  ( * pf_set_area ) ( struct input_thread_s *,
134                                      struct input_area_s * );
135             int  ( * pf_rewind )   ( struct input_thread_s * );
136             void ( * pf_seek )     ( struct input_thread_s *, off_t );
137         } input;
138
139         /* Audio output plugin */
140         struct
141         {
142             int  ( * pf_open )       ( struct aout_thread_s * );
143             int  ( * pf_setformat )  ( struct aout_thread_s * );
144             long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
145             void ( * pf_play )       ( struct aout_thread_s *, byte_t *, int );
146             void ( * pf_close )      ( struct aout_thread_s * );
147         } aout;
148
149         /* Video output plugin */
150         struct
151         {
152             int  ( * pf_create )     ( struct vout_thread_s * );
153             int  ( * pf_init )       ( struct vout_thread_s * );
154             void ( * pf_end )        ( struct vout_thread_s * );
155             void ( * pf_destroy )    ( struct vout_thread_s * );
156             int  ( * pf_manage )     ( struct vout_thread_s * );
157             void ( * pf_display )    ( struct vout_thread_s * );
158             void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
159                                        u16 *green, u16 *blue, u16 *transp );
160         } vout;
161
162         /* Motion compensation plugin */
163         struct
164         {
165             void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
166                                                int, int );
167         } motion;
168
169         /* IDCT plugin */
170         struct
171         {
172             void ( * pf_idct_init )    ( void ** );
173             void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
174                                          void *, int );
175             void ( * pf_idct_add )     ( dctelem_t *, yuv_data_t *, int,
176                                          void *, int );
177             void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
178                                          void *, int );
179             void ( * pf_idct_copy )    ( dctelem_t *, yuv_data_t *, int,
180                                          void *, int );
181             void ( * pf_norm_scan )    ( u8 ppi_scan[2][64] );
182         } idct;
183
184         /* YUV transformation plugin */
185         struct
186         {
187             int  ( * pf_init )         ( struct vout_thread_s * );
188             int  ( * pf_reset )        ( struct vout_thread_s * );
189             void ( * pf_end )          ( struct vout_thread_s * );
190         } yuv;
191
192         /* IMDCT plugin */
193         struct
194         {
195             void ( * pf_imdct_init )   ( struct imdct_s * );
196             void ( * pf_imdct_256 )    ( struct imdct_s *,
197                                          float data[], float delay[] );
198             void ( * pf_imdct_256_nol )( struct imdct_s *,
199                                          float data[], float delay[] );
200             void ( * pf_imdct_512 )    ( struct imdct_s *,
201                                          float data[], float delay[] );
202             void ( * pf_imdct_512_nol )( struct imdct_s *,
203                                          float data[], float delay[] );
204 //            void ( * pf_fft_64p )      ( struct complex_s * );
205
206         } imdct;
207
208         /* AC3 downmix plugin */
209         struct
210         {
211             void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
212             void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
213             void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
214             void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
215             void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
216             void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
217             void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
218
219         } downmix;
220
221     } functions;
222
223 } function_list_t;
224
225 typedef struct module_functions_s
226 {
227     /* XXX: The order here has to be the same as above for the #defines */
228     function_list_t intf;
229     function_list_t access;
230     function_list_t input;
231     function_list_t decaps;
232     function_list_t adec;
233     function_list_t vdec;
234     function_list_t motion;
235     function_list_t idct;
236     function_list_t aout;
237     function_list_t vout;
238     function_list_t yuv;
239     function_list_t imdct;
240     function_list_t downmix;
241
242 } module_functions_t;
243
244 typedef struct module_functions_s * p_module_functions_t;
245
246 /*****************************************************************************
247  * Macros used to build the configuration structure.
248  *****************************************************************************/
249
250 /* Mandatory first and last parts of the structure */
251 #define MODULE_CONFIG_ITEM_START       0xdead  /* The main window */
252 #define MODULE_CONFIG_ITEM_END         0xbeef  /* End of the window */
253
254 /* Configuration widgets */
255 #define MODULE_CONFIG_ITEM_WINDOW      0x0001  /* The main window */
256 #define MODULE_CONFIG_ITEM_PANE        0x0002  /* A notebook pane */
257 #define MODULE_CONFIG_ITEM_FRAME       0x0003  /* A frame */
258 #define MODULE_CONFIG_ITEM_COMMENT     0x0004  /* A comment text */
259 #define MODULE_CONFIG_ITEM_STRING      0x0005  /* A string */
260 #define MODULE_CONFIG_ITEM_FILE        0x0006  /* A file selector */
261 #define MODULE_CONFIG_ITEM_CHECK       0x0007  /* A checkbox */
262 #define MODULE_CONFIG_ITEM_CHOOSE      0x0008  /* A choose box */
263 #define MODULE_CONFIG_ITEM_RADIO       0x0009  /* A radio box */
264 #define MODULE_CONFIG_ITEM_SCALE       0x000a  /* A horizontal ruler */
265 #define MODULE_CONFIG_ITEM_SPIN        0x000b  /* A numerical selector */
266
267 typedef struct module_config_s
268 {
269     int         i_type;                         /* Configuration widget type */
270     char *      psz_text;        /* Text commenting or describing the widget */
271     char *      psz_name;                                   /* Variable name */
272     void *      p_getlist;          /* Function to call to get a choice list */
273     void *      p_change;        /* Function to call when commiting a change */
274 } module_config_t;
275
276 /*****************************************************************************
277  * Bank and module description structures
278  *****************************************************************************/
279
280 /* The module description structure */
281 typedef struct module_s
282 {
283     boolean_t           b_builtin;  /* Set to true if the module is built in */
284
285     union
286     {
287         struct
288         {
289             module_handle_t     handle;                     /* Unique handle */
290             char *              psz_filename;             /* Module filename */
291
292         } plugin;
293
294         struct
295         {
296             int ( *pf_deactivate ) ( struct module_s * );
297
298         } builtin;
299
300     } is;
301
302     char *              psz_name;                    /* Module _unique_ name */
303     char *              psz_longname;             /* Module descriptive name */
304     char *              psz_version;                       /* Module version */
305
306     int                 i_usage;                        /* Reference counter */
307     int                 i_unused_delay;    /* Delay until module is unloaded */
308
309     struct module_s *   next;                                 /* Next module */
310     struct module_s *   prev;                             /* Previous module */
311
312     module_config_t         *p_config;     /* Module configuration structure */
313     struct module_symbols_s *p_symbols;
314
315     u32                      i_capabilities;              /* Capability list */
316     p_module_functions_t     p_functions;            /* Capability functions */
317
318 } module_t;
319
320 /*****************************************************************************
321  * Exported functions.
322  *****************************************************************************/
323 void            module_InitBank     ( void );
324 void            module_EndBank      ( void );
325 void            module_ResetBank    ( void );
326 void            module_ManageBank   ( void );
327 module_t *      module_Need         ( int i_capabilities, void *p_data );
328 void            module_Unneed       ( module_t * p_module );
329