1 /*****************************************************************************
2 * xcommon.h: Defines common to the X11 and XVideo plugins
3 *****************************************************************************
4 * Copyright (C) 1998-2001 the VideoLAN team
7 * Authors: Vincent Seguin <seguin@via.ecp.fr>
8 * Samuel Hocevar <sam@zoy.org>
9 * David Kennedy <dkennedy@tinytoad.com>
10 * Gildas Bazin <gbazin@netcourrier.com>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
30 #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
31 # define IMAGE_TYPE XvImage
32 # define EXTRA_ARGS int i_xvport, int i_chroma, int i_bits_per_pixel
33 # define EXTRA_ARGS_SHM int i_xvport, int i_chroma, XShmSegmentInfo *p_shm
34 # define DATA_SIZE(p) (p)->data_size
35 # define IMAGE_FREE XFree /* There is nothing like XvDestroyImage */
37 # define IMAGE_TYPE XImage
38 # define EXTRA_ARGS Visual *p_visual, int i_depth, int i_bytes_per_pixel
39 # define EXTRA_ARGS_SHM Visual *p_visual, int i_depth, XShmSegmentInfo *p_shm
40 # define DATA_SIZE(p) ((p)->bytes_per_line * (p)->height)
41 # define IMAGE_FREE XDestroyImage
44 #define X11_FOURCC( a, b, c, d ) \
45 ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \
46 | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
47 #define VLC2X11_FOURCC( i ) \
48 X11_FOURCC( ((char *)&i)[0], ((char *)&i)[1], ((char *)&i)[2], \
50 #define X112VLC_FOURCC( i ) \
51 VLC_FOURCC( i & 0xff, (i >> 8) & 0xff, (i >> 16) & 0xff, \
55 /*****************************************************************************
56 * x11_window_t: X11 window descriptor
57 *****************************************************************************
58 * This structure contains all the data necessary to describe an X11 window.
59 *****************************************************************************/
60 typedef struct x11_window_t
62 Window owner_window; /* owner window (if any) */
63 Window base_window; /* base window */
64 Window video_window; /* sub-window for displaying video */
65 GC gc; /* graphic context instance handler */
67 unsigned int i_width; /* window width */
68 unsigned int i_height; /* window height */
69 int i_x; /* window x coordinate */
70 int i_y; /* window y coordinate */
73 Atom wm_delete_window;
81 /*****************************************************************************
82 * vout_sys_t: video output method descriptor
83 *****************************************************************************
84 * This structure is part of the video output thread descriptor.
85 * It describes the X11 and XVideo specific properties of an output thread.
86 *****************************************************************************/
89 /* Internal settings and properties */
90 Display * p_display; /* display pointer */
92 Visual * p_visual; /* visual pointer */
93 int i_screen; /* screen number */
97 /* Our current window */
100 /* Our two windows */
101 x11_window_t original_window;
102 x11_window_t fullscreen_window;
104 /* X11 generic properties */
105 vlc_bool_t b_altfullscreen; /* which fullscreen method */
106 #ifdef HAVE_SYS_SHM_H
107 vlc_bool_t b_shm; /* shared memory extension flag */
110 #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
113 Colormap colormap; /* colormap used (8bpp only) */
115 unsigned int i_screen_depth;
116 unsigned int i_bytes_per_pixel;
117 unsigned int i_bytes_per_line;
120 /* Screen saver properties */
121 int i_ss_timeout; /* timeout */
122 int i_ss_interval; /* interval between changes */
123 int i_ss_blanking; /* blanking mode */
124 int i_ss_exposure; /* exposure mode */
125 #ifdef DPMSINFO_IN_DPMS_H
126 BOOL b_ss_dpms; /* DPMS mode */
129 /* Mouse pointer properties */
130 vlc_bool_t b_mouse_pointer_visible;
131 mtime_t i_time_mouse_last_moved; /* used to auto-hide pointer*/
132 Cursor blank_cursor; /* the hidden cursor */
133 mtime_t i_time_button_last_pressed; /* to track dbl-clicks */
134 Pixmap cursor_pixmap;
136 /* Window manager properties */
138 Atom net_wm_state_fullscreen;
139 vlc_bool_t b_net_wm_state_fullscreen;
140 Atom net_wm_state_above;
141 vlc_bool_t b_net_wm_state_above;
142 Atom net_wm_state_stays_on_top;
143 vlc_bool_t b_net_wm_state_stays_on_top;
144 Atom net_wm_state_below;
145 vlc_bool_t b_net_wm_state_below;
147 #ifdef MODULE_NAME_IS_glx
154 #ifdef MODULE_NAME_IS_xvmc
155 /* XvMC related stuff here */
156 xvmc_macroblocks_t macroblocks;
157 xvmc_capabilities_t *xvmc_cap;
158 unsigned int xvmc_num_cap;
159 unsigned int xvmc_max_subpic_x;
160 unsigned int xvmc_max_subpic_y;
164 XvMCSubpicture *old_subpic;
165 XvMCSubpicture *new_subpic;
166 xx44_palette_t palette;
169 int cpu_save_enabled;
170 int reverse_nvidia_palette;
174 * These variables are protected by the context lock:
176 unsigned xvmc_cur_cap;
177 int xvmc_backend_subpic;
180 xvmc_surface_handler_t xvmc_surf_handler;
183 unsigned last_accel_request;
185 unsigned xvmc_height;
186 int have_xvmc_autopaint;
187 int xvmc_xoverlay_type;
191 * Only creation and destruction of the below.
195 XShmSegmentInfo subShmInfo;
198 * The mutex below is needed since XlockDisplay wasn't really enough
199 * to protect the XvMC Calls.
201 context_lock_t xvmc_lock;
202 subpicture_t * p_last_subtitle_save;
203 int xvmc_deinterlace_method;
207 //alphablend_t alphablend_extra_data;
211 /*****************************************************************************
212 * picture_sys_t: direct buffer method descriptor
213 *****************************************************************************
214 * This structure is part of the picture descriptor, it describes the
215 * XVideo specific properties of a direct buffer.
216 *****************************************************************************/
219 IMAGE_TYPE * p_image;
221 #ifdef HAVE_SYS_SHM_H
222 XShmSegmentInfo shminfo; /* shared memory zone information */
225 #ifdef MODULE_NAME_IS_xvmc
226 XvMCSurface *xvmc_surf;
227 vlc_xxmc_t xxmc_data;
229 vout_thread_t *p_vout;
234 /*****************************************************************************
235 * mwmhints_t: window manager hints
236 *****************************************************************************
237 * Fullscreen needs to be able to hide the wm decorations so we provide
238 * this structure to make it easier.
239 *****************************************************************************/
240 #define MWM_HINTS_DECORATIONS (1L << 1)
241 #define PROP_MWM_HINTS_ELEMENTS 5
243 typedef struct mwmhints_t
246 unsigned long functions;
247 unsigned long decorations;
248 signed long input_mode;
249 unsigned long status;
252 /*****************************************************************************
254 *****************************************************************************/
255 #ifdef MODULE_NAME_IS_xvideo
256 # define MAX_DIRECTBUFFERS 10
257 #elif defined(MODULE_NAME_IS_xvmc)
258 # define MAX_DIRECTBUFFERS 12
260 # define MAX_DIRECTBUFFERS 2
263 /*****************************************************************************
265 *****************************************************************************/
267 #ifdef MODULE_NAME_IS_xvmc
270 { /* CLUT == Color LookUp Table */
277 #define XX44_PALETTE_SIZE 32
278 #define OVL_PALETTE_SIZE 256
279 #define XVMC_MAX_SURFACES 16
280 #define XVMC_MAX_SUBPICTURES 4
281 #define FOURCC_IA44 0x34344149
282 #define FOURCC_AI44 0x34344941
288 uint32_t cluts[XX44_PALETTE_SIZE];
289 /* cache palette entries for both colors and clip_colors */
290 int lookup_cache[OVL_PALETTE_SIZE*2];
294 * Functions to handle the vlc-specific palette.
297 void clear_xx44_palette( xx44_palette_t *p );
300 * Convert the xine-specific palette to something useful.
303 void xx44_to_xvmc_palette( const xx44_palette_t *p,unsigned char *xvmc_palette,
304 unsigned first_xx44_entry, unsigned num_xx44_entries,
305 unsigned num_xvmc_components, char *xvmc_components );
309 vlc_macroblocks_t vlc_mc;
310 XvMCBlockArray blocks; /* pointer to memory for dct block array */
312 XvMCMacroBlock *macroblockptr; /* pointer to current macro block */
313 XvMCMacroBlock *macroblockbaseptr; /* pointer to base MacroBlock in MB array */
314 XvMCMacroBlockArray macro_blocks; /* pointer to memory for macroblock array */
316 } xvmc_macroblocks_t;
320 unsigned int mpeg_flags;
321 unsigned int accel_flags;
322 unsigned int max_width;
323 unsigned int max_height;
324 unsigned int sub_max_width;
325 unsigned int sub_max_height;
327 XvImageFormatValues subPicType;
329 } xvmc_capabilities_t;
331 typedef struct xvmc_surface_handler_s
333 XvMCSurface surfaces[XVMC_MAX_SURFACES];
334 int surfInUse[XVMC_MAX_SURFACES];
335 int surfValid[XVMC_MAX_SURFACES];
336 XvMCSubpicture subpictures[XVMC_MAX_SUBPICTURES];
337 int subInUse[XVMC_MAX_SUBPICTURES];
338 int subValid[XVMC_MAX_SUBPICTURES];
339 pthread_mutex_t mutex;
340 } xvmc_surface_handler_t;
342 typedef struct context_lock_s
344 pthread_mutex_t mutex;
349 #define XVMCLOCKDISPLAY(display) XLockDisplay(display);
350 #define XVMCUNLOCKDISPLAY(display) XUnlockDisplay(display);
352 void xvmc_context_reader_unlock( context_lock_t *c );
353 void xvmc_context_reader_lock( context_lock_t *c );
354 void xvmc_context_writer_lock( context_lock_t *c );
355 void xvmc_context_writer_unlock( context_lock_t *c );
356 void free_context_lock( context_lock_t *c );
357 void xxmc_dispose_context( vout_thread_t *p_vout );
359 int xxmc_xvmc_surface_valid( vout_thread_t *p_vout, XvMCSurface *surf );
360 void xxmc_xvmc_free_surface( vout_thread_t *p_vout, XvMCSurface *surf );
362 void xvmc_vld_slice( picture_t *picture );
363 void xvmc_vld_frame( picture_t *picture );
365 void xxmc_do_update_frame( picture_t *picture, uint32_t width, uint32_t height,
366 double ratio, int format, int flags);
368 int checkXvMCCap( vout_thread_t *p_vout);
370 XvMCSubpicture *xxmc_xvmc_alloc_subpicture( vout_thread_t *p_vout,
371 XvMCContext *context, unsigned short width, unsigned short height,
374 void xxmc_xvmc_free_subpicture( vout_thread_t *p_vout, XvMCSubpicture *sub );
375 void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img, int dst_width,
376 int dst_height, int dst_pitch, xx44_palette_t *palette,int ia44);