Merge svn changes up to r28862
[mplayer.git] / libvo / video_out.h
blob6d4b405e56927d1644e5b889a417064d110a4432
1 /*
2 * Copyright (C) Aaron Holtzman - Aug 1999
3 * Strongly modified, most parts rewritten: A'rpi/ESP-team - 2000-2001
4 * (C) MPlayer developers
6 * This file is part of MPlayer.
8 * MPlayer is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * MPlayer is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #ifndef MPLAYER_VIDEO_OUT_H
24 #define MPLAYER_VIDEO_OUT_H
26 #include <inttypes.h>
27 #include <stdarg.h>
29 //#include "font_load.h"
30 #include "libmpcodecs/img_format.h"
31 //#include "vidix/vidix.h"
33 #define VO_EVENT_EXPOSE 1
34 #define VO_EVENT_RESIZE 2
35 #define VO_EVENT_KEYPRESS 4
37 /* Obsolete: VOCTRL_QUERY_VAA 1 */
38 /* does the device support the required format */
39 #define VOCTRL_QUERY_FORMAT 2
40 /* signal a device reset seek */
41 #define VOCTRL_RESET 3
42 /* true if vo driver can use GUI created windows */
43 #define VOCTRL_GUISUPPORT 4
44 #define VOCTRL_GUI_NOWINDOW 19
45 /* used to switch to fullscreen */
46 #define VOCTRL_FULLSCREEN 5
47 /* signal a device pause */
48 #define VOCTRL_PAUSE 7
49 /* start/resume playback */
50 #define VOCTRL_RESUME 8
51 /* libmpcodecs direct rendering: */
52 #define VOCTRL_GET_IMAGE 9
53 #define VOCTRL_DRAW_IMAGE 13
54 #define VOCTRL_SET_SPU_PALETTE 14
55 /* decoding ahead: */
56 #define VOCTRL_GET_NUM_FRAMES 10
57 #define VOCTRL_GET_FRAME_NUM 11
58 #define VOCTRL_SET_FRAME_NUM 12
59 #define VOCTRL_GET_PANSCAN 15
60 #define VOCTRL_SET_PANSCAN 16
61 /* equalizer controls */
62 #define VOCTRL_SET_EQUALIZER 17
63 struct voctrl_set_equalizer_args {
64 const char *name;
65 int value;
67 #define VOCTRL_GET_EQUALIZER 18
68 struct voctrl_get_equalizer_args {
69 const char *name;
70 int *valueptr;
72 //#define VOCTRL_GUI_NOWINDOW 19
73 /* Frame duplication */
74 #define VOCTRL_DUPLICATE_FRAME 20
75 // ... 21
76 #define VOCTRL_START_SLICE 21
78 #define VOCTRL_ONTOP 25
79 #define VOCTRL_ROOTWIN 26
80 #define VOCTRL_BORDER 27
81 #define VOCTRL_DRAW_EOSD 28
82 #define VOCTRL_GET_EOSD_RES 29
83 typedef struct {
84 int w, h; // screen dimensions, including black borders
85 int mt, mb, ml, mr; // borders (top, bottom, left, right)
86 } mp_eosd_res_t;
88 #define VOCTRL_SET_DEINTERLACE 30
89 #define VOCTRL_GET_DEINTERLACE 31
91 #define VOCTRL_UPDATE_SCREENINFO 32
93 // Vo can be used by xover
94 #define VOCTRL_XOVERLAY_SUPPORT 22
96 #define VOCTRL_XOVERLAY_SET_COLORKEY 24
97 typedef struct {
98 uint32_t x11; // The raw x11 color
99 uint16_t r,g,b;
100 } mp_colorkey_t;
102 #define VOCTRL_XOVERLAY_SET_WIN 23
103 #define VOCTRL_REDRAW_OSD 24
105 typedef struct {
106 int x,y;
107 int w,h;
108 } mp_win_t;
110 #define VO_TRUE 1
111 #define VO_FALSE 0
112 #define VO_ERROR -1
113 #define VO_NOTAVAIL -2
114 #define VO_NOTIMPL -3
116 #define VOFLAG_FULLSCREEN 0x01
117 #define VOFLAG_MODESWITCHING 0x02
118 #define VOFLAG_SWSCALE 0x04
119 #define VOFLAG_FLIPPING 0x08
120 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
122 typedef struct vo_info_s
124 /* driver name ("Matrox Millennium G200/G400" */
125 const char *name;
126 /* short name (for config strings) ("mga") */
127 const char *short_name;
128 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
129 const char *author;
130 /* any additional comments */
131 const char *comment;
132 } vo_info_t;
134 struct vo;
135 struct osd_state;
137 struct vo_driver {
138 // Driver uses new API
139 int is_new;
141 // This is set if the driver is not new and contains pointers to
142 // old-API functions to be used instead of the ones below.
143 struct vo_old_functions *old_functions;
145 const vo_info_t *info;
147 * Preinitializes driver (real INITIALIZATION)
148 * arg - currently it's vo_subdevice
149 * returns: zero on successful initialization, non-zero on error.
151 int (*preinit)(struct vo *vo, const char *arg);
153 * Initialize (means CONFIGURE) the display driver.
154 * params:
155 * width,height: image source size
156 * d_width,d_height: size of the requested window size, just a hint
157 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
158 * title: window title, if available
159 * format: fourcc of pixel format
160 * returns : zero on successful initialization, non-zero on error.
162 int (*config)(struct vo *vo, uint32_t width, uint32_t height,
163 uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
164 char *title, uint32_t format);
167 * Control interface
169 int (*control)(struct vo *vo, uint32_t request, void *data);
172 * Display a new RGB/BGR frame of the video to the screen.
173 * params:
174 * src[0] - pointer to the image
176 int (*draw_frame)(struct vo *vo, uint8_t *src[]);
179 * Draw a planar YUV slice to the buffer:
180 * params:
181 * src[3] = source image planes (Y,U,V)
182 * stride[3] = source image planes line widths (in bytes)
183 * w,h = width*height of area to be copied (in Y pixels)
184 * x,y = position at the destination image (in Y pixels)
186 int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
187 int h, int x, int y);
190 * Draws OSD to the screen buffer
192 void (*draw_osd)(struct vo *vo, struct osd_state *osd);
195 * Blit/Flip buffer to the screen. Must be called after each frame!
197 void (*flip_page)(struct vo *vo);
200 * This func is called after every frames to handle keyboard and
201 * other events. It's called in PAUSE mode too!
203 void (*check_events)(struct vo *vo);
206 * Closes driver. Should restore the original state of the system.
208 void (*uninit)(struct vo *vo);
211 struct vo_old_functions {
212 int (*preinit)(const char *arg);
213 int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
214 uint32_t d_height, uint32_t fullscreen, char *title,
215 uint32_t format);
216 int (*control)(uint32_t request, void *data);
217 int (*draw_frame)(uint8_t *src[]);
218 int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
219 void (*draw_osd)(void);
220 void (*flip_page)(void);
221 void (*check_events)(void);
222 void (*uninit)(void);
225 struct vo {
226 int config_ok; // Last config call was successful?
227 int config_count; // Total number of successful config calls
228 const struct vo_driver *driver;
229 void *priv;
230 struct MPOpts *opts;
231 struct vo_x11_state *x11;
232 struct mp_fifo *key_fifo;
233 struct input_ctx *input_ctx;
235 // requested position/resolution
236 int dx;
237 int dy;
238 int dwidth;
239 int dheight;
241 int panscan_x;
242 int panscan_y;
243 float panscan_amount;
244 float monitor_aspect;
245 struct aspect_data {
246 int orgw; // real width
247 int orgh; // real height
248 int prew; // prescaled width
249 int preh; // prescaled height
250 int scrw; // horizontal resolution
251 int scrh; // vertical resolution
252 float asp;
253 } aspdat;
256 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
257 struct mp_fifo *key_fifo,
258 struct input_ctx *input_ctx);
259 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
260 uint32_t d_width, uint32_t d_height, uint32_t flags,
261 char *title, uint32_t format);
262 void list_video_out(void);
264 int vo_control(struct vo *vo, uint32_t request, void *data);
265 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
266 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
267 void vo_draw_osd(struct vo *vo, struct osd_state *osd);
268 void vo_flip_page(struct vo *vo);
269 void vo_check_events(struct vo *vo);
270 void vo_destroy(struct vo *vo);
273 // NULL terminated array of all drivers
274 extern const struct vo_driver *video_out_drivers[];
276 extern int xinerama_screen;
277 extern int xinerama_x;
278 extern int xinerama_y;
280 extern int vo_grabpointer;
281 extern int vo_doublebuffering;
282 extern int vo_directrendering;
283 extern int vo_vsync;
284 extern int vo_fs;
285 extern int vo_fsmode;
286 extern float vo_panscan;
287 extern int vo_adapter_num;
288 extern int vo_refresh_rate;
289 extern int vo_keepaspect;
290 extern int vo_rootwin;
291 extern int vo_border;
293 extern int vo_nomouse_input;
295 extern int vo_pts;
296 extern float vo_fps;
298 extern char *vo_subdevice;
300 extern int vo_colorkey;
302 extern int64_t WinID;
304 typedef struct {
305 float min;
306 float max;
307 } range_t;
309 float range_max(range_t *r);
310 int in_range(range_t *r, float f);
311 range_t *str2range(char *s);
312 extern char *monitor_hfreq_str;
313 extern char *monitor_vfreq_str;
314 extern char *monitor_dotclock_str;
316 struct keymap {
317 int from;
318 int to;
320 int lookup_keymap_table(const struct keymap *map, int key);
321 struct vo_rect {
322 int left, right, top, bottom, width, height;
324 void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
325 struct vo_rect *src, struct vo_rect *dst,
326 struct vo_rect *borders, const struct vo_rect *crop);
328 #endif /* MPLAYER_VIDEO_OUT_H */