annotate libvo/vo_cvidix.c @ 16256:578e8b4c3e7f

use libvbe from vesautils
author alex
date Thu, 18 Aug 2005 11:26:04 +0000
parents fd51fd1ff231
children 9bce6b40def2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
1 /*
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
2 VIDIX accelerated overlay on (black) background
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
3
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
4 should work on any OS
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
5
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
6 (C) Sascha Sommer
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
7
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
8
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
9 */
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
10
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
11 #include <stdio.h>
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
12 #include <stdlib.h>
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
13 #include <string.h>
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
14 #include <math.h>
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
15 #include <errno.h>
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
16
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
17 #include "config.h"
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
18 #include "video_out.h"
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
19 #include "video_out_internal.h"
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
20 #include "aspect.h"
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
21 #include "geometry.h"
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
22
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
23 #include "mp_msg.h"
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
24
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
25 #include "vosub_vidix.h"
13787
e047e70a9767 Handle "xxx.h" vs "../xxx.h" include paths in a consistent way.
diego
parents: 13360
diff changeset
26 #include "vidix/vidixlib.h"
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
27
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
28
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
29 static vo_info_t info = {
12783
d4739143fe2e output wording
diego
parents: 12769
diff changeset
30 "console VIDIX",
11017
afdf982f0673 consolevidix -> cvidix
faust3
parents: 10979
diff changeset
31 "cvidix",
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
32 "Sascha Sommer",
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
33 ""
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
34 };
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
35
11017
afdf982f0673 consolevidix -> cvidix
faust3
parents: 10979
diff changeset
36 LIBVO_EXTERN(cvidix)
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
37
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
38 #define UNUSED(x) ((void)(x)) /* Removes warning about unused arguments */
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
39
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
40 /* VIDIX related */
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
41 static char *vidix_name;
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
42 static uint32_t swidth,sheight,sformat;
13360
1f09ac7b543a center the image when screenw & height are set
faust3
parents: 13355
diff changeset
43 /// center video only when screenw & height are set
1f09ac7b543a center the image when screenw & height are set
faust3
parents: 13355
diff changeset
44 static uint32_t center=0;
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
45 static vidix_grkey_t gr_key;
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
46
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
47
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
48 static uint32_t setup_vidix(){
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
49 int x=vo_dx,y=vo_dy;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
50 aspect(&vo_dwidth,&vo_dheight,vo_fs ? A_ZOOM : A_NOZOOM);
13360
1f09ac7b543a center the image when screenw & height are set
faust3
parents: 13355
diff changeset
51 if(vo_fs || center){
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
52 if(vo_dwidth <= vo_screenwidth)x = (vo_screenwidth - vo_dwidth)/2;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
53 else x=0;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
54 if(vo_dheight <= vo_screenheight)y = (vo_screenheight - vo_dheight)/2;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
55 else y=0;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
56 }
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
57 if(vo_config_count)vidix_stop();
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
58 if(vidix_init(swidth, sheight, x, y, vo_dwidth, vo_dheight, sformat, 32, vo_screenwidth,vo_screenheight)){
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
59 mp_msg(MSGT_VO, MSGL_FATAL, "Can't setup VIDIX driver: %s\n", strerror(errno));
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
60 return 1;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
61 }
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
62 vidix_start();
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
63 if(vidix_grkey_support()){
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
64 vidix_grkey_get(&gr_key);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
65 gr_key.key_op = KEYS_PUT;
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
66 if (!vo_fs && !(vo_colorkey & 0xff000000)){
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
67 gr_key.ckey.op = CKEY_TRUE;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
68 gr_key.ckey.red = (vo_colorkey & 0x00FF0000) >> 16;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
69 gr_key.ckey.green = (vo_colorkey & 0x0000FF00) >> 8;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
70 gr_key.ckey.blue = vo_colorkey & 0x000000FF;
11158
85f4534d1edb Colorkeying can be disabled. Fbdev, svga and vesa vidix colorkeying support
alex
parents: 11019
diff changeset
71 }
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
72 else gr_key.ckey.op = CKEY_FALSE;
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
73 vidix_grkey_set(&gr_key);
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
74 }
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
75 return 0;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
76 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
77
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
78 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){
15212
05aa13cdf92f replace VO and VF numeric flags with #defined identifiers
henry
parents: 14041
diff changeset
79 vo_fs = flags & VOFLAG_FULLSCREEN;
13360
1f09ac7b543a center the image when screenw & height are set
faust3
parents: 13355
diff changeset
80 if(!vo_config_count){
14041
928b03a98062 10l initial patch by Oded Shimon <ods15 at ods15.dyndns.org>
faust3
parents: 13787
diff changeset
81 if(vo_screenwidth && vo_screenheight){
928b03a98062 10l initial patch by Oded Shimon <ods15 at ods15.dyndns.org>
faust3
parents: 13787
diff changeset
82 if(!vo_geometry)center=1;
928b03a98062 10l initial patch by Oded Shimon <ods15 at ods15.dyndns.org>
faust3
parents: 13787
diff changeset
83 }
13360
1f09ac7b543a center the image when screenw & height are set
faust3
parents: 13355
diff changeset
84 else mp_msg(MSGT_VO, MSGL_WARN, "vo_cvidix: warn: screenwidth and height not set assuming 640x480\n");
1f09ac7b543a center the image when screenw & height are set
faust3
parents: 13355
diff changeset
85 }
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
86 if(!vo_screenwidth)vo_screenwidth=640;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
87 if(!vo_screenheight)vo_screenheight=480;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
88 swidth = width;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
89 sheight = height;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
90 sformat = format;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
91 vo_dwidth=d_width;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
92 vo_dheight=d_height;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
93 aspect_save_orig(width,height);
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
94 aspect_save_prescale(d_width,d_height);
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
95 aspect_save_screenres(vo_screenwidth,vo_screenheight);
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
96 if(!vo_geometry){
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
97 vo_dx=0;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
98 vo_dy=0;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
99 }
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
100 else geometry(&vo_dx, &vo_dy, &vo_dwidth, &vo_dheight,vo_screenwidth,vo_screenheight);
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
101 return setup_vidix();
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
102 }
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
103
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
104 static void check_events(void){
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
105 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
106
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
107 /* draw_osd, flip_page, draw_slice, draw_frame should be
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
108 overwritten with vidix functions (vosub_vidix.c) */
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
109 static void draw_osd(void){
11019
69daa4fb97d9 consolevidix -> cvidix
faust3
parents: 11017
diff changeset
110 mp_msg(MSGT_VO, MSGL_FATAL, "vo_cvidix: error: didn't use vidix draw_osd!\n");
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
111 return;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
112 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
113
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
114 static void flip_page(void){
11019
69daa4fb97d9 consolevidix -> cvidix
faust3
parents: 11017
diff changeset
115 mp_msg(MSGT_VO, MSGL_FATAL, "vo_cvidix: error: didn't use vidix flip_page!\n");
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
116 return;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
117 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
118
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
119 static int draw_slice(uint8_t *src[], int stride[],int w, int h, int x, int y){
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
120 UNUSED(src);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
121 UNUSED(stride);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
122 UNUSED(w);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
123 UNUSED(h);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
124 UNUSED(x);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
125 UNUSED(y);
11019
69daa4fb97d9 consolevidix -> cvidix
faust3
parents: 11017
diff changeset
126 mp_msg(MSGT_VO, MSGL_FATAL, "vo_cvidix: error: didn't use vidix draw_slice!\n");
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
127 return -1;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
128 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
129
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
130 static int draw_frame(uint8_t *src[]){
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
131 UNUSED(src);
11019
69daa4fb97d9 consolevidix -> cvidix
faust3
parents: 11017
diff changeset
132 mp_msg(MSGT_VO, MSGL_FATAL, "vo_cvidix: error: didn't use vidix draw_frame!\n");
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
133 return -1;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
134 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
135
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
136 static int query_format(uint32_t format){
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
137 return(vidix_query_fourcc(format));
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
138 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
139
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
140 static void uninit(void){
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
141 if(!vo_config_count) return;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
142 vidix_term();
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
143 if(vidix_name){
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
144 free(vidix_name);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
145 vidix_name = NULL;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
146 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
147 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
148
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
149 static int preinit(const char *arg){
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
150 if(arg)vidix_name = strdup(arg);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
151 else {
11462
2e367138d4b5 message expanded with hint to use -v option
gabucino
parents: 11232
diff changeset
152 mp_msg(MSGT_VO, MSGL_INFO, "vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!\n");
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
153 vidix_name = NULL;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
154 }
11019
69daa4fb97d9 consolevidix -> cvidix
faust3
parents: 11017
diff changeset
155 if(vidix_preinit(vidix_name, &video_out_cvidix))return 1;
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
156 return 0;
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
157 }
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
158
16171
fd51fd1ff231 Fix the return types of all (six) libvo API functions. Used to be uint32_t, but
ivo
parents: 15212
diff changeset
159 static int control(uint32_t request, void *data, ...){
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
160 switch (request) {
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
161 case VOCTRL_QUERY_FORMAT:
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
162 return query_format(*((uint32_t*)data));
11232
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
163 case VOCTRL_FULLSCREEN:
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
164 if(vo_fs)vo_fs=0;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
165 else vo_fs=1;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
166 setup_vidix();
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
167 return VO_TRUE;
147a4c50214d added aspect && geometry support
faust3
parents: 11216
diff changeset
168 }
10979
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
169 return vidix_control(request, data);
ea4426db0db5 new vidix vo modules for textmode console and windows
faust3
parents:
diff changeset
170 }