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, \
58 /*****************************************************************************
59 * x11_window_t: X11 window descriptor
60 *****************************************************************************
61 * This structure contains all the data necessary to describe an X11 window.
62 *****************************************************************************/
63 typedef struct x11_window_t
65 Window owner_window; /* owner window (if any) */
66 Window base_window; /* base window */
67 Window video_window; /* sub-window for displaying video */
68 GC gc; /* graphic context instance handler */
70 unsigned int i_width; /* window width */
71 unsigned int i_height; /* window height */
72 int i_x; /* window x coordinate */
73 int i_y; /* window y coordinate */
76 Atom wm_delete_window;
84 /*****************************************************************************
85 * vout_sys_t: video output method descriptor
86 *****************************************************************************
87 * This structure is part of the video output thread descriptor.
88 * It describes the X11 and XVideo specific properties of an output thread.
89 *****************************************************************************/
92 /* Internal settings and properties */
93 Display * p_display; /* display pointer */
95 Visual * p_visual; /* visual pointer */
96 int i_screen; /* screen number */
100 /* Our current window */
101 x11_window_t * p_win;
103 /* Our two windows */
104 x11_window_t original_window;
105 x11_window_t fullscreen_window;
107 /* X11 generic properties */
108 vlc_bool_t b_altfullscreen; /* which fullscreen method */
109 #ifdef HAVE_SYS_SHM_H
110 vlc_bool_t b_shm; /* shared memory extension flag */
113 #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
116 Colormap colormap; /* colormap used (8bpp only) */
118 unsigned int i_screen_depth;
119 unsigned int i_bytes_per_pixel;
120 unsigned int i_bytes_per_line;
123 /* Screen saver properties */
124 int i_ss_timeout; /* timeout */
125 int i_ss_interval; /* interval between changes */
126 int i_ss_blanking; /* blanking mode */
127 int i_ss_exposure; /* exposure mode */
128 #ifdef DPMSINFO_IN_DPMS_H
129 BOOL b_ss_dpms; /* DPMS mode */
132 /* Mouse pointer properties */
133 vlc_bool_t b_mouse_pointer_visible;
134 mtime_t i_time_mouse_last_moved; /* used to auto-hide pointer*/
135 Cursor blank_cursor; /* the hidden cursor */
136 mtime_t i_time_button_last_pressed; /* to track dbl-clicks */
137 Pixmap cursor_pixmap;
139 /* Window manager properties */
141 Atom net_wm_state_fullscreen;
142 vlc_bool_t b_net_wm_state_fullscreen;
143 Atom net_wm_state_above;
144 vlc_bool_t b_net_wm_state_above;
145 Atom net_wm_state_stays_on_top;
146 vlc_bool_t b_net_wm_state_stays_on_top;
147 Atom net_wm_state_below;
148 vlc_bool_t b_net_wm_state_below;
150 #ifdef MODULE_NAME_IS_glx
157 #ifdef MODULE_NAME_IS_xvmc
158 /* XvMC related stuff here */
159 xvmc_macroblocks_t macroblocks;
160 xvmc_capabilities_t *xvmc_cap;
161 unsigned int xvmc_num_cap;
162 unsigned int xvmc_max_subpic_x;
163 unsigned int xvmc_max_subpic_y;
167 XvMCSubpicture *old_subpic;
168 XvMCSubpicture *new_subpic;
169 xx44_palette_t palette;
172 int cpu_save_enabled;
173 int reverse_nvidia_palette;
177 * These variables are protected by the context lock:
179 unsigned xvmc_cur_cap;
180 int xvmc_backend_subpic;
183 xvmc_surface_handler_t xvmc_surf_handler;
186 unsigned last_accel_request;
188 unsigned xvmc_height;
189 int have_xvmc_autopaint;
190 int xvmc_xoverlay_type;
194 * Only creation and destruction of the below.
198 XShmSegmentInfo subShmInfo;
201 * The mutex below is needed since XlockDisplay wasn't really enough
202 * to protect the XvMC Calls.
204 context_lock_t xvmc_lock;
205 subpicture_t * p_last_subtitle_save;
206 int xvmc_deinterlace_method;
210 //alphablend_t alphablend_extra_data;
218 osso_context_t *p_octx;
219 int i_backlight_on_counter;
225 /*****************************************************************************
226 * picture_sys_t: direct buffer method descriptor
227 *****************************************************************************
228 * This structure is part of the picture descriptor, it describes the
229 * XVideo specific properties of a direct buffer.
230 *****************************************************************************/
233 IMAGE_TYPE * p_image;
235 #ifdef HAVE_SYS_SHM_H
236 XShmSegmentInfo shminfo; /* shared memory zone information */
239 #ifdef MODULE_NAME_IS_xvmc
240 XvMCSurface *xvmc_surf;
241 vlc_xxmc_t xxmc_data;
243 vout_thread_t *p_vout;
248 /*****************************************************************************
249 * mwmhints_t: window manager hints
250 *****************************************************************************
251 * Fullscreen needs to be able to hide the wm decorations so we provide
252 * this structure to make it easier.
253 *****************************************************************************/
254 #define MWM_HINTS_DECORATIONS (1L << 1)
255 #define PROP_MWM_HINTS_ELEMENTS 5
257 typedef struct mwmhints_t
260 unsigned long functions;
261 unsigned long decorations;
262 signed long input_mode;
263 unsigned long status;
266 /*****************************************************************************
268 *****************************************************************************/
269 #ifdef MODULE_NAME_IS_xvideo
270 # define MAX_DIRECTBUFFERS 10
271 #elif defined(MODULE_NAME_IS_xvmc)
272 # define MAX_DIRECTBUFFERS 12
274 # define MAX_DIRECTBUFFERS 2
277 /*****************************************************************************
279 *****************************************************************************/
281 #ifdef MODULE_NAME_IS_xvmc
284 { /* CLUT == Color LookUp Table */
291 #define XX44_PALETTE_SIZE 32
292 #define OVL_PALETTE_SIZE 256
293 #define XVMC_MAX_SURFACES 16
294 #define XVMC_MAX_SUBPICTURES 4
295 #define FOURCC_IA44 0x34344149
296 #define FOURCC_AI44 0x34344941
302 uint32_t cluts[XX44_PALETTE_SIZE];
303 /* cache palette entries for both colors and clip_colors */
304 int lookup_cache[OVL_PALETTE_SIZE*2];
308 * Functions to handle the vlc-specific palette.
311 void clear_xx44_palette( xx44_palette_t *p );
314 * Convert the xine-specific palette to something useful.
317 void xx44_to_xvmc_palette( const xx44_palette_t *p,unsigned char *xvmc_palette,
318 unsigned first_xx44_entry, unsigned num_xx44_entries,
319 unsigned num_xvmc_components, char *xvmc_components );
323 vlc_macroblocks_t vlc_mc;
324 XvMCBlockArray blocks; /* pointer to memory for dct block array */
326 XvMCMacroBlock *macroblockptr; /* pointer to current macro block */
327 XvMCMacroBlock *macroblockbaseptr; /* pointer to base MacroBlock in MB array */
328 XvMCMacroBlockArray macro_blocks; /* pointer to memory for macroblock array */
330 } xvmc_macroblocks_t;
334 unsigned int mpeg_flags;
335 unsigned int accel_flags;
336 unsigned int max_width;
337 unsigned int max_height;
338 unsigned int sub_max_width;
339 unsigned int sub_max_height;
341 XvImageFormatValues subPicType;
343 } xvmc_capabilities_t;
345 typedef struct xvmc_surface_handler_s
347 XvMCSurface surfaces[XVMC_MAX_SURFACES];
348 int surfInUse[XVMC_MAX_SURFACES];
349 int surfValid[XVMC_MAX_SURFACES];
350 XvMCSubpicture subpictures[XVMC_MAX_SUBPICTURES];
351 int subInUse[XVMC_MAX_SUBPICTURES];
352 int subValid[XVMC_MAX_SUBPICTURES];
353 pthread_mutex_t mutex;
354 } xvmc_surface_handler_t;
356 typedef struct context_lock_s
358 pthread_mutex_t mutex;
363 #define XVMCLOCKDISPLAY(display) XLockDisplay(display);
364 #define XVMCUNLOCKDISPLAY(display) XUnlockDisplay(display);
366 void xvmc_context_reader_unlock( context_lock_t *c );
367 void xvmc_context_reader_lock( context_lock_t *c );
368 void xvmc_context_writer_lock( context_lock_t *c );
369 void xvmc_context_writer_unlock( context_lock_t *c );
370 void free_context_lock( context_lock_t *c );
371 void xxmc_dispose_context( vout_thread_t *p_vout );
373 int xxmc_xvmc_surface_valid( vout_thread_t *p_vout, XvMCSurface *surf );
374 void xxmc_xvmc_free_surface( vout_thread_t *p_vout, XvMCSurface *surf );
376 void xvmc_vld_slice( picture_t *picture );
377 void xvmc_vld_frame( picture_t *picture );
379 void xxmc_do_update_frame( picture_t *picture, uint32_t width, uint32_t height,
380 double ratio, int format, int flags);
382 int checkXvMCCap( vout_thread_t *p_vout);
384 XvMCSubpicture *xxmc_xvmc_alloc_subpicture( vout_thread_t *p_vout,
385 XvMCContext *context, unsigned short width, unsigned short height,
388 void xxmc_xvmc_free_subpicture( vout_thread_t *p_vout, XvMCSubpicture *sub );
389 void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img, int dst_width,
390 int dst_height, int dst_pitch, xx44_palette_t *palette,int ia44);