libvo: Move aspect.c static variables to vo struct
[mplayer.git] / libvo / video_out.h
blob174911c9d20bc1bec70179f4d43f458d90d1b336
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 typedef struct {
91 int x,y;
92 int w,h;
93 } mp_win_t;
95 #define VO_TRUE 1
96 #define VO_FALSE 0
97 #define VO_ERROR -1
98 #define VO_NOTAVAIL -2
99 #define VO_NOTIMPL -3
101 #define VOFLAG_FULLSCREEN 0x01
102 #define VOFLAG_MODESWITCHING 0x02
103 #define VOFLAG_SWSCALE 0x04
104 #define VOFLAG_FLIPPING 0x08
105 #define VOFLAG_XOVERLAY_SUB_VO 0x10000
107 typedef struct vo_info_s
109 /* driver name ("Matrox Millennium G200/G400" */
110 const char *name;
111 /* short name (for config strings) ("mga") */
112 const char *short_name;
113 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
114 const char *author;
115 /* any additional comments */
116 const char *comment;
117 } vo_info_t;
119 struct vo;
121 struct vo_driver {
122 // Driver uses new API
123 int is_new;
125 // This is set if the driver is not new and contains pointers to
126 // old-API functions to be used instead of the ones below.
127 struct vo_old_functions *old_functions;
129 const vo_info_t *info;
131 * Preinitializes driver (real INITIALIZATION)
132 * arg - currently it's vo_subdevice
133 * returns: zero on successful initialization, non-zero on error.
135 int (*preinit)(struct vo *vo, const char *arg);
137 * Initialize (means CONFIGURE) the display driver.
138 * params:
139 * width,height: image source size
140 * d_width,d_height: size of the requested window size, just a hint
141 * fullscreen: flag, 0=windowd 1=fullscreen, just a hint
142 * title: window title, if available
143 * format: fourcc of pixel format
144 * returns : zero on successful initialization, non-zero on error.
146 int (*config)(struct vo *vo, uint32_t width, uint32_t height,
147 uint32_t d_width, uint32_t d_height, uint32_t fullscreen,
148 char *title, uint32_t format);
151 * Control interface
153 int (*control)(struct vo *vo, uint32_t request, void *data);
156 * Display a new RGB/BGR frame of the video to the screen.
157 * params:
158 * src[0] - pointer to the image
160 int (*draw_frame)(struct vo *vo, uint8_t *src[]);
163 * Draw a planar YUV slice to the buffer:
164 * params:
165 * src[3] = source image planes (Y,U,V)
166 * stride[3] = source image planes line widths (in bytes)
167 * w,h = width*height of area to be copied (in Y pixels)
168 * x,y = position at the destination image (in Y pixels)
170 int (*draw_slice)(struct vo *vo, uint8_t *src[], int stride[], int w,
171 int h, int x, int y);
174 * Draws OSD to the screen buffer
176 void (*draw_osd)(struct vo *vo);
179 * Blit/Flip buffer to the screen. Must be called after each frame!
181 void (*flip_page)(struct vo *vo);
184 * This func is called after every frames to handle keyboard and
185 * other events. It's called in PAUSE mode too!
187 void (*check_events)(struct vo *vo);
190 * Closes driver. Should restore the original state of the system.
192 void (*uninit)(struct vo *vo);
195 struct vo_old_functions {
196 int (*preinit)(const char *arg);
197 int (*config)(uint32_t width, uint32_t height, uint32_t d_width,
198 uint32_t d_height, uint32_t fullscreen, char *title,
199 uint32_t format);
200 int (*control)(uint32_t request, void *data);
201 int (*draw_frame)(uint8_t *src[]);
202 int (*draw_slice)(uint8_t *src[], int stride[], int w,int h, int x,int y);
203 void (*draw_osd)(void);
204 void (*flip_page)(void);
205 void (*check_events)(void);
206 void (*uninit)(void);
209 struct vo {
210 int config_ok; // Last config call was successful?
211 int config_count; // Total number of successful config calls
212 const struct vo_driver *driver;
213 void *priv;
214 struct MPOpts *opts;
215 struct vo_x11_state *x11;
216 struct mp_fifo *key_fifo;
217 struct input_ctx *input_ctx;
219 // requested position/resolution
220 int dx;
221 int dy;
222 int dwidth;
223 int dheight;
225 int panscan_x;
226 int panscan_y;
227 float panscan_amount;
228 float monitor_aspect;
229 struct aspect_data {
230 int orgw; // real width
231 int orgh; // real height
232 int prew; // prescaled width
233 int preh; // prescaled height
234 int scrw; // horizontal resolution
235 int scrh; // vertical resolution
236 float asp;
237 } aspdat;
240 struct vo *init_best_video_out(struct MPOpts *opts, struct vo_x11_state *x11,
241 struct mp_fifo *key_fifo,
242 struct input_ctx *input_ctx);
243 int vo_config(struct vo *vo, uint32_t width, uint32_t height,
244 uint32_t d_width, uint32_t d_height, uint32_t flags,
245 char *title, uint32_t format);
246 void list_video_out(void);
248 int vo_control(struct vo *vo, uint32_t request, void *data);
249 int vo_draw_frame(struct vo *vo, uint8_t *src[]);
250 int vo_draw_slice(struct vo *vo, uint8_t *src[], int stride[], int w, int h, int x, int y);
251 void vo_draw_osd(struct vo *vo);
252 void vo_flip_page(struct vo *vo);
253 void vo_check_events(struct vo *vo);
254 void vo_destroy(struct vo *vo);
257 // NULL terminated array of all drivers
258 extern const struct vo_driver *video_out_drivers[];
260 extern int xinerama_screen;
261 extern int xinerama_x;
262 extern int xinerama_y;
264 extern int vo_grabpointer;
265 extern int vo_doublebuffering;
266 extern int vo_directrendering;
267 extern int vo_vsync;
268 extern int vo_fs;
269 extern int vo_fsmode;
270 extern float vo_panscan;
271 extern int vo_adapter_num;
272 extern int vo_refresh_rate;
273 extern int vo_keepaspect;
274 extern int vo_rootwin;
275 extern int vo_border;
277 extern int vo_nomouse_input;
279 extern int vo_pts;
280 extern float vo_fps;
282 extern char *vo_subdevice;
284 extern int vo_colorkey;
286 extern int WinID;
288 #if defined(HAVE_FBDEV) || defined(HAVE_VESA)
290 typedef struct {
291 float min;
292 float max;
293 } range_t;
295 extern float range_max(range_t *r);
296 extern int in_range(range_t *r, float f);
297 extern range_t *str2range(char *s);
298 extern char *monitor_hfreq_str;
299 extern char *monitor_vfreq_str;
300 extern char *monitor_dotclock_str;
302 #endif /* defined(HAVE_FBDEV) || defined(HAVE_VESA) */
304 #endif /* MPLAYER_VIDEO_OUT_H */