xcommon.h
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:15k
源码类别:

midi

开发平台:

Unix_Linux

  1. /*****************************************************************************
  2.  * xcommon.h: Defines common to the X11 and XVideo plugins
  3.  *****************************************************************************
  4.  * Copyright (C) 1998-2001 the VideoLAN team
  5.  * $Id: 736cfdf49f37e7ea30742b1890936a60dfedfa2d $
  6.  *
  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>
  11.  *
  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.
  16.  *
  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.
  21.  *
  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.  *****************************************************************************/
  26. /*****************************************************************************
  27.  * Defines
  28.  *****************************************************************************/
  29. #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
  30. #   define IMAGE_TYPE     XvImage
  31. #   define EXTRA_ARGS     int i_xvport, int i_chroma, int i_bits_per_pixel
  32. #   define EXTRA_ARGS_SHM int i_xvport, int i_chroma, XShmSegmentInfo *p_shm
  33. #   define DATA_SIZE(p)   (p)->data_size
  34. #   define IMAGE_FREE     XFree      /* There is nothing like XvDestroyImage */
  35. #else
  36. #   define IMAGE_TYPE     XImage
  37. #   define EXTRA_ARGS     Visual *p_visual, int i_depth, int i_bytes_per_pixel
  38. #   define EXTRA_ARGS_SHM Visual *p_visual, int i_depth, XShmSegmentInfo *p_shm
  39. #   define DATA_SIZE(p)   ((p)->bytes_per_line * (p)->height)
  40. #   define IMAGE_FREE     XDestroyImage
  41. #endif
  42. #define X11_FOURCC( a, b, c, d ) 
  43.         ( ((uint32_t)a) | ( ((uint32_t)b) << 8 ) 
  44.            | ( ((uint32_t)c) << 16 ) | ( ((uint32_t)d) << 24 ) )
  45. #define VLC2X11_FOURCC( i ) 
  46.         X11_FOURCC( ((char *)&i)[0], ((char *)&i)[1], ((char *)&i)[2], 
  47.                     ((char *)&i)[3] )
  48. #define X112VLC_FOURCC( i ) 
  49.         VLC_FOURCC( i & 0xff, (i >> 8) & 0xff, (i >> 16) & 0xff, 
  50.                     (i >> 24) & 0xff )
  51. #ifdef HAVE_OSSO
  52. #include <libosso.h>
  53. #endif
  54. struct vout_window_t;
  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
  61. {
  62.     struct vout_window_t*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 */
  66.     unsigned int        i_width;                             /* window width */
  67.     unsigned int        i_height;                           /* window height */
  68.     int                 i_x;                          /* window x coordinate */
  69.     int                 i_y;                          /* window y coordinate */
  70.     Atom                wm_protocols;
  71.     Atom                wm_delete_window;
  72. #ifdef HAVE_XINERAMA
  73.     int                 i_screen;
  74. #endif
  75. } x11_window_t;
  76. /*****************************************************************************
  77.  * Xxmc defines
  78.  *****************************************************************************/
  79. #ifdef MODULE_NAME_IS_xvmc
  80. typedef struct
  81. {         /* CLUT == Color LookUp Table */
  82.     uint8_t cb;
  83.     uint8_t cr;
  84.     uint8_t y;
  85.     uint8_t foo;
  86. } clut_t;
  87. #define XX44_PALETTE_SIZE 32
  88. #define OVL_PALETTE_SIZE 256
  89. #define XVMC_MAX_SURFACES 16
  90. #define XVMC_MAX_SUBPICTURES 4
  91. #define FOURCC_IA44 0x34344149
  92. #define FOURCC_AI44 0x34344941
  93. typedef struct
  94. {
  95.     unsigned size;
  96.     unsigned max_used;
  97.     uint32_t cluts[XX44_PALETTE_SIZE];
  98.     /* cache palette entries for both colors and clip_colors */
  99.     int lookup_cache[OVL_PALETTE_SIZE*2];
  100. } xx44_palette_t;
  101. /*
  102.  * Functions to handle the vlc-specific palette.
  103.  */
  104. void clear_xx44_palette( xx44_palette_t *p );
  105. /*
  106.  * Convert the xine-specific palette to something useful.
  107.  */
  108. void xx44_to_xvmc_palette( const xx44_palette_t *p,unsigned char *xvmc_palette,
  109.              unsigned first_xx44_entry, unsigned num_xx44_entries,
  110.              unsigned num_xvmc_components, char *xvmc_components );
  111. typedef struct
  112. {
  113.     vlc_macroblocks_t   vlc_mc;
  114.     XvMCBlockArray      blocks;            /* pointer to memory for dct block array  */
  115.     int                 num_blocks;
  116.     XvMCMacroBlock      *macroblockptr;     /* pointer to current macro block         */
  117.     XvMCMacroBlock      *macroblockbaseptr; /* pointer to base MacroBlock in MB array */
  118.     XvMCMacroBlockArray macro_blocks;      /* pointer to memory for macroblock array */
  119.     int                 slices;
  120. } xvmc_macroblocks_t;
  121. typedef struct
  122. {
  123.     unsigned int        mpeg_flags;
  124.     unsigned int        accel_flags;
  125.     unsigned int        max_width;
  126.     unsigned int        max_height;
  127.     unsigned int        sub_max_width;
  128.     unsigned int        sub_max_height;
  129.     int                 type_id;
  130.     XvImageFormatValues subPicType;
  131.     int                 flags;
  132. } xvmc_capabilities_t;
  133. typedef struct xvmc_surface_handler_s
  134. {
  135.     XvMCSurface         surfaces[XVMC_MAX_SURFACES];
  136.     int                 surfInUse[XVMC_MAX_SURFACES];
  137.     int                 surfValid[XVMC_MAX_SURFACES];
  138.     XvMCSubpicture      subpictures[XVMC_MAX_SUBPICTURES];
  139.     int                 subInUse[XVMC_MAX_SUBPICTURES];
  140.     int                 subValid[XVMC_MAX_SUBPICTURES];
  141.     pthread_mutex_t     mutex;
  142. } xvmc_surface_handler_t;
  143. typedef struct context_lock_s
  144. {
  145.     pthread_mutex_t     mutex;
  146.     pthread_cond_t      cond;
  147.     int                 num_readers;
  148. } context_lock_t;
  149. #define XVMCLOCKDISPLAY(display) XLockDisplay(display);
  150. #define XVMCUNLOCKDISPLAY(display) XUnlockDisplay(display);
  151. void xvmc_context_reader_unlock( context_lock_t *c );
  152. void xvmc_context_reader_lock( context_lock_t *c );
  153. void xvmc_context_writer_lock( context_lock_t *c );
  154. void xvmc_context_writer_unlock( context_lock_t *c );
  155. void free_context_lock( context_lock_t *c );
  156. void xxmc_dispose_context( vout_thread_t *p_vout );
  157. int xxmc_xvmc_surface_valid( vout_thread_t *p_vout, XvMCSurface *surf );
  158. void xxmc_xvmc_free_surface( vout_thread_t *p_vout, XvMCSurface *surf );
  159. void xvmc_vld_slice( picture_t *picture );
  160. void xvmc_vld_frame( picture_t *picture );
  161. void xxmc_do_update_frame( picture_t *picture, uint32_t width, uint32_t height,
  162.         double ratio, int format, int flags);
  163. int checkXvMCCap( vout_thread_t *p_vout);
  164. XvMCSubpicture *xxmc_xvmc_alloc_subpicture( vout_thread_t *p_vout,
  165.         XvMCContext *context, unsigned short width, unsigned short height,
  166.         int xvimage_id );
  167. void xxmc_xvmc_free_subpicture( vout_thread_t *p_vout, XvMCSubpicture *sub );
  168. void blend_xx44( uint8_t *dst_img, subpicture_t *sub_img, int dst_width,
  169.         int dst_height, int dst_pitch, xx44_palette_t *palette,int ia44);
  170. #endif /* XvMC defines */
  171. /*****************************************************************************
  172.  * vout_sys_t: video output method descriptor
  173.  *****************************************************************************
  174.  * This structure is part of the video output thread descriptor.
  175.  * It describes the X11 and XVideo specific properties of an output thread.
  176.  *****************************************************************************/
  177. struct vout_sys_t
  178. {
  179.     /* Internal settings and properties */
  180.     Display *           p_display;                        /* display pointer */
  181.     Visual *            p_visual;                          /* visual pointer */
  182.     int                 i_screen;                           /* screen number */
  183.     /* Our current window */
  184.     x11_window_t *      p_win;
  185.     /* Our two windows */
  186.     x11_window_t        original_window;
  187.     x11_window_t        fullscreen_window;
  188.     /* key and mouse event handling */
  189.     int                 i_vout_event;  /* 1(Fullsupport), 2(FullscreenOnly), 3(none) */
  190.     /* X11 generic properties */
  191.     bool          b_altfullscreen;          /* which fullscreen method */
  192. #ifdef HAVE_SYS_SHM_H
  193.     int                 i_shm_opcode;      /* shared memory extension opcode */
  194. #endif
  195. #if defined(MODULE_NAME_IS_xvideo) || defined(MODULE_NAME_IS_xvmc)
  196.     int                 i_xvport;
  197.     bool          b_paint_colourkey;
  198.     int                 i_colourkey;
  199. #else
  200.     Colormap            colormap;               /* colormap used (8bpp only) */
  201.     unsigned int        i_screen_depth;
  202.     unsigned int        i_bytes_per_pixel;
  203.     unsigned int        i_bytes_per_line;
  204. #endif
  205.     /* Screen saver properties */
  206.     int                 i_ss_timeout;                             /* timeout */
  207.     int                 i_ss_interval;           /* interval between changes */
  208.     int                 i_ss_blanking;                      /* blanking mode */
  209.     int                 i_ss_exposure;                      /* exposure mode */
  210. #ifdef DPMSINFO_IN_DPMS_H
  211.     BOOL                b_ss_dpms;                              /* DPMS mode */
  212. #endif
  213.     /* Mouse pointer properties */
  214.     bool          b_mouse_pointer_visible;
  215.     mtime_t             i_time_mouse_last_moved; /* used to auto-hide pointer*/
  216.     mtime_t             i_mouse_hide_timeout;      /* after time hide cursor */
  217.     Cursor              blank_cursor;                   /* the hidden cursor */
  218.     mtime_t             i_time_button_last_pressed;   /* to track dbl-clicks */
  219.     Pixmap              cursor_pixmap;
  220.     /* Window manager properties */
  221.     Atom                net_wm_state;
  222.     Atom                net_wm_state_fullscreen;
  223.     bool          b_net_wm_state_fullscreen;
  224.     Atom                net_wm_state_above;
  225.     bool          b_net_wm_state_above;
  226.     Atom                net_wm_state_stays_on_top;
  227.     bool          b_net_wm_state_stays_on_top;
  228.     Atom                net_wm_state_below;
  229.     bool          b_net_wm_state_below;
  230. #ifdef MODULE_NAME_IS_glx
  231.     /* GLX properties */
  232.     int                 b_glx13;
  233.     GLXContext          gwctx;
  234.     GLXWindow           gwnd;
  235. #endif
  236. #ifdef MODULE_NAME_IS_xvmc
  237.     /* XvMC related stuff here */
  238.     xvmc_macroblocks_t  macroblocks;
  239.     xvmc_capabilities_t *xvmc_cap;
  240.     unsigned int        xvmc_num_cap;
  241.     unsigned int        xvmc_max_subpic_x;
  242.     unsigned int        xvmc_max_subpic_y;
  243.     int                 xvmc_eventbase;
  244.     int                 xvmc_errbase;
  245.     int                 hwSubpictures;
  246.     XvMCSubpicture      *old_subpic;
  247.     XvMCSubpicture      *new_subpic;
  248.     xx44_palette_t      palette;
  249.     int                 first_overlay;
  250.     float               cpu_saver;
  251.     int                 cpu_save_enabled;
  252.     int                 reverse_nvidia_palette;
  253.     int                 context_flags;
  254.     /*
  255.      * These variables are protected by the context lock:
  256.      */
  257.     unsigned            xvmc_cur_cap;
  258.     int                 xvmc_backend_subpic;
  259.     XvMCContext         context;
  260.     int                 contextActive;
  261.     xvmc_surface_handler_t xvmc_surf_handler;
  262.     unsigned            xvmc_mpeg;
  263.     unsigned            xvmc_accel;
  264.     unsigned            last_accel_request;
  265.     unsigned            xvmc_width;
  266.     unsigned            xvmc_height;
  267.     int                 have_xvmc_autopaint;
  268.     int                 xvmc_xoverlay_type;
  269.     int                 unsigned_intra;
  270.     /*
  271.      * Only creation and destruction of the below.
  272.      */
  273.     char                *xvmc_palette;
  274.     XvImage             *subImage;
  275.     XShmSegmentInfo     subShmInfo;
  276.     /*
  277.      * The mutex below is needed since XlockDisplay wasn't really enough
  278.      * to protect the XvMC Calls.
  279.      */
  280.     context_lock_t      xvmc_lock;
  281.     subpicture_t *      p_last_subtitle_save;
  282.     int                 xvmc_deinterlace_method;
  283.     int                 xvmc_crop_style;
  284.     mtime_t             last_date;
  285.     //alphablend_t       alphablend_extra_data;
  286. #endif
  287. #ifdef HAVE_XSP
  288.     int                 i_hw_scale;
  289. #endif
  290. #ifdef HAVE_OSSO
  291.     osso_context_t      *p_octx;
  292.     int                 i_backlight_on_counter;
  293. #endif
  294. };
  295. /*****************************************************************************
  296.  * picture_sys_t: direct buffer method descriptor
  297.  *****************************************************************************
  298.  * This structure is part of the picture descriptor, it describes the
  299.  * XVideo specific properties of a direct buffer.
  300.  *****************************************************************************/
  301. struct picture_sys_t
  302. {
  303.     IMAGE_TYPE *        p_image;
  304. #ifdef HAVE_SYS_SHM_H
  305.     XShmSegmentInfo     shminfo;       /* shared memory zone information */
  306. #endif
  307. #ifdef MODULE_NAME_IS_xvmc
  308.     XvMCSurface         *xvmc_surf;
  309.     vlc_xxmc_t           xxmc_data;
  310.     int                  last_sw_format;
  311.     vout_thread_t        *p_vout;
  312.     int                  nb_display;
  313. #endif
  314. };
  315. /*****************************************************************************
  316.  * mwmhints_t: window manager hints
  317.  *****************************************************************************
  318.  * Fullscreen needs to be able to hide the wm decorations so we provide
  319.  * this structure to make it easier.
  320.  *****************************************************************************/
  321. #define MWM_HINTS_DECORATIONS   (1L << 1)
  322. #define PROP_MWM_HINTS_ELEMENTS 5
  323. typedef struct mwmhints_t
  324. {
  325.     unsigned long flags;
  326.     unsigned long functions;
  327.     unsigned long decorations;
  328.     signed   long input_mode;
  329.     unsigned long status;
  330. } mwmhints_t;
  331. /*****************************************************************************
  332.  * Chroma defines
  333.  *****************************************************************************/
  334. #ifdef MODULE_NAME_IS_xvideo
  335. #   define MAX_DIRECTBUFFERS (VOUT_MAX_PICTURES)
  336. #elif defined(MODULE_NAME_IS_xvmc)
  337. #   define MAX_DIRECTBUFFERS (VOUT_MAX_PICTURES+2)
  338. #else
  339. #   define MAX_DIRECTBUFFERS 2
  340. #endif
  341. #ifndef MODULE_NAME_IS_glx
  342. static IMAGE_TYPE *CreateImage    ( vout_thread_t *,
  343.                                     Display *, EXTRA_ARGS, int, int );
  344. #ifdef HAVE_SYS_SHM_H
  345. IMAGE_TYPE *CreateShmImage ( vout_thread_t *,
  346.                                     Display *, EXTRA_ARGS_SHM, int, int );
  347. #endif
  348. #endif