2 * VIDIX-accelerated overlay on (black) background
4 * should work on any OS
6 * copyright (C) 2003 Sascha Sommer
8 * This file is part of MPlayer.
10 * MPlayer is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * MPlayer is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
32 #include "video_out.h"
33 #include "video_out_internal.h"
39 #include "vosub_vidix.h"
40 #include "vidix/vidix.h"
43 static const vo_info_t info
= {
52 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
55 static char *vidix_name
;
56 static uint32_t swidth
,sheight
,sformat
;
57 /// center video only when screenw & height are set
58 static uint32_t center
=0;
59 static vidix_grkey_t gr_key
;
62 static uint32_t setup_vidix(void){
64 aspect(&vo_dwidth
,&vo_dheight
,vo_fs
? A_ZOOM
: A_NOZOOM
);
66 if(vo_dwidth
<= vo_screenwidth
)x
= (vo_screenwidth
- vo_dwidth
)/2;
68 if(vo_dheight
<= vo_screenheight
)y
= (vo_screenheight
- vo_dheight
)/2;
71 if(vo_config_count
)vidix_stop();
72 if(vidix_init(swidth
, sheight
, x
, y
, vo_dwidth
, vo_dheight
, sformat
, 32, vo_screenwidth
,vo_screenheight
)){
73 mp_msg(MSGT_VO
, MSGL_FATAL
, "Can't setup VIDIX driver: %s\n", strerror(errno
));
77 if(vidix_grkey_support()){
78 vidix_grkey_get(&gr_key
);
79 gr_key
.key_op
= KEYS_PUT
;
80 if (!vo_fs
&& !(vo_colorkey
& 0xff000000)){
81 gr_key
.ckey
.op
= CKEY_TRUE
;
82 gr_key
.ckey
.red
= (vo_colorkey
& 0x00FF0000) >> 16;
83 gr_key
.ckey
.green
= (vo_colorkey
& 0x0000FF00) >> 8;
84 gr_key
.ckey
.blue
= vo_colorkey
& 0x000000FF;
86 else gr_key
.ckey
.op
= CKEY_FALSE
;
87 vidix_grkey_set(&gr_key
);
92 static int config(uint32_t width
, uint32_t height
, uint32_t d_width
,uint32_t d_height
, uint32_t flags
, char *title
, uint32_t format
){
93 vo_fs
= flags
& VOFLAG_FULLSCREEN
;
95 if(vo_screenwidth
&& vo_screenheight
){
96 if(!vo_geometry
)center
=1;
100 mp_msg(MSGT_VO
, MSGL_WARN
, "vo_cvidix: Screen width not set (see -screenw), assuming 640 pixels.\n");
101 vo_screenwidth
= 640;
103 if(!vo_screenheight
){
104 mp_msg(MSGT_VO
, MSGL_WARN
, "vo_cvidix: Screen height not set (see -screenh), assuming 480 pixels.\n");
105 vo_screenheight
= 480;
112 aspect_save_orig(width
,height
);
113 aspect_save_prescale(d_width
,d_height
);
114 aspect_save_screenres(vo_screenwidth
,vo_screenheight
);
119 else geometry(&vo_dx
, &vo_dy
, &vo_dwidth
, &vo_dheight
,vo_screenwidth
,vo_screenheight
);
120 return setup_vidix();
123 static void check_events(void){
126 /* draw_osd, flip_page, draw_slice, draw_frame should be
127 overwritten with vidix functions (vosub_vidix.c) */
128 static void draw_osd(void){
129 mp_msg(MSGT_VO
, MSGL_FATAL
, "vo_cvidix: error: didn't use vidix draw_osd!\n");
133 static void flip_page(void){
134 mp_msg(MSGT_VO
, MSGL_FATAL
, "vo_cvidix: error: didn't use vidix flip_page!\n");
138 static int draw_slice(uint8_t *src
[], int stride
[],int w
, int h
, int x
, int y
){
145 mp_msg(MSGT_VO
, MSGL_FATAL
, "vo_cvidix: error: didn't use vidix draw_slice!\n");
149 static int draw_frame(uint8_t *src
[]){
151 mp_msg(MSGT_VO
, MSGL_FATAL
, "vo_cvidix: error: didn't use vidix draw_frame!\n");
155 static int query_format(uint32_t format
){
156 return vidix_query_fourcc(format
);
159 static void uninit(void){
160 if(!vo_config_count
) return;
168 static int preinit(const char *arg
){
169 if(arg
)vidix_name
= strdup(arg
);
171 mp_msg(MSGT_VO
, MSGL_INFO
, "vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!\n");
174 if (vidix_preinit(vidix_name
, video_out_cvidix
.old_functions
))return 1;
178 static int control(uint32_t request
, void *data
){
180 case VOCTRL_QUERY_FORMAT
:
181 return query_format(*((uint32_t*)data
));
182 case VOCTRL_FULLSCREEN
:
188 return vidix_control(request
, data
);