Mercurial > mplayer.hg
comparison libvo/vo_ggi.c @ 1132:80a0f8aa2360
Added for development only this is in pre-alpha state, do not use!
author | atmosfear |
---|---|
date | Fri, 15 Jun 2001 16:31:19 +0000 |
parents | |
children | c33f8b7488d1 |
comparison
equal
deleted
inserted
replaced
1131:30e6a115a088 | 1132:80a0f8aa2360 |
---|---|
1 /* | |
2 vo_ggi.c - General Graphics Interface (GGI) Renderer for MPlayer | |
3 | |
4 (C) Alex Beregszaszi <alex@naxine.org> | |
5 | |
6 Uses libGGI - http://www.ggi-project.org/ | |
7 */ | |
8 | |
9 #define DISP | |
10 | |
11 #include <stdio.h> | |
12 #include <stdlib.h> | |
13 #include <string.h> | |
14 #include <errno.h> | |
15 | |
16 #include "config.h" | |
17 #include "video_out.h" | |
18 #include "video_out_internal.h" | |
19 | |
20 #include "yuv2rgb.h" | |
21 | |
22 #include <ggi/ggi.h> | |
23 #include "fastmemcpy.h" | |
24 | |
25 LIBVO_EXTERN (ggi) | |
26 | |
27 static vo_info_t vo_info = | |
28 { | |
29 "General Graphics Interface (GGI) output", | |
30 "ggi", | |
31 "Alex Beregszaszi <alex@naxine.org>", | |
32 "" | |
33 }; | |
34 | |
35 extern int verbose; | |
36 | |
37 static char *ggi_output_name = NULL; | |
38 static ggi_visual_t ggi_vis; | |
39 static ggi_directbuffer *ggi_buffer; | |
40 static int bpp = 0; | |
41 static uint32_t virt_width; | |
42 static uint32_t virt_height; | |
43 static ggi_pixel white; | |
44 static ggi_pixel black; | |
45 | |
46 static int ggi_setmode(uint32_t d_width, uint32_t d_height, int d_depth, int format) | |
47 { | |
48 ggi_mode mode = | |
49 { | |
50 1, /* frames */ | |
51 { GGI_AUTO, GGI_AUTO }, /* visible */ | |
52 { GGI_AUTO, GGI_AUTO }, /* virt */ | |
53 { GGI_AUTO, GGI_AUTO }, /* size */ | |
54 GT_AUTO, /* graphtype */ | |
55 { GGI_AUTO, GGI_AUTO } /* dots per pixel */ | |
56 }; | |
57 ggi_color pal[256]; | |
58 int depth; | |
59 | |
60 mode.visible.x = mode.virt.x = d_width; | |
61 mode.visible.y = mode.virt.y = d_height; | |
62 | |
63 switch(d_depth) | |
64 { | |
65 case 1: | |
66 mode.graphtype = GT_1BIT; | |
67 depth = 1; | |
68 break; | |
69 case 2: | |
70 mode.graphtype = GT_2BIT; | |
71 depth = 2; | |
72 break; | |
73 case 4: | |
74 mode.graphtype = GT_4BIT; | |
75 depth = 4; | |
76 break; | |
77 case 8: | |
78 mode.graphtype = GT_8BIT; | |
79 depth = 8; | |
80 break; | |
81 case 15: | |
82 mode.graphtype = GT_15BIT; | |
83 depth = 15; | |
84 break; | |
85 case 16: | |
86 mode.graphtype = GT_16BIT; | |
87 depth = 16; | |
88 break; | |
89 case 24: | |
90 mode.graphtype = GT_24BIT; | |
91 depth = 24; | |
92 break; | |
93 case 32: | |
94 mode.graphtype = GT_32BIT; | |
95 depth = 32; | |
96 break; | |
97 default: | |
98 printf("ggi-setmode: unknown bit depth - using auto\n"); | |
99 mode.graphtype = GT_AUTO; | |
100 } | |
101 | |
102 ggiCheckMode(ggi_vis, &mode); | |
103 | |
104 if (ggiSetMode(ggi_vis, &mode) != 0) | |
105 { | |
106 printf("ggi-setmode: unable to set mode\n"); | |
107 ggiClose(ggi_vis); | |
108 ggiExit(); | |
109 return(-1); | |
110 } | |
111 | |
112 virt_width = mode.virt.x; | |
113 virt_height = mode.virt.y; | |
114 vo_screenwidth = mode.visible.x; | |
115 vo_screenheight = mode.visible.y; | |
116 vo_depthonscreen = depth; | |
117 bpp = depth; /* byte per pixel = depth ? */ | |
118 | |
119 | |
120 #ifdef get_db_info | |
121 { | |
122 const ggi_directbuffer *db = ggiDBGetBuffer(ggi_vis, 0); | |
123 | |
124 if (db) | |
125 { | |
126 vo_depthonscreen = db->buffer.plb.pixelformat->depth; | |
127 bpp = db->buffer.plb.pixelformat->size / 8; | |
128 } | |
129 } | |
130 #endif | |
131 | |
132 if (GT_SCHEME(mode.graphtype) == GT_PALETTE) | |
133 { | |
134 ggiSetColorfulPalette(ggi_vis); | |
135 ggiGetPalette(ggi_vis, 0, 1 << bpp, pal); | |
136 } | |
137 | |
138 if (verbose) | |
139 printf("ggi-setmode: %dx%d (virt: %dx%d) %d depth, %d bpp\n", vo_screenwidth, | |
140 vo_screenheight, virt_width, virt_height, vo_depthonscreen, bpp); | |
141 | |
142 return(0); | |
143 } | |
144 | |
145 | |
146 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, | |
147 uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) | |
148 { | |
149 printf("\nggi: THIS DRIVER IS IN PRE-ALPHA PHASE, DO NOT USE!\n\n"); | |
150 if (ggiInit() != 0) | |
151 { | |
152 printf("ggi-init: unable to initialize GGI\n"); | |
153 return(-1); | |
154 } | |
155 | |
156 if ((ggi_vis = ggiOpen(ggi_output_name)) == NULL) | |
157 { | |
158 printf("ggi-init: unable to open GGI for %s output\n", | |
159 (ggi_output_name == NULL) ? "default" : ggi_output_name); | |
160 ggiExit(); | |
161 return(-1); | |
162 } | |
163 | |
164 switch(format) | |
165 { | |
166 case IMGFMT_RGB8: | |
167 bpp = 8; | |
168 break; | |
169 case IMGFMT_RGB15: | |
170 bpp = 15; | |
171 break; | |
172 case IMGFMT_RGB16: | |
173 bpp = 16; | |
174 break; | |
175 case IMGFMT_RGB24: | |
176 bpp = 24; | |
177 break; | |
178 case IMGFMT_RGB32: | |
179 bpp = 32; | |
180 break; | |
181 case IMGFMT_BGR8: | |
182 bpp = 8; | |
183 break; | |
184 case IMGFMT_BGR15: | |
185 bpp = 15; | |
186 break; | |
187 case IMGFMT_BGR16: | |
188 bpp = 16; | |
189 break; | |
190 case IMGFMT_BGR24: | |
191 bpp = 24; | |
192 break; | |
193 case IMGFMT_BGR32: | |
194 bpp = 32; | |
195 break; | |
196 case IMGFMT_YV12: /* rgb, 24bit */ | |
197 bpp = 16; | |
198 yuv2rgb_init(32/*screendepth*/, MODE_RGB); | |
199 break; | |
200 default: | |
201 printf("ggi-init: no suitable image format found\n"); | |
202 return(-1); | |
203 } | |
204 | |
205 ggiSetFlags(ggi_vis, GGIFLAG_ASYNC); | |
206 | |
207 if (ggi_setmode(d_width, d_height, 32/*bpp*/, format) != 0) | |
208 { | |
209 printf("ggi-init: setmode returned with error\n"); | |
210 return(-1); | |
211 } | |
212 | |
213 ggi_buffer = (ggi_directbuffer *)ggiDBGetBuffer(ggi_vis, 0); | |
214 | |
215 if (ggi_buffer == NULL) | |
216 { | |
217 printf("ggi-init: double buffering is not available\n"); | |
218 ggiClose(ggi_vis); | |
219 ggiExit(); | |
220 return(-1); | |
221 } | |
222 | |
223 if (!(ggi_buffer->type & GGI_DB_SIMPLE_PLB) || | |
224 (ggi_buffer->page_size != 0) || | |
225 (ggi_buffer->write == NULL) || | |
226 (ggi_buffer->noaccess != 0) || | |
227 (ggi_buffer->align != 0)) | |
228 { | |
229 printf("ggi-init: incorrect video memory type\n"); | |
230 ggiClose(ggi_vis); | |
231 ggiExit(); | |
232 return(-1); | |
233 } | |
234 | |
235 /* just for fun */ | |
236 { | |
237 ggi_color col; | |
238 | |
239 /* set black */ | |
240 col.r = col.g = col.b = 0x0000; | |
241 black = ggiMapColor(ggi_vis, &col); | |
242 | |
243 /* set white */ | |
244 col.r = col.g = col.b = 0xffff; | |
245 white = ggiMapColor(ggi_vis, &col); | |
246 | |
247 ggiSetGCForeground(ggi_vis, white); | |
248 ggiSetGCBackground(ggi_vis, black); | |
249 } | |
250 | |
251 return(0); | |
252 } | |
253 | |
254 static const vo_info_t* get_info(void) | |
255 { | |
256 return &vo_info; | |
257 } | |
258 | |
259 static uint32_t draw_frame(uint8_t *src[]) | |
260 { | |
261 uint8_t *ptr; | |
262 int y, x, i; | |
263 /*int bppmul = vo_depthonscreen/8;*/ | |
264 | |
265 ggiResourceAcquire(ggi_buffer->resource, GGI_ACTYPE_WRITE); | |
266 ggiSetDisplayFrame(ggi_vis, ggi_buffer->frame); | |
267 ggiSetWriteFrame(ggi_vis, ggi_buffer->frame); | |
268 | |
269 ptr = ggi_buffer->write; | |
270 | |
271 // for (i = 1; i < 3; i++) | |
272 /* for (x = 0; x < virt_width; x++) | |
273 for (y = 0; y < virt_height; y++) | |
274 *ptr++ = src[0][x*virt_height+y];*/ | |
275 memcpy(ptr,src[0],virt_width*virt_height*(bpp/8)); | |
276 | |
277 ggiPuts(ggi_vis, x/2, y-10, "MPlayer GGI"); | |
278 | |
279 ggiResourceRelease(ggi_buffer->resource); | |
280 } | |
281 | |
282 static void flip_page(void) | |
283 { | |
284 check_events(); | |
285 ggiFlush(ggi_vis); | |
286 } | |
287 | |
288 static uint32_t draw_slice(uint8_t *src[], int stride[], int w, int h, | |
289 int x, int y) | |
290 { | |
291 uint8_t *dst; | |
292 | |
293 dst = ggi_buffer->write + (virt_width * y + x) * (bpp/8); | |
294 yuv2rgb(dst, src[0], src[1], src[2], w, h, virt_width*(bpp/8), | |
295 stride[0], stride[1]); | |
296 //draw_frame(dst); | |
297 | |
298 // dst = image_data + (virt_width * y + x) * (bpp/8); | |
299 // yuv2rgb(dst, src[0], src[1], src[2], w, h, virt_width*(bpp/8), | |
300 // stride[0], stride[1]); | |
301 return(0); | |
302 } | |
303 | |
304 static uint32_t query_format(uint32_t format) | |
305 { | |
306 switch(format){ | |
307 case IMGFMT_YV12: | |
308 return 1; | |
309 case IMGFMT_RGB8: | |
310 case IMGFMT_RGB15: | |
311 case IMGFMT_RGB16: | |
312 case IMGFMT_RGB24: | |
313 case IMGFMT_RGB32: | |
314 case IMGFMT_BGR8: | |
315 case IMGFMT_BGR15: | |
316 case IMGFMT_BGR16: | |
317 case IMGFMT_BGR24: | |
318 case IMGFMT_BGR32: | |
319 return 1; | |
320 } | |
321 return 0; | |
322 } | |
323 | |
324 static void uninit(void) | |
325 { | |
326 ggiResourceRelease(ggi_buffer->resource); | |
327 ggiClose(ggi_vis); | |
328 ggiExit(); | |
329 } | |
330 | |
331 static void check_events(void) | |
332 { | |
333 /* add ggiPollEvent stuff */ | |
334 } | |
335 |