xcommon.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * xcommon.h: Defines common to the X11 and XVideo plugins
00003  *****************************************************************************
00004  * Copyright (C) 1998-2001 the VideoLAN team
00005  * $Id: c51f43708deabb7aea7e3cc6db00cc99c591e3eb $
00006  *
00007  * Authors: Vincent Seguin <seguin@via.ecp.fr>
00008  *          Samuel Hocevar <sam@zoy.org>
00009  *          David Kennedy <dkennedy@tinytoad.com>
00010  *          Gildas Bazin <gbazin@netcourrier.com>
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00025  *****************************************************************************/
00026 
00027 /*****************************************************************************
00028  * Defines
00029  *****************************************************************************/
00030 #if defined(MODULE_NAME_IS_xvmc)
00031 #   define IMAGE_TYPE     XvImage
00032 #   define EXTRA_ARGS     int i_xvport, int i_chroma, int i_bits_per_pixel
00033 #   define EXTRA_ARGS_SHM int i_xvport, int i_chroma, XShmSegmentInfo *p_shm
00034 #   define DATA_SIZE(p)   (p)->data_size
00035 #   define IMAGE_FREE     XFree      /* There is nothing like XvDestroyImage */
00036 #else
00037 #   define IMAGE_TYPE     XImage
00038 #   define EXTRA_ARGS     Visual *p_visual, int i_depth, int i_bytes_per_pixel
00039 #   define EXTRA_ARGS_SHM Visual *p_visual, int i_depth, XShmSegmentInfo *p_shm
00040 #   define DATA_SIZE(p)   ((p)->bytes_per_line * (p)->height)
00041 #   define IMAGE_FREE     XDestroyImage
00042 #endif
00043 
00044 #define X11_FOURCC( a, b, c, d ) \
00045         ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) \
00046            | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
00047 #define VLC2X11_FOURCC( i ) \
00048         X11_FOURCC( ((char *)&i)[0], ((char *)&i)[1], ((char *)&i)[2], \
00049                     ((char *)&i)[3] )
00050 #define X112VLC_FOURCC( i ) \
00051         VLC_FOURCC( i & 0xff, (i >> 8) & 0xff, (i >> 16) & 0xff, \
00052                     (i >> 24) & 0xff )
00053 
00054 struct vout_window_t;
00055 
00056 /*****************************************************************************
00057  * x11_window_t: X11 window descriptor
00058  *****************************************************************************
00059  * This structure contains all the data necessary to describe an X11 window.
00060  *****************************************************************************/
00061 typedef struct x11_window_t
00062 {
00063     struct vout_window_t*owner_window;               /* owner window (if any) */
00064     Window              base_window;                          /* base window */
00065     Window              video_window;     /* sub-window for displaying video */
00066     GC                  gc;              /* graphic context instance handler */
00067 
00068     unsigned int        i_width;                             /* window width */
00069     unsigned int        i_height;                           /* window height */
00070     int                 i_x;                          /* window x coordinate */
00071     int                 i_y;                          /* window y coordinate */
00072 
00073     Atom                wm_protocols;
00074     Atom                wm_delete_window;
00075 } x11_window_t;
00076 
00077 /*****************************************************************************
00078  * Xxmc defines
00079  *****************************************************************************/
00080 
00081 #ifdef MODULE_NAME_IS_xvmc
00082 
00083 typedef struct
00084 {         /* CLUT == Color LookUp Table */
00085     uint8_t cb;
00086     uint8_t cr;
00087     uint8_t y;
00088     uint8_t foo;
00089 } clut_t;
00090 
00091 #define XX44_PALETTE_SIZE 32
00092 #define OVL_PALETTE_SIZE 256
00093 #define XVMC_MAX_SURFACES 16
00094 #define XVMC_MAX_SUBPICTURES 4
00095 #define FOURCC_IA44 0x34344149
00096 #define FOURCC_AI44 0x34344941
00097 
00098 typedef struct
00099 {
00100     unsigned size;
00101     unsigned max_used;
00102     uint32_t cluts[XX44_PALETTE_SIZE];
00103     /* cache palette entries for both colors and clip_colors */
00104     int lookup_cache[OVL_PALETTE_SIZE*2];
00105 } xx44_palette_t;
00106 
00107 /*
00108  * Functions to handle the vlc-specific palette.
00109  */
00110 
00111 void clear_xx44_palette( xx44_palette_t *p );
00112 
00113 /*
00114  * Convert the xine-specific palette to something useful.
00115  */
00116 
00117 void xx44_to_xvmc_palette( const xx44_palette_t *p,unsigned char *xvmc_palette,
00118              unsigned first_xx44_entry, unsigned num_xx44_entries,
00119              unsigned num_xvmc_components, char *xvmc_components );
00120 
00121 typedef struct
00122 {
00123     vlc_macroblocks_t   vlc_mc;
00124     XvMCBlockArray      blocks;            /* pointer to memory for dct block array  */
00125     int                 num_blocks;
00126     XvMCMacroBlock      *macroblockptr;     /* pointer to current macro block         */
00127     XvMCMacroBlock      *macroblockbaseptr; /* pointer to base MacroBlock in MB array */
00128     XvMCMacroBlockArray macro_blocks;      /* pointer to memory for macroblock array */
00129     int                 slices;
00130 } xvmc_macroblocks_t;
00131 
00132 typedef struct
00133 {
00134     unsigned int        mpeg_flags;
00135     unsigned int        accel_flags;
00136     unsigned int        max_width;
00137     unsigned int        max_height;
00138     unsigned int        sub_max_width;
00139     unsigned int        sub_max_height;
00140     int                 type_id;
00141     XvImageFormatValues subPicType;
00142     int                 flags;
00143 } xvmc_capabilities_t;
00144 
00145 typedef struct xvmc_surface_handler_s
00146 {
00147     XvMCSurface         surfaces[XVMC_MAX_SURFACES];
00148     int                 surfInUse[XVMC_MAX_SURFACES];
00149     int                 surfValid[XVMC_MAX_SURFACES];
00150     XvMCSubpicture      subpictures[XVMC_MAX_SUBPICTURES];
00151     int                 subInUse[XVMC_MAX_SUBPICTURES];
00152     int                 subValid[XVMC_MAX_SUBPICTURES];
00153     pthread_mutex_t     mutex;
00154 } xvmc_surface_handler_t;
00155 
00156 typedef struct context_lock_s
00157 {
00158     pthread_mutex_t     mutex;
00159     pthread_cond_t      cond;
00160     int                 num_readers;
00161 } context_lock_t;
00162 
00163 #define XVMCLOCKDISPLAY(display) XLockDisplay(display);
00164 #define XVMCUNLOCKDISPLAY(display) XUnlockDisplay(display);
00165 
00166 void xvmc_context_reader_unlock( context_lock_t *c );
00167 void xvmc_context_reader_lock( context_lock_t *c );
00168 void xvmc_context_writer_lock( context_lock_t *c );
00169 void xvmc_context_writer_unlock( context_lock_t *c );
00170 void free_context_lock( context_lock_t *c );
00171 void xxmc_dispose_context( vout_thread_t *p_vout );
00172 
00173 int xxmc_xvmc_surface_valid( vout_thread_t *p_vout, XvMCSurface *surf );
00174 void xxmc_xvmc_free_surface( vout_thread_t *p_vout, XvMCSurface *surf );
00175 
00176 void xvmc_vld_slice( picture_t *picture );
00177 void xvmc_vld_frame( picture_t *picture );
00178 
00179 void xxmc_do_update_frame( picture_t *picture, uint32_t width, uint32_t height,
00180         double ratio, int format, int flags);
00181 
00182 int checkXvMCCap( vout_thread_t *p_vout);
00183 
00184 XvMCSubpicture *xxmc_xvmc_alloc_subpicture( vout_thread_t *p_vout,
00185         XvMCContext *context, unsigned short width, unsigned short height,
00186         int xvimage_id );
00187 
00188 void xxmc_xvmc_free_subpicture( vout_thread_t *p_vout, XvMCSubpicture *sub );
00189 void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img, int dst_width,
00190         int dst_height, int dst_pitch, xx44_palette_t *palette,int ia44);
00191 
00192 #endif /* XvMC defines */
00193 
00194 /*****************************************************************************
00195  * vout_sys_t: video output method descriptor
00196  *****************************************************************************
00197  * This structure is part of the video output thread descriptor.
00198  * It describes the X11 and XVideo specific properties of an output thread.
00199  *****************************************************************************/
00200 struct vout_sys_t
00201 {
00202     /* Internal settings and properties */
00203     Display *           p_display;                        /* display pointer */
00204 
00205     int                 i_screen;                           /* screen number */
00206 
00207     /* Our window */
00208     x11_window_t        window;
00209 
00210     /* X11 generic properties */
00211 #ifdef HAVE_SYS_SHM_H
00212     int                 i_shm_opcode;      /* shared memory extension opcode */
00213 #endif
00214 
00215 #if defined(MODULE_NAME_IS_xvmc)
00216     int                 i_xvport;
00217     bool          b_paint_colourkey;
00218     int                 i_colourkey;
00219 #endif
00220 
00221     /* Screen saver properties */
00222     int                 i_ss_timeout;                             /* timeout */
00223     int                 i_ss_interval;           /* interval between changes */
00224     int                 i_ss_blanking;                      /* blanking mode */
00225     int                 i_ss_exposure;                      /* exposure mode */
00226 #ifdef DPMSINFO_IN_DPMS_H
00227     BOOL                b_ss_dpms;                              /* DPMS mode */
00228 #endif
00229 
00230     /* Mouse pointer properties */
00231     bool          b_mouse_pointer_visible;
00232     mtime_t             i_time_mouse_last_moved; /* used to auto-hide pointer*/
00233     mtime_t             i_mouse_hide_timeout;      /* after time hide cursor */
00234     Cursor              blank_cursor;                   /* the hidden cursor */
00235     mtime_t             i_time_button_last_pressed;   /* to track dbl-clicks */
00236     Pixmap              cursor_pixmap;
00237 
00238 #ifdef MODULE_NAME_IS_glx
00239     /* GLX properties */
00240     int                 b_glx13;
00241     GLXContext          gwctx;
00242     GLXWindow           gwnd;
00243 #endif
00244 
00245 #ifdef MODULE_NAME_IS_xvmc
00246     /* XvMC related stuff here */
00247     xvmc_macroblocks_t  macroblocks;
00248     xvmc_capabilities_t *xvmc_cap;
00249     unsigned int        xvmc_num_cap;
00250     unsigned int        xvmc_max_subpic_x;
00251     unsigned int        xvmc_max_subpic_y;
00252     int                 xvmc_eventbase;
00253     int                 xvmc_errbase;
00254     int                 hwSubpictures;
00255     XvMCSubpicture      *old_subpic;
00256     XvMCSubpicture      *new_subpic;
00257     xx44_palette_t      palette;
00258     int                 first_overlay;
00259     float               cpu_saver;
00260     int                 cpu_save_enabled;
00261     int                 reverse_nvidia_palette;
00262     int                 context_flags;
00263 
00264     /*
00265      * These variables are protected by the context lock:
00266      */
00267     unsigned            xvmc_cur_cap;
00268     int                 xvmc_backend_subpic;
00269     XvMCContext         context;
00270     int                 contextActive;
00271     xvmc_surface_handler_t xvmc_surf_handler;
00272     unsigned            xvmc_mpeg;
00273     unsigned            xvmc_accel;
00274     unsigned            last_accel_request;
00275     unsigned            xvmc_width;
00276     unsigned            xvmc_height;
00277     int                 have_xvmc_autopaint;
00278     int                 xvmc_xoverlay_type;
00279     int                 unsigned_intra;
00280 
00281     /*
00282      * Only creation and destruction of the below.
00283      */
00284     char                *xvmc_palette;
00285     XvImage             *subImage;
00286     XShmSegmentInfo     subShmInfo;
00287 
00288     /*
00289      * The mutex below is needed since XlockDisplay wasn't really enough
00290      * to protect the XvMC Calls.
00291      */
00292     context_lock_t      xvmc_lock;
00293     subpicture_t *      p_last_subtitle_save;
00294     int                 xvmc_deinterlace_method;
00295     int                 xvmc_crop_style;
00296     mtime_t             last_date;
00297 
00298     //alphablend_t       alphablend_extra_data;
00299 #endif
00300 
00301 #ifdef HAVE_XSP
00302     int                 i_hw_scale;
00303 #endif
00304 };
00305 
00306 /*****************************************************************************
00307  * picture_sys_t: direct buffer method descriptor
00308  *****************************************************************************
00309  * This structure is part of the picture descriptor, it describes the
00310  * XVideo specific properties of a direct buffer.
00311  *****************************************************************************/
00312 struct picture_sys_t
00313 {
00314     IMAGE_TYPE *        p_image;
00315 
00316 #ifdef HAVE_SYS_SHM_H
00317     XShmSegmentInfo     shminfo;       /* shared memory zone information */
00318 #endif
00319 
00320 #ifdef MODULE_NAME_IS_xvmc
00321     XvMCSurface         *xvmc_surf;
00322     vlc_xxmc_t           xxmc_data;
00323     int                  last_sw_format;
00324     vout_thread_t        *p_vout;
00325     int                  nb_display;
00326 #endif
00327 };
00328 
00329 /*****************************************************************************
00330  * mwmhints_t: window manager hints
00331  *****************************************************************************
00332  * Fullscreen needs to be able to hide the wm decorations so we provide
00333  * this structure to make it easier.
00334  *****************************************************************************/
00335 #define MWM_HINTS_DECORATIONS   (1L << 1)
00336 #define PROP_MWM_HINTS_ELEMENTS 5
00337 
00338 typedef struct mwmhints_t
00339 {
00340     unsigned long flags;
00341     unsigned long functions;
00342     unsigned long decorations;
00343     signed   long input_mode;
00344     unsigned long status;
00345 } mwmhints_t;
00346 
00347 /*****************************************************************************
00348  * Chroma defines
00349  *****************************************************************************/
00350 #if defined(MODULE_NAME_IS_xvmc)
00351 #   define MAX_DIRECTBUFFERS (VOUT_MAX_PICTURES+2)
00352 #else
00353 #   define MAX_DIRECTBUFFERS 2
00354 #endif
00355 
00356 #ifndef MODULE_NAME_IS_glx
00357 IMAGE_TYPE *CreateImage    ( vout_thread_t *,
00358                              Display *, EXTRA_ARGS, int, int );
00359 #ifdef HAVE_SYS_SHM_H
00360 IMAGE_TYPE *CreateShmImage ( vout_thread_t *,
00361                                     Display *, EXTRA_ARGS_SHM, int, int );
00362 #endif
00363 #endif
00364 

Generated on Wed Mar 31 08:05:26 2010 for VLC by  doxygen 1.5.6