TOOLS/binary_codecs.sh: make indentation consistent
[mplayer/glamo.git] / libvo / video_out.h
blob380e3b7f956eb4f5aed9e59a44d811dc6c9bcfa4
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
38 #define VO_EVENT_REINIT 8
39 #define VO_EVENT_MOVE 16
41 /* Obsolete: VOCTRL_QUERY_VAA 1 */
42 /* does the device support the required format */
43 #define VOCTRL_QUERY_FORMAT 2
44 /* signal a device reset seek */
45 #define VOCTRL_RESET 3
46 /* used to switch to fullscreen */
47 #define VOCTRL_FULLSCREEN 5
48 /* signal a device pause */
49 #define VOCTRL_PAUSE 7
50 /* start/resume playback */
51 #define VOCTRL_RESUME 8
52 /* libmpcodecs direct rendering: */
53 #define VOCTRL_GET_IMAGE 9
54 #define VOCTRL_DRAW_IMAGE 13
55 #define VOCTRL_SET_SPU_PALETTE 14
56 /* decoding ahead: */
57 #define VOCTRL_GET_NUM_FRAMES 10
58 #define VOCTRL_GET_FRAME_NUM 11
59 #define VOCTRL_SET_FRAME_NUM 12
60 #define VOCTRL_GET_PANSCAN 15
61 #define VOCTRL_SET_PANSCAN 16
62 /* equalizer controls */
63 #define VOCTRL_SET_EQUALIZER 17
64 struct voctrl_set_equalizer_args {
65 const char *name;
66 int value;
68 #define VOCTRL_GET_EQUALIZER 18
69 struct voctrl_get_equalizer_args {
70 const char *name;
71 int *valueptr;
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 #define VOCTRL_SET_YUV_COLORSPACE 33
94 #define VOCTRL_GET_YUV_COLORSPACE 34
96 // Vo can be used by xover
97 #define VOCTRL_XOVERLAY_SUPPORT 22
99 #define VOCTRL_XOVERLAY_SET_COLORKEY 24
100 typedef struct {
101 uint32_t x11; // The raw x11 color
102 uint16_t r,g,b;
103 } mp_colorkey_t;
105 #define VOCTRL_XOVERLAY_SET_WIN 23
106 #define VOCTRL_REDRAW_OSD 24
108 typedef struct {
109 int x,y;
110 int w,h;
111 } mp_win_t;
113 #define VO_TRUE 1
114 #define VO_FALSE 0
115 #define VO_ERROR -1
116 #define VO_NOTAVAIL -2
117 #define VO_NOTIMPL -3
119 #define VOFLAG_FULLSCREEN 0x01
120 #define VOFLAG_MODESWITCHING 0x02
121 #define VOFLAG_SWSCALE 0x04
122 #define VOFLAG_FLIPPING 0x08
123 #define VOFLAG_HIDDEN 0x10 //< Use to create a hidden window
124 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
126 typedef struct vo_info_s
128 /* driver name ("Matrox Millennium G200/G400" */
129 const char *name;
130 /* short name (for config strings) ("mga") */
131 const char *short_name;
132 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
133 const char *author;
134 /* any additional comments */
135 const char *comment;
136 } vo_info_t;
138 struct vo;
139 struct osd_state;
140 struct mp_image;
142 struct vo_driver {
143 // Driver uses new API
144 bool is_new;
145 // Driver buffers or adds (deinterlace) frames and will keep track
146 // of pts values itself
147 bool buffer_frames;
149 // This is set if the driver is not new and contains pointers to
150 // old-API functions to be used instead of the ones below.
151 struct vo_old_functions *old_functions;
153 const vo_info_t *info;
155 * Preinitializes driver (real INITIALIZATION)
156 * arg - currently it's vo_subdevice
157 * returns: zero on successful initialization, non-zero on error.
159 int (*preinit)(struct vo *vo, const char *arg);
161 * Initialize (means CONFIGURE) the display driver.
162 * params:
163 * width,height: image source size
164 * d_width,d_height: size of the requested window size, just a hint
165 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
166 * title: window title, if available
167 * format: fourcc of pixel format
168 * returns : zero on successful initialization, non-zero on error.
170 int (*config)(struct vo *vo, uint32_t width, uint32_t height,
171 uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
172 char *title, uint32_t format);
175 * Control interface
177 int (*control)(struct vo *vo, uint32_t request, void *data);
179 void (*draw_image)(struct vo *vo, struct mp_image *mpi, double pts);
182 * Get extra frames from the VO, such as those added by VDPAU
183 * deinterlace. Preparing the next such frame if any could be done
184 * automatically by the VO after a previous flip_page(), but having
185 * it as a separate step seems to allow making code more robust.
187 void (*get_buffered_frame)(struct vo *vo, bool eof);
190 * Draw a planar YUV slice to the buffer:
191 * params:
192 * src[3] = source image planes (Y,U,V)
193 * stride[3] = source image planes line widths (in bytes)
194 * w,h = width*height of area to be copied (in Y pixels)
195 * x,y = position at the destination image (in Y pixels)
197 int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
198 int h, int x, int y);
201 * Draws OSD to the screen buffer
203 void (*draw_osd)(struct vo *vo, struct osd_state *osd);
206 * Blit/Flip buffer to the screen. Must be called after each frame!
208 void (*flip_page)(struct vo *vo);
209 void (*flip_page_timed)(struct vo *vo, unsigned int pts_us, int duration);
212 * This func is called after every frames to handle keyboard and
213 * other events. It's called in PAUSE mode too!
215 void (*check_events)(struct vo *vo);
218 * Closes driver. Should restore the original state of the system.
220 void (*uninit)(struct vo *vo);
223 struct vo_old_functions {
224 int (*preinit)(const char *arg);
225 int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
226 uint32_t d_height, uint32_t fullscreen, char *title,
227 uint32_t format);
228 int (*control)(uint32_t request, void *data);
229 int (*draw_frame)(uint8_t *src[]);
230 int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
231 void (*draw_osd)(void);
232 void (*flip_page)(void);
233 void (*check_events)(void);
234 void (*uninit)(void);
237 struct vo {
238 int config_ok; // Last config call was successful?
239 int config_count; // Total number of successful config calls
241 bool frame_loaded; // Is there a next frame the VO could flip to?
242 double next_pts; // pts value of the next frame if any
243 double next_pts2; // optional pts of frame after that
245 double flip_queue_offset; // queue flip events at most this much in advance
247 const struct vo_driver *driver;
248 void *priv;
249 struct MPOpts *opts;
250 struct vo_x11_state *x11;
251 struct mp_fifo *key_fifo;
252 struct input_ctx *input_ctx;
254 // requested position/resolution
255 int dx;
256 int dy;
257 int dwidth;
258 int dheight;
260 int panscan_x;
261 int panscan_y;
262 float panscan_amount;
263 float monitor_aspect;
264 struct aspect_data {
265 int orgw; // real width
266 int orgh; // real height
267 int prew; // prescaled width
268 int preh; // prescaled height
269 int scrw; // horizontal resolution
270 int scrh; // vertical resolution
271 float asp;
272 } aspdat;
275 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
276 struct mp_fifo *key_fifo,
277 struct input_ctx *input_ctx);
278 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
279 uint32_t d_width, uint32_t d_height, uint32_t flags,
280 char *title, uint32_t format);
281 void list_video_out(void);
283 int vo_control(struct vo *vo, uint32_t request, void *data);
284 int vo_draw_image(struct vo *vo, struct mp_image *mpi, double pts);
285 int vo_get_buffered_frame(struct vo *vo, bool eof);
286 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
287 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
288 void vo_draw_osd(struct vo *vo, struct osd_state *osd);
289 void vo_flip_page(struct vo *vo, unsigned int pts_us, int duration);
290 void vo_check_events(struct vo *vo);
291 void vo_seek_reset(struct vo *vo);
292 void vo_destroy(struct vo *vo);
295 // NULL terminated array of all drivers
296 extern const struct vo_driver *video_out_drivers[];
298 extern int xinerama_screen;
299 extern int xinerama_x;
300 extern int xinerama_y;
302 extern int vo_grabpointer;
303 extern int vo_doublebuffering;
304 extern int vo_directrendering;
305 extern int vo_vsync;
306 extern int vo_fs;
307 extern int vo_fsmode;
308 extern float vo_panscan;
309 extern int vo_adapter_num;
310 extern int vo_refresh_rate;
311 extern int vo_keepaspect;
312 extern int vo_rootwin;
313 extern int vo_border;
315 extern int vo_nomouse_input;
316 extern int enable_mouse_movements;
318 extern int vo_pts;
319 extern float vo_fps;
321 extern char *vo_subdevice;
323 extern int vo_colorkey;
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 mp_keymap {
340 int from;
341 int to;
343 int lookup_keymap_table(const struct mp_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);
350 struct input_ctx;
351 void vo_mouse_movement(struct vo *vo, int posx, int posy);
353 static inline int aspect_scaling(void)
355 return vo_keepaspect || vo_fs;
358 #endif /* MPLAYER_VIDEO_OUT_H */