Merge svn changes up to r28461
[mplayer.git] / libvo / video_out.h
blobe0bc79976e64573fa5a376d118f62326e55f0d33
1 /*
2 * video_out.h
4 * Copyright (C) Aaron Holtzman - Aug 1999
5 * Strongly modified, most parts rewritten: A'rpi/ESP-team - 2000-2001
6 * (C) MPlayer Developers
8 */
10 #ifndef MPLAYER_VIDEO_OUT_H
11 #define MPLAYER_VIDEO_OUT_H
13 #include <inttypes.h>
14 #include <stdarg.h>
16 //#include "font_load.h"
17 #include "libmpcodecs/img_format.h"
18 //#include "vidix/vidix.h"
20 #define VO_EVENT_EXPOSE 1
21 #define VO_EVENT_RESIZE 2
22 #define VO_EVENT_KEYPRESS 4
24 /* Obsolete: VOCTRL_QUERY_VAA 1 */
25 /* does the device support the required format */
26 #define VOCTRL_QUERY_FORMAT 2
27 /* signal a device reset seek */
28 #define VOCTRL_RESET 3
29 /* true if vo driver can use GUI created windows */
30 #define VOCTRL_GUISUPPORT 4
31 #define VOCTRL_GUI_NOWINDOW 19
32 /* used to switch to fullscreen */
33 #define VOCTRL_FULLSCREEN 5
34 /* signal a device pause */
35 #define VOCTRL_PAUSE 7
36 /* start/resume playback */
37 #define VOCTRL_RESUME 8
38 /* libmpcodecs direct rendering: */
39 #define VOCTRL_GET_IMAGE 9
40 #define VOCTRL_DRAW_IMAGE 13
41 #define VOCTRL_SET_SPU_PALETTE 14
42 /* decoding ahead: */
43 #define VOCTRL_GET_NUM_FRAMES 10
44 #define VOCTRL_GET_FRAME_NUM 11
45 #define VOCTRL_SET_FRAME_NUM 12
46 #define VOCTRL_GET_PANSCAN 15
47 #define VOCTRL_SET_PANSCAN 16
48 /* equalizer controls */
49 #define VOCTRL_SET_EQUALIZER 17
50 struct voctrl_set_equalizer_args {
51 const char *name;
52 int value;
54 #define VOCTRL_GET_EQUALIZER 18
55 struct voctrl_get_equalizer_args {
56 const char *name;
57 int *valueptr;
59 //#define VOCTRL_GUI_NOWINDOW 19
60 /* Frame duplication */
61 #define VOCTRL_DUPLICATE_FRAME 20
62 // ... 21
63 #define VOCTRL_START_SLICE 21
65 #define VOCTRL_ONTOP 25
66 #define VOCTRL_ROOTWIN 26
67 #define VOCTRL_BORDER 27
68 #define VOCTRL_DRAW_EOSD 28
69 #define VOCTRL_GET_EOSD_RES 29
70 typedef struct {
71 int w, h; // screen dimensions, including black borders
72 int mt, mb, ml, mr; // borders (top, bottom, left, right)
73 } mp_eosd_res_t;
75 #define VOCTRL_SET_DEINTERLACE 30
76 #define VOCTRL_GET_DEINTERLACE 31
78 #define VOCTRL_UPDATE_SCREENINFO 32
80 // Vo can be used by xover
81 #define VOCTRL_XOVERLAY_SUPPORT 22
83 #define VOCTRL_XOVERLAY_SET_COLORKEY 24
84 typedef struct {
85 uint32_t x11; // The raw x11 color
86 uint16_t r,g,b;
87 } mp_colorkey_t;
89 #define VOCTRL_XOVERLAY_SET_WIN 23
90 #define VOCTRL_REDRAW_OSD 24
92 typedef struct {
93 int x,y;
94 int w,h;
95 } mp_win_t;
97 #define VO_TRUE 1
98 #define VO_FALSE 0
99 #define VO_ERROR -1
100 #define VO_NOTAVAIL -2
101 #define VO_NOTIMPL -3
103 #define VOFLAG_FULLSCREEN 0x01
104 #define VOFLAG_MODESWITCHING 0x02
105 #define VOFLAG_SWSCALE 0x04
106 #define VOFLAG_FLIPPING 0x08
107 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
109 typedef struct vo_info_s
111 /* driver name ("Matrox Millennium G200/G400" */
112 const char *name;
113 /* short name (for config strings) ("mga") */
114 const char *short_name;
115 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
116 const char *author;
117 /* any additional comments */
118 const char *comment;
119 } vo_info_t;
121 struct vo;
122 struct osd_state;
124 struct vo_driver {
125 // Driver uses new API
126 int is_new;
128 // This is set if the driver is not new and contains pointers to
129 // old-API functions to be used instead of the ones below.
130 struct vo_old_functions *old_functions;
132 const vo_info_t *info;
134 * Preinitializes driver (real INITIALIZATION)
135 * arg - currently it's vo_subdevice
136 * returns: zero on successful initialization, non-zero on error.
138 int (*preinit)(struct vo *vo, const char *arg);
140 * Initialize (means CONFIGURE) the display driver.
141 * params:
142 * width,height: image source size
143 * d_width,d_height: size of the requested window size, just a hint
144 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
145 * title: window title, if available
146 * format: fourcc of pixel format
147 * returns : zero on successful initialization, non-zero on error.
149 int (*config)(struct vo *vo, uint32_t width, uint32_t height,
150 uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
151 char *title, uint32_t format);
154 * Control interface
156 int (*control)(struct vo *vo, uint32_t request, void *data);
159 * Display a new RGB/BGR frame of the video to the screen.
160 * params:
161 * src[0] - pointer to the image
163 int (*draw_frame)(struct vo *vo, uint8_t *src[]);
166 * Draw a planar YUV slice to the buffer:
167 * params:
168 * src[3] = source image planes (Y,U,V)
169 * stride[3] = source image planes line widths (in bytes)
170 * w,h = width*height of area to be copied (in Y pixels)
171 * x,y = position at the destination image (in Y pixels)
173 int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
174 int h, int x, int y);
177 * Draws OSD to the screen buffer
179 void (*draw_osd)(struct vo *vo, struct osd_state *osd);
182 * Blit/Flip buffer to the screen. Must be called after each frame!
184 void (*flip_page)(struct vo *vo);
187 * This func is called after every frames to handle keyboard and
188 * other events. It's called in PAUSE mode too!
190 void (*check_events)(struct vo *vo);
193 * Closes driver. Should restore the original state of the system.
195 void (*uninit)(struct vo *vo);
198 struct vo_old_functions {
199 int (*preinit)(const char *arg);
200 int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
201 uint32_t d_height, uint32_t fullscreen, char *title,
202 uint32_t format);
203 int (*control)(uint32_t request, void *data);
204 int (*draw_frame)(uint8_t *src[]);
205 int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
206 void (*draw_osd)(void);
207 void (*flip_page)(void);
208 void (*check_events)(void);
209 void (*uninit)(void);
212 struct vo {
213 int config_ok; // Last config call was successful?
214 int config_count; // Total number of successful config calls
215 const struct vo_driver *driver;
216 void *priv;
217 struct MPOpts *opts;
218 struct vo_x11_state *x11;
219 struct mp_fifo *key_fifo;
220 struct input_ctx *input_ctx;
222 // requested position/resolution
223 int dx;
224 int dy;
225 int dwidth;
226 int dheight;
228 int panscan_x;
229 int panscan_y;
230 float panscan_amount;
231 float monitor_aspect;
232 struct aspect_data {
233 int orgw; // real width
234 int orgh; // real height
235 int prew; // prescaled width
236 int preh; // prescaled height
237 int scrw; // horizontal resolution
238 int scrh; // vertical resolution
239 float asp;
240 } aspdat;
243 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
244 struct mp_fifo *key_fifo,
245 struct input_ctx *input_ctx);
246 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
247 uint32_t d_width, uint32_t d_height, uint32_t flags,
248 char *title, uint32_t format);
249 void list_video_out(void);
251 int vo_control(struct vo *vo, uint32_t request, void *data);
252 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
253 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
254 void vo_draw_osd(struct vo *vo, struct osd_state *osd);
255 void vo_flip_page(struct vo *vo);
256 void vo_check_events(struct vo *vo);
257 void vo_destroy(struct vo *vo);
260 // NULL terminated array of all drivers
261 extern const struct vo_driver *video_out_drivers[];
263 extern int xinerama_screen;
264 extern int xinerama_x;
265 extern int xinerama_y;
267 extern int vo_grabpointer;
268 extern int vo_doublebuffering;
269 extern int vo_directrendering;
270 extern int vo_vsync;
271 extern int vo_fs;
272 extern int vo_fsmode;
273 extern float vo_panscan;
274 extern int vo_adapter_num;
275 extern int vo_refresh_rate;
276 extern int vo_keepaspect;
277 extern int vo_rootwin;
278 extern int vo_border;
280 extern int vo_nomouse_input;
282 extern int vo_pts;
283 extern float vo_fps;
285 extern char *vo_subdevice;
287 extern int vo_colorkey;
289 extern int WinID;
291 typedef struct {
292 float min;
293 float max;
294 } range_t;
296 float range_max(range_t *r);
297 int in_range(range_t *r, float f);
298 range_t *str2range(char *s);
299 extern char *monitor_hfreq_str;
300 extern char *monitor_vfreq_str;
301 extern char *monitor_dotclock_str;
303 struct keymap {
304 int from;
305 int to;
307 int lookup_keymap_table(const struct keymap *map, int key);
309 #endif /* MPLAYER_VIDEO_OUT_H */