Mercurial > mplayer.hg
annotate libvo/vo_svga.c @ 3845:8feacfc6bfee
nuppelvideo is suffering too
author | gabucino |
---|---|
date | Fri, 28 Dec 2001 20:14:24 +0000 |
parents | 32638add0dc8 |
children | ed5b85b713a3 |
rev | line source |
---|---|
285 | 1 /* |
292 | 2 Video driver for SVGAlib - alpha, slow |
285 | 3 by Zoltan Mark Vician <se7en@sch.bme.hu> |
381 | 4 Code started: Mon Apr 1 23:25:47 2001 |
407 | 5 |
6 Uses HW acceleration if your card is supported by SVGAlib. | |
285 | 7 */ |
8 | |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 | |
12 #include <vga.h> | |
13 #include <vgagl.h> | |
14 | |
485 | 15 #include <limits.h> |
16 | |
285 | 17 #include "config.h" |
18 #include "video_out.h" | |
19 #include "video_out_internal.h" | |
20 | |
616 | 21 #include "sub.h" |
2556 | 22 #include "../postproc/rgb2rgb.h" |
616 | 23 |
485 | 24 extern int vo_dbpp; |
504 | 25 extern int verbose; |
407 | 26 |
285 | 27 LIBVO_EXTERN(svga) |
28 | |
29 static vo_info_t vo_info = { | |
30 "SVGAlib", | |
31 "svga", | |
32 "Zoltan Mark Vician <se7en@sch.bme.hu>", | |
33 "" | |
34 }; | |
35 | |
36 // SVGAlib definitions | |
37 | |
38 GraphicsContext *screen; | |
39 GraphicsContext *virt; | |
40 | |
407 | 41 static uint8_t *scalebuf = NULL, *yuvbuf = NULL, *bppbuf = NULL; |
285 | 42 |
43 static uint32_t orig_w, orig_h, maxw, maxh; // Width, height | |
377 | 44 static float scaling = 1.0; |
285 | 45 static uint32_t x_pos, y_pos; // Position |
46 | |
483 | 47 // SVGAlib - list of detected modes |
48 typedef struct vga_modelist_s { | |
49 uint16_t modenum; | |
50 vga_modeinfo modeinfo; | |
51 struct vga_modelist_s *next; | |
52 } vga_modelist_t; | |
447 | 53 |
483 | 54 vga_modelist_t *modelist = NULL; |
55 | |
327 | 56 static uint8_t bpp; |
483 | 57 static uint8_t bpp_conv = 0; |
448
198b46b739d8
qrva eletbe nem kene cvs-t elbaszni inkabb ne nyuljatok hozza baz+
arpi_esp
parents:
447
diff
changeset
|
58 static uint32_t pformat; |
447 | 59 |
483 | 60 #define BPP_15 1 |
61 #define BPP_16 2 | |
62 #define BPP_24 4 | |
63 #define BPP_32 8 | |
64 static uint8_t bpp_avail = 0; | |
65 | |
285 | 66 static uint8_t checked = 0; |
483 | 67 |
485 | 68 static uint32_t add_mode(uint16_t mode, vga_modeinfo minfo) { |
483 | 69 vga_modelist_t *list; |
285 | 70 |
483 | 71 if (modelist == NULL) { |
485 | 72 modelist = (vga_modelist_t *) malloc(sizeof(vga_modelist_t)); |
483 | 73 if (modelist == NULL) { |
74 printf("vo_svga: add_mode() failed. Not enough memory for modelist."); | |
75 return(1); // error | |
76 } | |
485 | 77 modelist->modenum = mode; |
78 modelist->modeinfo = minfo; | |
79 modelist->next = NULL; | |
483 | 80 } else { |
81 list = modelist; | |
82 while (list->next != NULL) | |
83 list = list->next; | |
485 | 84 list->next = (vga_modelist_t *) malloc(sizeof(vga_modelist_t)); |
483 | 85 if (list->next == NULL) { |
86 printf("vo_svga: add_mode() failed. Not enough memory for modelist."); | |
87 return(1); // error | |
88 } | |
89 list = list->next; | |
90 list->modenum = mode; | |
91 list->modeinfo = minfo; | |
92 list->next = NULL; | |
93 } | |
485 | 94 return (0); |
483 | 95 } |
96 | |
97 static int checksupportedmodes() { | |
485 | 98 uint16_t i, max; |
483 | 99 vga_modeinfo *minfo; |
285 | 100 |
101 checked = 1; | |
102 vga_init(); | |
103 vga_disabledriverreport(); | |
485 | 104 max = vga_lastmodenumber(); |
105 for (i = 1; i < max; i++) | |
483 | 106 if (vga_hasmode(i) > 0) { |
107 minfo = vga_getmodeinfo(i); | |
108 switch (minfo->colors) { | |
109 case 32768: bpp_avail |= BPP_15; break; | |
110 case 65536: bpp_avail |= BPP_16; break; | |
111 } | |
112 switch (minfo->bytesperpixel) { | |
113 case 3: bpp_avail |= BPP_24; break; | |
114 case 4: bpp_avail |= BPP_32; break; | |
115 } | |
504 | 116 if (verbose >= 2) |
117 printf("vo_svga: Mode found: %s\n",vga_getmodename(i)); | |
483 | 118 if (add_mode(i, *minfo)) |
119 return(1); | |
120 } | |
485 | 121 return(0); |
285 | 122 } |
123 | |
124 static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, | |
125 uint32_t d_height, uint32_t fullscreen, char *title, | |
126 uint32_t format) { | |
483 | 127 uint32_t req_w = (d_width > 0 ? d_width : width); |
128 uint32_t req_h = (d_height > 0 ? d_height : height); | |
129 uint16_t vid_mode = 0; | |
976 | 130 uint8_t res_widescr, vid_widescr = (((req_w*1.0)/req_h) > (4.0/3)) ? 1 : 0; |
485 | 131 uint16_t buf_w = USHRT_MAX, buf_h = USHRT_MAX; |
483 | 132 vga_modelist_t *list = modelist; |
387 | 133 |
285 | 134 if (!checked) { |
485 | 135 if (checksupportedmodes()) // Looking for available video modes |
483 | 136 return(1); |
285 | 137 } |
407 | 138 |
483 | 139 bpp_avail = 0; |
140 while (list != NULL) { | |
141 if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) { | |
142 switch (list->modeinfo.colors) { | |
143 case 32768: bpp_avail |= BPP_15; break; | |
144 case 65536: bpp_avail |= BPP_16; break; | |
145 } | |
146 switch (list->modeinfo.bytesperpixel) { | |
147 case 3: bpp_avail |= BPP_24; break; | |
148 case 4: bpp_avail |= BPP_32; break; | |
149 } | |
150 } | |
151 list = list->next; | |
152 } | |
153 | |
285 | 154 pformat = format; |
411 | 155 |
483 | 156 // bpp check |
157 bpp_conv = 0; | |
411 | 158 if (!vo_dbpp) { |
159 if (format == IMGFMT_YV12) bpp = 32; | |
160 else bpp = format & 255; | |
504 | 161 if (verbose) |
162 printf("vo_svga: vo_dbpp == 0, bpp: %d\n",bpp); | |
483 | 163 switch (bpp) { |
164 case 32: if (!(bpp_avail & BPP_32)) { | |
165 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
485 | 166 printf("vo_svga: Maybe you should try -bpp\n"); |
483 | 167 return(1); |
168 } | |
169 break; | |
619 | 170 case 24: if (!(bpp_avail & BPP_24)) { |
483 | 171 if (!(bpp_avail & BPP_32)) { |
172 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
485 | 173 printf("vo_svga: Maybe you should try -bpp\n"); |
483 | 174 return(1); |
175 } else { | |
176 bpp = 32; | |
177 bpp_conv = 1; | |
617 | 178 printf("vo_svga: BPP conversion 24->32\n"); |
619 | 179 } |
180 } | |
483 | 181 break; |
182 case 16: if (!(bpp_avail & BPP_16)) { | |
183 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
184 printf("vo_svga: Maybe you should try -bpp\n"); | |
185 return(1); | |
186 } | |
187 break; | |
619 | 188 case 15: if (!(bpp_avail & BPP_15)) { |
483 | 189 if (!(bpp_avail & BPP_16)) { |
190 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
191 printf("vo_svga: Maybe you should try -bpp\n"); | |
192 return(1); | |
193 } else { | |
194 bpp = 16; | |
195 bpp_conv = 1; | |
617 | 196 printf("vo_svga: BPP conversion 15->16\n"); |
483 | 197 } |
619 | 198 } |
483 | 199 break; |
200 } | |
411 | 201 } else { |
202 bpp = vo_dbpp; | |
504 | 203 if (verbose) |
204 printf("vo_svga: vo_dbpp == %d\n",bpp); | |
411 | 205 switch (bpp) { |
483 | 206 case 32: if (!(bpp_avail & BPP_32)) { |
485 | 207 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 208 return(1); |
209 } | |
485 | 210 break; |
483 | 211 case 24: if (!(bpp_avail & BPP_24)) { |
485 | 212 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 213 return(1); |
214 } | |
485 | 215 break; |
483 | 216 case 16: if (!(bpp_avail & BPP_16)) { |
485 | 217 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 218 return(1); |
219 } | |
485 | 220 break; |
483 | 221 case 15: if (!(bpp_avail & BPP_15)) { |
485 | 222 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 223 return(1); |
224 } | |
485 | 225 break; |
411 | 226 } |
227 } | |
483 | 228 |
229 list = modelist; | |
504 | 230 if (verbose) { |
231 printf("vo_svga: Looking for the best resolution...\n"); | |
232 printf("vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,bpp); | |
233 } | |
485 | 234 while (list != NULL) { |
483 | 235 if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) { |
504 | 236 if (verbose) { |
237 switch (list->modeinfo.colors) { | |
238 case 32768: printf("vo_svga: vid_mode: %d, %dx%d 15bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height); | |
239 break; | |
240 case 65536: printf("vo_svga: vid_mode: %d, %dx%d 16bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height); | |
241 break; | |
242 } | |
243 switch (list->modeinfo.bytesperpixel) { | |
244 case 3: printf("vo_svga: vid_mode: %d, %dx%d 24bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height); | |
245 break; | |
246 case 4: printf("vo_svga: vid_mode: %d, %dx%d 32bpp\n",list->modenum,list->modeinfo.width,list->modeinfo.height); | |
247 break; | |
248 } | |
249 } | |
285 | 250 switch (bpp) { |
483 | 251 case 32: if (list->modeinfo.bytesperpixel == 4) |
485 | 252 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
253 vid_mode = list->modenum; | |
254 buf_w = list->modeinfo.width; | |
255 buf_h = list->modeinfo.height; | |
976 | 256 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 257 } |
258 break; | |
483 | 259 case 24: if (list->modeinfo.bytesperpixel == 3) |
485 | 260 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
261 vid_mode = list->modenum; | |
262 buf_w = list->modeinfo.width; | |
263 buf_h = list->modeinfo.height; | |
976 | 264 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 265 } |
266 break; | |
483 | 267 case 16: if (list->modeinfo.colors == 65536) |
485 | 268 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
269 vid_mode = list->modenum; | |
270 buf_w = list->modeinfo.width; | |
271 buf_h = list->modeinfo.height; | |
976 | 272 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 273 } |
274 break; | |
483 | 275 case 15: if (list->modeinfo.colors == 32768) |
485 | 276 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
277 vid_mode = list->modenum; | |
278 buf_w = list->modeinfo.width; | |
279 buf_h = list->modeinfo.height; | |
976 | 280 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 281 } |
282 break; | |
285 | 283 } |
483 | 284 } |
285 list = list->next; | |
407 | 286 } |
485 | 287 |
2982
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
288 if(vo_subdevice) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
289 int vm; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
290 vm=vga_getmodenumber(vo_subdevice); |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
291 list=modelist; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
292 while(list) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
293 if(list->modenum == vm) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
294 buf_w = list->modeinfo.width; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
295 buf_h = list->modeinfo.height; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
296 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
297 switch(list->modeinfo.colors) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
298 case 32768: |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
299 bpp=16; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
300 bpp_conv=1; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
301 break; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
302 case 65536: |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
303 bpp=16; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
304 bpp_conv=0; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
305 break; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
306 case (1<<24): |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
307 if(list->modeinfo.bytesperpixel == 3) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
308 bpp=32; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
309 bpp_conv=1; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
310 } else { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
311 bpp=32; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
312 bpp_conv=0; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
313 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
314 break; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
315 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
316 vid_mode=vm; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
317 list=NULL; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
318 } else list=list->next; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
319 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
320 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
321 |
504 | 322 if (verbose) |
323 printf("vo_svga: vid_mode: %d\n",vid_mode); | |
485 | 324 if (vga_setmode(vid_mode) == -1) { |
286 | 325 printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode); |
483 | 326 uninit(); |
285 | 327 return(1); // error |
485 | 328 } |
2982
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
329 vga_setlinearaddressing(); |
485 | 330 if (gl_setcontextvga(vid_mode)) { |
286 | 331 printf("vo_svga: gl_setcontextvga(%d) failed.\n",vid_mode); |
483 | 332 uninit(); |
285 | 333 return(1); // error |
286 | 334 } |
285 | 335 screen = gl_allocatecontext(); |
336 gl_getcontext(screen); | |
485 | 337 if (gl_setcontextvgavirtual(vid_mode)) { |
286 | 338 printf("vo_svga: gl_setcontextvgavirtual(%d) failed.\n",vid_mode); |
483 | 339 uninit(); |
285 | 340 return(1); // error |
286 | 341 } |
285 | 342 virt = gl_allocatecontext(); |
343 gl_getcontext(virt); | |
344 gl_setcontext(virt); | |
345 gl_clearscreen(0); | |
346 | |
485 | 347 if (bpp_conv) { |
483 | 348 bppbuf = malloc(maxw * maxh * BYTESPERPIXEL); |
485 | 349 if (bppbuf == NULL) { |
350 printf("vo_svga: bppbuf -> Not enough memory for buffering!\n"); | |
351 uninit(); | |
352 return (1); | |
353 } | |
483 | 354 } |
355 | |
285 | 356 orig_w = width; |
357 orig_h = height; | |
976 | 358 if ((fullscreen & 0x04) && (WIDTH != orig_w) && (HEIGHT != orig_h)) { |
359 if (!vid_widescr || !res_widescr) { | |
292 | 360 maxh = HEIGHT; |
361 scaling = maxh / (orig_h * 1.0); | |
362 maxw = (uint32_t) (orig_w * scaling); | |
363 scalebuf = malloc(maxw * maxh * BYTESPERPIXEL); | |
483 | 364 if (scalebuf == NULL) { |
485 | 365 printf("vo_svga: scalebuf -> Not enough memory for buffering!\n"); |
407 | 366 uninit(); |
367 return (1); | |
368 } | |
292 | 369 } else { |
370 maxw = WIDTH; | |
371 scaling = maxw / (orig_w * 1.0); | |
372 maxh = (uint32_t) (orig_h * scaling); | |
373 scalebuf = malloc(maxw * maxh * BYTESPERPIXEL); | |
483 | 374 if (scalebuf == NULL) { |
485 | 375 printf("vo_svga: scalebuf -> Not enough memory for buffering!\n"); |
407 | 376 uninit(); |
377 return (1); | |
378 } | |
292 | 379 } |
285 | 380 } else { |
381 maxw = orig_w; | |
382 maxh = orig_h; | |
383 } | |
384 x_pos = (WIDTH - maxw) / 2; | |
385 y_pos = (HEIGHT - maxh) / 2; | |
386 | |
387 if (pformat == IMGFMT_YV12) { | |
388 yuv2rgb_init(bpp, MODE_RGB); | |
389 yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL); | |
483 | 390 if (yuvbuf == NULL) { |
485 | 391 printf("vo_svga: yuvbuf -> Not enough memory for buffering!\n"); |
407 | 392 uninit(); |
393 return (1); | |
394 } | |
285 | 395 } |
377 | 396 |
504 | 397 printf("vo_svga: SVGAlib resolution: %dx%d %dbpp - ", WIDTH, HEIGHT, bpp); |
293 | 398 if (maxw != orig_w || maxh != orig_h) printf("Video scaled to: %dx%d\n",maxw,maxh); |
285 | 399 else printf("No video scaling\n"); |
400 | |
401 return (0); | |
402 } | |
403 | |
404 static uint32_t query_format(uint32_t format) { | |
485 | 405 uint32_t res = 0; |
407 | 406 |
483 | 407 if (!checked) { |
408 if (checksupportedmodes()) // Looking for available video modes | |
409 return(0); | |
410 } | |
485 | 411 |
412 // if (vo_dbpp) => There is NO conversion!!! | |
413 if (vo_dbpp) { | |
712 | 414 if (format == IMGFMT_YV12) return (1); |
485 | 415 switch (vo_dbpp) { |
488 | 416 case 32: if ((format == IMGFMT_RGB32) || (format == IMGFMT_BGR32)) |
485 | 417 return ((bpp_avail & BPP_32) ? 1 : 0); |
418 break; | |
488 | 419 case 24: if ((format == IMGFMT_RGB24) || (format == IMGFMT_BGR24)) |
485 | 420 return ((bpp_avail & BPP_24) ? 1 : 0); |
421 break; | |
488 | 422 case 16: if ((format == IMGFMT_RGB16) || (format == IMGFMT_BGR16)) |
485 | 423 return ((bpp_avail & BPP_16) ? 1 : 0); |
424 break; | |
488 | 425 case 15: if ((format == IMGFMT_RGB15) || (format == IMGFMT_BGR15)) |
485 | 426 return ((bpp_avail & BPP_15) ? 1 : 0); |
427 break; | |
407 | 428 } |
488 | 429 } else { |
485 | 430 switch (format) { |
431 case IMGFMT_RGB32: | |
488 | 432 case IMGFMT_BGR32: return ((bpp_avail & BPP_32) ? 1 : 0); break; |
485 | 433 case IMGFMT_RGB24: |
488 | 434 case IMGFMT_BGR24: { |
485 | 435 res = (bpp_avail & BPP_24) ? 1 : 0; |
436 if (!res) | |
437 res = (bpp_avail & BPP_32) ? 1 : 0; | |
438 return (res); | |
439 } break; | |
440 case IMGFMT_RGB16: | |
488 | 441 case IMGFMT_BGR16: return ((bpp_avail & BPP_16) ? 1 : 0); break; |
485 | 442 case IMGFMT_RGB15: |
488 | 443 case IMGFMT_BGR15: { |
485 | 444 res = (bpp_avail & BPP_15) ? 1 : 0; |
445 if (!res) | |
446 res = (bpp_avail & BPP_16) ? 1 : 0; | |
447 return (res); | |
448 } break; | |
449 case IMGFMT_YV12: return (1); break; | |
285 | 450 } |
488 | 451 } |
285 | 452 return (0); |
453 } | |
454 | |
455 static const vo_info_t* get_info(void) { | |
456 return (&vo_info); | |
457 } | |
458 | |
459 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
460 unsigned char *srca, int stride) { | |
327 | 461 switch (bpp) { |
462 case 32: | |
463 vo_draw_alpha_rgb32(w, h, src, srca, stride, virt->vbuf+4*(y0*WIDTH+x0), 4*WIDTH); | |
464 break; | |
465 case 24: | |
466 vo_draw_alpha_rgb24(w, h, src, srca, stride, virt->vbuf+3*(y0*WIDTH+x0), 3*WIDTH); | |
467 break; | |
468 case 16: | |
469 vo_draw_alpha_rgb16(w, h, src, srca, stride, virt->vbuf+2*(y0*WIDTH+x0), 2*WIDTH); | |
470 break; | |
471 case 15: | |
472 vo_draw_alpha_rgb15(w, h, src, srca, stride, virt->vbuf+2*(y0*WIDTH+x0), 2*WIDTH); | |
473 break; | |
474 } | |
285 | 475 } |
476 | |
477 static uint32_t draw_frame(uint8_t *src[]) { | |
478 if (pformat == IMGFMT_YV12) { | |
479 yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, orig_w * BYTESPERPIXEL, orig_w, orig_w / 2); | |
480 src[0] = yuvbuf; | |
481 } | |
483 | 482 if (scalebuf != NULL) { |
285 | 483 gl_scalebox(orig_w, orig_h, src[0], maxw, maxh, scalebuf); |
484 src[0] = scalebuf; | |
485 } | |
407 | 486 if (bpp_conv) { |
487 switch(bpp) { | |
485 | 488 case 32: { |
620 | 489 uint8_t *source = src[0]; |
490 uint8_t *dest = bppbuf; | |
491 register uint32_t i = 0; | |
502 | 492 |
620 | 493 while (i < (maxw * maxh * 4)) { |
494 dest[i] = source[i]; | |
495 dest[i+1] = source[i+1]; | |
496 dest[i+2] = source[i+2]; | |
497 dest[i+3] = 0; | |
498 i += 4; | |
407 | 499 } |
485 | 500 } break; |
501 case 16: { | |
2556 | 502 rgb15to16(src[0],bppbuf,maxw * maxh * 2); |
485 | 503 } break; |
407 | 504 } |
505 src[0] = bppbuf; | |
506 } | |
285 | 507 gl_putbox(x_pos, y_pos, maxw, maxh, src[0]); |
617 | 508 |
509 return (0); | |
285 | 510 } |
511 | |
512 static uint32_t draw_slice(uint8_t *image[], int stride[], | |
513 int w, int h, int x, int y) { | |
514 uint8_t *src = yuvbuf; | |
377 | 515 uint32_t sw, sh; |
516 | |
875 | 517 yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, orig_w * BYTESPERPIXEL, stride[0], stride[1]); |
377 | 518 sw = (uint32_t) (w * scaling); |
519 sh = (uint32_t) (h * scaling); | |
483 | 520 if (scalebuf != NULL) { |
377 | 521 gl_scalebox(w, h, yuvbuf, sw, sh, scalebuf); |
285 | 522 src = scalebuf; |
523 } | |
377 | 524 gl_putbox((int)(x * scaling) + x_pos, (int)(y * scaling) + y_pos, sw, sh, src); |
617 | 525 |
526 return (0); | |
285 | 527 } |
528 | |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
529 static void draw_osd(void) |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
530 { |
292 | 531 if (y_pos) { |
532 gl_fillbox(0, 0, WIDTH, y_pos, 0); | |
533 gl_fillbox(0, HEIGHT - y_pos, WIDTH, y_pos, 0); | |
1512
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
534 if (x_pos) { |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
535 int hmy=HEIGHT - (y_pos<<1); |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
536 gl_fillbox(0, y_pos, x_pos, hmy, 0); |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
537 gl_fillbox(WIDTH - x_pos, y_pos, x_pos, hmy, 0); |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
538 } |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
539 } else if (x_pos) { |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
540 gl_fillbox(0, y_pos, x_pos, HEIGHT, 0); |
d3364cc1f792
small changes to erase only needed place (rectangles doesn't overlap)
atlka
parents:
1501
diff
changeset
|
541 gl_fillbox(WIDTH - x_pos, y_pos, x_pos, HEIGHT, 0); |
989 | 542 } |
543 | |
486 | 544 vo_draw_text(WIDTH, HEIGHT, draw_alpha); |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
545 } |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
546 |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
547 static void flip_page(void) { |
285 | 548 gl_copyscreen(screen); |
549 } | |
550 | |
551 static void check_events(void) { | |
552 } | |
553 | |
554 static void uninit(void) { | |
483 | 555 vga_modelist_t *list = modelist; |
556 | |
285 | 557 gl_freecontext(screen); |
558 gl_freecontext(virt); | |
559 vga_setmode(TEXT); | |
483 | 560 if (bppbuf != NULL) |
407 | 561 free(bppbuf); |
483 | 562 if (scalebuf != NULL) |
285 | 563 free(scalebuf); |
483 | 564 if (yuvbuf != NULL) |
285 | 565 free(yuvbuf); |
1501
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
566 while (modelist != NULL) { |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
567 list=modelist; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
568 modelist=modelist->next; |
d40f2b686846
changes according to -utf8 option, draw_osd() function added
atlka
parents:
1339
diff
changeset
|
569 free(list); |
483 | 570 } |
285 | 571 } |