Fix vf_tcdump's compilation
[mplayer/kovensky.git] / libvo / video_out.h
blob0b5f71255c57c37d17059e27ade763c57917cd34
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 <stdbool.h>
29 //#include "font_load.h"
30 #include "libmpcodecs/img_format.h"
31 //#include "vidix/vidix.h"
33 #define MP_NOPTS_VALUE (-1LL<<63)
35 #define VO_EVENT_EXPOSE 1
36 #define VO_EVENT_RESIZE 2
37 #define VO_EVENT_KEYPRESS 4
39 /* Obsolete: VOCTRL_QUERY_VAA 1 */
40 /* does the device support the required format */
41 #define VOCTRL_QUERY_FORMAT 2
42 /* signal a device reset seek */
43 #define VOCTRL_RESET 3
44 /* used to switch to fullscreen */
45 #define VOCTRL_FULLSCREEN 5
46 /* signal a device pause */
47 #define VOCTRL_PAUSE 7
48 /* start/resume playback */
49 #define VOCTRL_RESUME 8
50 /* libmpcodecs direct rendering: */
51 #define VOCTRL_GET_IMAGE 9
52 #define VOCTRL_DRAW_IMAGE 13
53 #define VOCTRL_SET_SPU_PALETTE 14
54 /* decoding ahead: */
55 #define VOCTRL_GET_NUM_FRAMES 10
56 #define VOCTRL_GET_FRAME_NUM 11
57 #define VOCTRL_SET_FRAME_NUM 12
58 #define VOCTRL_GET_PANSCAN 15
59 #define VOCTRL_SET_PANSCAN 16
60 /* equalizer controls */
61 #define VOCTRL_SET_EQUALIZER 17
62 struct voctrl_set_equalizer_args {
63 const char *name;
64 int value;
66 #define VOCTRL_GET_EQUALIZER 18
67 struct voctrl_get_equalizer_args {
68 const char *name;
69 int *valueptr;
71 /* Frame duplication */
72 #define VOCTRL_DUPLICATE_FRAME 20
73 // ... 21
74 #define VOCTRL_START_SLICE 21
76 #define VOCTRL_ONTOP 25
77 #define VOCTRL_ROOTWIN 26
78 #define VOCTRL_BORDER 27
79 #define VOCTRL_DRAW_EOSD 28
80 #define VOCTRL_GET_EOSD_RES 29
81 typedef struct {
82 int w, h; // screen dimensions, including black borders
83 int mt, mb, ml, mr; // borders (top, bottom, left, right)
84 } mp_eosd_res_t;
86 #define VOCTRL_SET_DEINTERLACE 30
87 #define VOCTRL_GET_DEINTERLACE 31
89 #define VOCTRL_UPDATE_SCREENINFO 32
91 #define VOCTRL_SET_YUV_COLORSPACE 33
92 #define VOCTRL_GET_YUV_COLORSPACE 34
94 // Vo can be used by xover
95 #define VOCTRL_XOVERLAY_SUPPORT 22
97 #define VOCTRL_XOVERLAY_SET_COLORKEY 24
98 typedef struct {
99 uint32_t x11; // The raw x11 color
100 uint16_t r,g,b;
101 } mp_colorkey_t;
103 #define VOCTRL_XOVERLAY_SET_WIN 23
104 #define VOCTRL_REDRAW_OSD 24
106 typedef struct {
107 int x,y;
108 int w,h;
109 } mp_win_t;
111 #define VO_TRUE 1
112 #define VO_FALSE 0
113 #define VO_ERROR -1
114 #define VO_NOTAVAIL -2
115 #define VO_NOTIMPL -3
117 #define VOFLAG_FULLSCREEN 0x01
118 #define VOFLAG_MODESWITCHING 0x02
119 #define VOFLAG_SWSCALE 0x04
120 #define VOFLAG_FLIPPING 0x08
121 #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window
122 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
124 typedef struct vo_info_s
126 /* driver name ("Matrox Millennium G200/G400" */
127 const char *name;
128 /* short name (for config strings) ("mga") */
129 const char *short_name;
130 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
131 const char *author;
132 /* any additional comments */
133 const char *comment;
134 } vo_info_t;
136 struct vo;
137 struct osd_state;
138 struct mp_image;
140 struct vo_driver {
141 // Driver uses new API
142 bool is_new;
143 // Driver buffers or adds (deinterlace) frames and will keep track
144 // of pts values itself
145 bool buffer_frames;
147 // This is set if the driver is not new and contains pointers to
148 // old-API functions to be used instead of the ones below.
149 struct vo_old_functions *old_functions;
151 const vo_info_t *info;
153 * Preinitializes driver (real INITIALIZATION)
154 * arg - currently it's vo_subdevice
155 * returns: zero on successful initialization, non-zero on error.
157 int (*preinit)(struct vo *vo, const char *arg);
159 * Initialize (means CONFIGURE) the display driver.
160 * params:
161 * width,height: image source size
162 * d_width,d_height: size of the requested window size, just a hint
163 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
164 * title: window title, if available
165 * format: fourcc of pixel format
166 * returns : zero on successful initialization, non-zero on error.
168 int (*config)(struct vo *vo, uint32_t width, uint32_t height,
169 uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
170 char *title, uint32_t format);
173 * Control interface
175 int (*control)(struct vo *vo, uint32_t request, void *data);
177 void (*draw_image)(struct vo *vo, struct mp_image *mpi, double pts);
180 * Get extra frames from the VO, such as those added by VDPAU
181 * deinterlace. Preparing the next such frame if any could be done
182 * automatically by the VO after a previous flip_page(), but having
183 * it as a separate step seems to allow making code more robust.
185 void (*get_buffered_frame)(struct vo *vo, bool eof);
188 * Draw a planar YUV slice to the buffer:
189 * params:
190 * src[3] = source image planes (Y,U,V)
191 * stride[3] = source image planes line widths (in bytes)
192 * w,h = width*height of area to be copied (in Y pixels)
193 * x,y = position at the destination image (in Y pixels)
195 int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
196 int h, int x, int y);
199 * Draws OSD to the screen buffer
201 void (*draw_osd)(struct vo *vo, struct osd_state *osd);
204 * Blit/Flip buffer to the screen. Must be called after each frame!
206 void (*flip_page)(struct vo *vo);
207 void (*flip_page_timed)(struct vo *vo, unsigned int pts_us, int duration);
210 * This func is called after every frames to handle keyboard and
211 * other events. It's called in PAUSE mode too!
213 void (*check_events)(struct vo *vo);
216 * Closes driver. Should restore the original state of the system.
218 void (*uninit)(struct vo *vo);
221 struct vo_old_functions {
222 int (*preinit)(const char *arg);
223 int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
224 uint32_t d_height, uint32_t fullscreen, char *title,
225 uint32_t format);
226 int (*control)(uint32_t request, void *data);
227 int (*draw_frame)(uint8_t *src[]);
228 int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
229 void (*draw_osd)(void);
230 void (*flip_page)(void);
231 void (*check_events)(void);
232 void (*uninit)(void);
235 struct vo {
236 int config_ok; // Last config call was successful?
237 int config_count; // Total number of successful config calls
239 bool frame_loaded; // Is there a next frame the VO could flip to?
240 double next_pts; // pts value of the next frame if any
241 double next_pts2; // optional pts of frame after that
243 double flip_queue_offset; // queue flip events at most this much in advance
245 const struct vo_driver *driver;
246 void *priv;
247 struct MPOpts *opts;
248 struct vo_x11_state *x11;
249 struct mp_fifo *key_fifo;
250 struct input_ctx *input_ctx;
252 // requested position/resolution
253 int dx;
254 int dy;
255 int dwidth;
256 int dheight;
258 int panscan_x;
259 int panscan_y;
260 float panscan_amount;
261 float monitor_aspect;
262 struct aspect_data {
263 int orgw; // real width
264 int orgh; // real height
265 int prew; // prescaled width
266 int preh; // prescaled height
267 int scrw; // horizontal resolution
268 int scrh; // vertical resolution
269 float asp;
270 } aspdat;
273 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
274 struct mp_fifo *key_fifo,
275 struct input_ctx *input_ctx);
276 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
277 uint32_t d_width, uint32_t d_height, uint32_t flags,
278 char *title, uint32_t format);
279 void list_video_out(void);
281 int vo_control(struct vo *vo, uint32_t request, void *data);
282 int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts);
283 int vo_get_buffered_frame(struct vo *vo, bool eof);
284 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
285 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
286 void vo_draw_osd(struct vo *vo, struct osd_state *osd);
287 void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration);
288 void vo_check_events(struct vo *vo);
289 void vo_seek_reset(struct vo *vo);
290 void vo_destroy(struct vo *vo);
293 // NULL terminated array of all drivers
294 extern const struct vo_driver *video_out_drivers[];
296 extern int xinerama_screen;
297 extern int xinerama_x;
298 extern int xinerama_y;
300 extern int vo_grabpointer;
301 extern int vo_doublebuffering;
302 extern int vo_directrendering;
303 extern int vo_vsync;
304 extern int vo_fs;
305 extern int vo_fsmode;
306 extern float vo_panscan;
307 extern int vo_adapter_num;
308 extern int vo_refresh_rate;
309 extern int vo_keepaspect;
310 extern int vo_rootwin;
311 extern int vo_border;
313 extern int vo_nomouse_input;
315 extern int vo_pts;
316 extern float vo_fps;
318 extern char *vo_subdevice;
320 extern int vo_colorkey;
322 extern char *vo_winname;
323 extern char *vo_wintitle;
325 extern int64_t WinID;
327 typedef struct {
328 float min;
329 float max;
330 } range_t;
332 float range_max(range_t *r);
333 int in_range(range_t *r, float f);
334 range_t *str2range(char *s);
335 extern char *monitor_hfreq_str;
336 extern char *monitor_vfreq_str;
337 extern char *monitor_dotclock_str;
339 struct keymap {
340 int from;
341 int to;
343 int lookup_keymap_table(const struct keymap *map, int key);
344 struct vo_rect {
345 int left, right, top, bottom, width, height;
347 void calc_src_dst_rects(struct vo *vo, int src_width, int src_height,
348 struct vo_rect *src, struct vo_rect *dst,
349 struct vo_rect *borders, const struct vo_rect *crop);
351 static inline int aspect_scaling(void)
353 return vo_keepaspect || vo_fs;
356 #endif /* MPLAYER_VIDEO_OUT_H */