Mercurial > mplayer.hg
annotate libvo/vo_svga.c @ 5999:792d58595767
fix -fs and 'f'
author | pontscho |
---|---|
date | Mon, 06 May 2002 16:56:41 +0000 |
parents | 30f196ff3bec |
children | a5df6daa31fb |
rev | line source |
---|---|
285 | 1 /* |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
2 Video driver for SVGAlib |
285 | 3 by Zoltan Mark Vician <se7en@sch.bme.hu> |
381 | 4 Code started: Mon Apr 1 23:25:47 2001 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
5 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
6 Some changes by Matan Ziv-Av <matan@svgalib.org> |
285 | 7 */ |
8 | |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 | |
12 #include <vga.h> | |
13 | |
485 | 14 #include <limits.h> |
15 | |
285 | 16 #include "config.h" |
17 #include "video_out.h" | |
18 #include "video_out_internal.h" | |
19 | |
616 | 20 #include "sub.h" |
2556 | 21 #include "../postproc/rgb2rgb.h" |
616 | 22 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
23 #include "../mp_msg.h" |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
24 //#include "../mp_image.h" |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
25 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
26 extern int vo_directrendering; |
485 | 27 extern int vo_dbpp; |
504 | 28 extern int verbose; |
407 | 29 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
30 static uint32_t query_format(uint32_t format); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
31 static int checksupportedmodes(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
32 static void putbox(int x, int y, int w, int h, uint8_t *buf,int prog); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
33 static void fillbox(int x, int y, int w, int h, uint32_t c); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
34 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
35 unsigned char *srca, int stride); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
36 static uint32_t get_image(mp_image_t *mpi); |
285 | 37 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
38 static uint8_t *yuvbuf = NULL, *bppbuf = NULL; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
39 static uint8_t *GRAPH_MEM; |
285 | 40 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
41 static int BYTESPERPIXEL, WIDTH, HEIGHT, LINEWIDTH; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
42 static int frame, maxframes, oldmethod=0; |
285 | 43 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
44 static uint32_t pformat; |
285 | 45 static uint32_t orig_w, orig_h, maxw, maxh; // Width, height |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
46 static uint8_t buf0[8192]; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
47 static uint8_t *buffer; |
285 | 48 |
483 | 49 typedef struct vga_modelist_s { |
50 uint16_t modenum; | |
51 vga_modeinfo modeinfo; | |
52 struct vga_modelist_s *next; | |
53 } vga_modelist_t; | |
447 | 54 |
483 | 55 vga_modelist_t *modelist = NULL; |
56 | |
327 | 57 static uint8_t bpp; |
483 | 58 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
|
59 static uint32_t pformat; |
447 | 60 |
483 | 61 #define BPP_15 1 |
62 #define BPP_16 2 | |
63 #define BPP_24 4 | |
64 #define BPP_32 8 | |
65 static uint8_t bpp_avail = 0; | |
66 | |
285 | 67 static uint8_t checked = 0; |
483 | 68 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
69 static uint32_t x_pos, y_pos; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
70 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
71 LIBVO_EXTERN(svga) |
285 | 72 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
73 static vo_info_t vo_info = { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
74 "SVGAlib", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
75 "svga", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
76 "Zoltan Mark Vician <se7en@sch.bme.hu>", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
77 "" |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
78 }; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
79 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
80 static uint32_t preinit(const char *arg) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
81 { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
82 int i; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
83 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
84 for(i=0;i<8192;i++) buf0[i]=0; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
85 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
86 if(vo_directrendering) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
87 maxframes=0; |
483 | 88 } else { |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
89 maxframes=1; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
90 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
91 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
92 printf("vo_svga: preinit - maxframes=%i\n",maxframes); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
93 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
94 return 0; |
483 | 95 } |
96 | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
97 static uint32_t control(uint32_t request, void *data, ...) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
98 { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
99 switch (request) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
100 case VOCTRL_QUERY_FORMAT: |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
101 return query_format(*((uint32_t*)data)); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
102 case VOCTRL_GET_IMAGE: |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
103 return get_image(data); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
104 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
105 return VO_NOTIMPL; |
285 | 106 } |
107 | |
4433 | 108 static uint32_t config(uint32_t width, uint32_t height, uint32_t d_width, |
285 | 109 uint32_t d_height, uint32_t fullscreen, char *title, |
4433 | 110 uint32_t format,const vo_tune_info_t *info) { |
483 | 111 uint32_t req_w = (d_width > 0 ? d_width : width); |
112 uint32_t req_h = (d_height > 0 ? d_height : height); | |
113 uint16_t vid_mode = 0; | |
976 | 114 uint8_t res_widescr, vid_widescr = (((req_w*1.0)/req_h) > (4.0/3)) ? 1 : 0; |
485 | 115 uint16_t buf_w = USHRT_MAX, buf_h = USHRT_MAX; |
483 | 116 vga_modelist_t *list = modelist; |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
117 |
285 | 118 if (!checked) { |
485 | 119 if (checksupportedmodes()) // Looking for available video modes |
483 | 120 return(1); |
285 | 121 } |
407 | 122 |
483 | 123 bpp_avail = 0; |
124 while (list != NULL) { | |
125 if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) { | |
126 switch (list->modeinfo.colors) { | |
127 case 32768: bpp_avail |= BPP_15; break; | |
128 case 65536: bpp_avail |= BPP_16; break; | |
129 } | |
130 switch (list->modeinfo.bytesperpixel) { | |
131 case 3: bpp_avail |= BPP_24; break; | |
132 case 4: bpp_avail |= BPP_32; break; | |
133 } | |
134 } | |
135 list = list->next; | |
136 } | |
137 | |
285 | 138 pformat = format; |
411 | 139 |
483 | 140 // bpp check |
141 bpp_conv = 0; | |
411 | 142 if (!vo_dbpp) { |
143 if (format == IMGFMT_YV12) bpp = 32; | |
144 else bpp = format & 255; | |
504 | 145 if (verbose) |
146 printf("vo_svga: vo_dbpp == 0, bpp: %d\n",bpp); | |
483 | 147 switch (bpp) { |
148 case 32: if (!(bpp_avail & BPP_32)) { | |
149 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
485 | 150 printf("vo_svga: Maybe you should try -bpp\n"); |
483 | 151 return(1); |
152 } | |
153 break; | |
619 | 154 case 24: if (!(bpp_avail & BPP_24)) { |
483 | 155 if (!(bpp_avail & BPP_32)) { |
156 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
485 | 157 printf("vo_svga: Maybe you should try -bpp\n"); |
483 | 158 return(1); |
159 } else { | |
160 bpp = 32; | |
161 bpp_conv = 1; | |
617 | 162 printf("vo_svga: BPP conversion 24->32\n"); |
619 | 163 } |
164 } | |
483 | 165 break; |
166 case 16: if (!(bpp_avail & BPP_16)) { | |
167 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
168 printf("vo_svga: Maybe you should try -bpp\n"); | |
169 return(1); | |
170 } | |
171 break; | |
619 | 172 case 15: if (!(bpp_avail & BPP_15)) { |
483 | 173 if (!(bpp_avail & BPP_16)) { |
174 printf("vo_svga: Haven't found video mode which fit to: %dx%d %dbpp\n",req_w,req_h,bpp); | |
175 printf("vo_svga: Maybe you should try -bpp\n"); | |
176 return(1); | |
177 } else { | |
178 bpp = 16; | |
179 bpp_conv = 1; | |
617 | 180 printf("vo_svga: BPP conversion 15->16\n"); |
483 | 181 } |
619 | 182 } |
483 | 183 break; |
184 } | |
411 | 185 } else { |
186 bpp = vo_dbpp; | |
504 | 187 if (verbose) |
188 printf("vo_svga: vo_dbpp == %d\n",bpp); | |
411 | 189 switch (bpp) { |
483 | 190 case 32: if (!(bpp_avail & BPP_32)) { |
485 | 191 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 192 return(1); |
193 } | |
485 | 194 break; |
483 | 195 case 24: if (!(bpp_avail & BPP_24)) { |
485 | 196 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 197 return(1); |
198 } | |
485 | 199 break; |
483 | 200 case 16: if (!(bpp_avail & BPP_16)) { |
485 | 201 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 202 return(1); |
203 } | |
485 | 204 break; |
483 | 205 case 15: if (!(bpp_avail & BPP_15)) { |
485 | 206 printf("vo_svga: %dbpp not supported in %dx%d (or larger resoltuion) by HW or SVGAlib\n",bpp,req_w,req_h); |
411 | 207 return(1); |
208 } | |
485 | 209 break; |
411 | 210 } |
211 } | |
483 | 212 |
213 list = modelist; | |
504 | 214 if (verbose) { |
215 printf("vo_svga: Looking for the best resolution...\n"); | |
216 printf("vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,bpp); | |
217 } | |
485 | 218 while (list != NULL) { |
483 | 219 if ((list->modeinfo.width >= req_w) && (list->modeinfo.height >= req_h)) { |
504 | 220 if (verbose) { |
221 switch (list->modeinfo.colors) { | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
222 case 32768: printf("vo_svga: vid_mode: %d, %dx%d 15bpp\n", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
223 list->modenum,list->modeinfo.width,list->modeinfo.height); |
504 | 224 break; |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
225 case 65536: printf("vo_svga: vid_mode: %d, %dx%d 16bpp\n", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
226 list->modenum,list->modeinfo.width,list->modeinfo.height); |
504 | 227 break; |
228 } | |
229 switch (list->modeinfo.bytesperpixel) { | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
230 case 3: printf("vo_svga: vid_mode: %d, %dx%d 24bpp\n", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
231 list->modenum,list->modeinfo.width,list->modeinfo.height); |
504 | 232 break; |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
233 case 4: printf("vo_svga: vid_mode: %d, %dx%d 32bpp\n", |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
234 list->modenum,list->modeinfo.width,list->modeinfo.height); |
504 | 235 break; |
236 } | |
237 } | |
285 | 238 switch (bpp) { |
483 | 239 case 32: if (list->modeinfo.bytesperpixel == 4) |
485 | 240 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
241 vid_mode = list->modenum; | |
242 buf_w = list->modeinfo.width; | |
243 buf_h = list->modeinfo.height; | |
976 | 244 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 245 } |
246 break; | |
483 | 247 case 24: if (list->modeinfo.bytesperpixel == 3) |
485 | 248 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
249 vid_mode = list->modenum; | |
250 buf_w = list->modeinfo.width; | |
251 buf_h = list->modeinfo.height; | |
976 | 252 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 253 } |
254 break; | |
483 | 255 case 16: if (list->modeinfo.colors == 65536) |
485 | 256 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
257 vid_mode = list->modenum; | |
258 buf_w = list->modeinfo.width; | |
259 buf_h = list->modeinfo.height; | |
976 | 260 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 261 } |
262 break; | |
483 | 263 case 15: if (list->modeinfo.colors == 32768) |
485 | 264 if ((list->modeinfo.width < buf_w) || (list->modeinfo.height < buf_h)) { |
265 vid_mode = list->modenum; | |
266 buf_w = list->modeinfo.width; | |
267 buf_h = list->modeinfo.height; | |
976 | 268 res_widescr = (((buf_w*1.0)/buf_h) > (4.0/3)) ? 1 : 0; |
485 | 269 } |
270 break; | |
285 | 271 } |
483 | 272 } |
273 list = list->next; | |
407 | 274 } |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
275 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
276 if((vo_subdevice) && (strlen(vo_subdevice)>2)) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
277 if(!strncmp(vo_subdevice,"old",3)) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
278 oldmethod=1; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
279 vo_subdevice+=3; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
280 if( *vo_subdevice == ',' ) vo_subdevice++; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
281 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
282 } |
485 | 283 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
284 if((vo_subdevice) && *vo_subdevice) { |
2982
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
285 int vm; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
286 vm=vga_getmodenumber(vo_subdevice); |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
287 list=modelist; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
288 while(list) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
289 if(list->modenum == vm) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
290 buf_w = list->modeinfo.width; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
291 buf_h = list->modeinfo.height; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
292 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
|
293 switch(list->modeinfo.colors) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
294 case 32768: |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
295 bpp=16; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
296 bpp_conv=1; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
297 break; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
298 case 65536: |
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=0; |
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 (1<<24): |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
303 if(list->modeinfo.bytesperpixel == 3) { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
304 bpp=32; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
305 bpp_conv=1; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
306 } else { |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
307 bpp=32; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
308 bpp_conv=0; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
309 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
310 break; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
311 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
312 vid_mode=vm; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
313 list=NULL; |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
314 } else list=list->next; |
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 } |
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
317 |
504 | 318 if (verbose) |
319 printf("vo_svga: vid_mode: %d\n",vid_mode); | |
485 | 320 if (vga_setmode(vid_mode) == -1) { |
286 | 321 printf("vo_svga: vga_setmode(%d) failed.\n",vid_mode); |
483 | 322 uninit(); |
285 | 323 return(1); // error |
485 | 324 } |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
325 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
326 WIDTH=vga_getxdim(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
327 HEIGHT=vga_getydim(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
328 BYTESPERPIXEL=(bpp+1)>>3; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
329 LINEWIDTH=WIDTH*BYTESPERPIXEL; |
2982
32638add0dc8
mode selection (subdev) fix by Matan Ziv-Av matan@svgalib.org
arpi
parents:
2732
diff
changeset
|
330 vga_setlinearaddressing(); |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
331 if(oldmethod) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
332 buffer=malloc(HEIGHT*LINEWIDTH); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
333 maxframes=0; |
286 | 334 } |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
335 vga_claimvideomemory((maxframes+1)*HEIGHT*LINEWIDTH); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
336 GRAPH_MEM=vga_getgraphmem(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
337 frame=0; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
338 fillbox(0,0,WIDTH,HEIGHT*(maxframes+1),0); |
285 | 339 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
340 orig_w = width; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
341 orig_h = height; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
342 maxw = orig_w; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
343 maxh = orig_h; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
344 |
485 | 345 if (bpp_conv) { |
483 | 346 bppbuf = malloc(maxw * maxh * BYTESPERPIXEL); |
485 | 347 if (bppbuf == NULL) { |
348 printf("vo_svga: bppbuf -> Not enough memory for buffering!\n"); | |
349 uninit(); | |
350 return (1); | |
351 } | |
483 | 352 } |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
353 |
285 | 354 x_pos = (WIDTH - maxw) / 2; |
355 y_pos = (HEIGHT - maxh) / 2; | |
356 | |
357 if (pformat == IMGFMT_YV12) { | |
358 yuv2rgb_init(bpp, MODE_RGB); | |
359 yuvbuf = malloc(maxw * maxh * BYTESPERPIXEL); | |
483 | 360 if (yuvbuf == NULL) { |
485 | 361 printf("vo_svga: yuvbuf -> Not enough memory for buffering!\n"); |
407 | 362 uninit(); |
363 return (1); | |
364 } | |
285 | 365 } |
377 | 366 |
504 | 367 printf("vo_svga: SVGAlib resolution: %dx%d %dbpp - ", WIDTH, HEIGHT, bpp); |
293 | 368 if (maxw != orig_w || maxh != orig_h) printf("Video scaled to: %dx%d\n",maxw,maxh); |
285 | 369 else printf("No video scaling\n"); |
370 | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
371 vga_setdisplaystart(0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
372 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
373 return (0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
374 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
375 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
376 static const vo_info_t* get_info(void) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
377 return (&vo_info); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
378 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
379 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
380 static uint32_t draw_frame(uint8_t *src[]) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
381 if (pformat == IMGFMT_YV12) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
382 yuv2rgb(yuvbuf, src[0], src[1], src[2], orig_w, orig_h, orig_w * BYTESPERPIXEL, orig_w, orig_w / 2); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
383 src[0] = yuvbuf; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
384 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
385 if (bpp_conv) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
386 switch(bpp) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
387 case 32: { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
388 uint8_t *source = src[0]; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
389 uint8_t *dest = bppbuf; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
390 register uint32_t i = 0; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
391 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
392 while (i < (maxw * maxh * 4)) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
393 dest[i] = source[i]; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
394 dest[i+1] = source[i+1]; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
395 dest[i+2] = source[i+2]; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
396 dest[i+3] = 0; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
397 i += 4; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
398 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
399 } break; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
400 case 16: { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
401 rgb15to16(src[0],bppbuf,maxw * maxh * 2); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
402 } break; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
403 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
404 src[0] = bppbuf; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
405 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
406 putbox(x_pos, y_pos, maxw, maxh, src[0], 1); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
407 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
408 return (0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
409 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
410 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
411 static uint32_t draw_slice(uint8_t *image[], int stride[], |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
412 int w, int h, int x, int y) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
413 uint8_t *src = yuvbuf; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
414 uint32_t sw, sh; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
415 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
416 yuv2rgb(yuvbuf, image[0], image[1], image[2], w, h, orig_w * BYTESPERPIXEL, stride[0], stride[1]); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
417 putbox(x + x_pos, y + y_pos, w, h, src, 1); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
418 |
285 | 419 return (0); |
420 } | |
421 | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
422 static void draw_osd(void) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
423 { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
424 if(oldmethod) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
425 if (y_pos) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
426 fillbox(0, 0, WIDTH, y_pos, 0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
427 fillbox(0, HEIGHT - y_pos, WIDTH, y_pos, 0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
428 if (x_pos) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
429 int hmy=HEIGHT - (y_pos<<1); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
430 fillbox(0, y_pos, x_pos, hmy, 0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
431 fillbox(WIDTH - x_pos, y_pos, x_pos, hmy, 0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
432 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
433 } else if (x_pos) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
434 fillbox(0, y_pos, x_pos, HEIGHT, 0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
435 fillbox(WIDTH - x_pos, y_pos, x_pos, HEIGHT, 0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
436 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
437 vo_draw_text(WIDTH, HEIGHT, draw_alpha); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
438 } else |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
439 vo_draw_text(maxw, maxh, draw_alpha); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
440 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
441 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
442 static void flip_page(void) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
443 if(oldmethod) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
444 int i; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
445 uint8_t *b; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
446 b=buffer; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
447 for(i=0;i<HEIGHT;i++){ |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
448 vga_drawscansegment(b,0,i,LINEWIDTH); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
449 b+=LINEWIDTH; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
450 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
451 } else { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
452 if(maxframes) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
453 vga_setdisplaystart(frame*HEIGHT*LINEWIDTH); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
454 frame++; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
455 if(frame>maxframes)frame=0; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
456 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
457 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
458 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
459 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
460 static void check_events(void) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
461 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
462 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
463 static void uninit(void) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
464 vga_modelist_t *list = modelist; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
465 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
466 vga_setmode(TEXT); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
467 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
468 if (bppbuf != NULL) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
469 free(bppbuf); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
470 if (yuvbuf != NULL) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
471 free(yuvbuf); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
472 while (modelist != NULL) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
473 list=modelist; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
474 modelist=modelist->next; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
475 free(list); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
476 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
477 checked = 0; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
478 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
479 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
480 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
481 /* --------------------------------------------------------------------- */ |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
482 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
483 static uint32_t add_mode(uint16_t mode, vga_modeinfo minfo) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
484 vga_modelist_t *list; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
485 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
486 if (modelist == NULL) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
487 modelist = (vga_modelist_t *) malloc(sizeof(vga_modelist_t)); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
488 if (modelist == NULL) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
489 printf("vo_svga: add_mode() failed. Not enough memory for modelist."); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
490 return(1); // error |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
491 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
492 modelist->modenum = mode; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
493 modelist->modeinfo = minfo; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
494 modelist->next = NULL; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
495 } else { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
496 list = modelist; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
497 while (list->next != NULL) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
498 list = list->next; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
499 list->next = (vga_modelist_t *) malloc(sizeof(vga_modelist_t)); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
500 if (list->next == NULL) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
501 printf("vo_svga: add_mode() failed. Not enough memory for modelist."); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
502 return(1); // error |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
503 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
504 list = list->next; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
505 list->modenum = mode; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
506 list->modeinfo = minfo; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
507 list->next = NULL; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
508 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
509 return (0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
510 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
511 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
512 static int checksupportedmodes() { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
513 uint16_t i, max; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
514 vga_modeinfo *minfo; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
515 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
516 checked = 1; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
517 vga_init(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
518 vga_disabledriverreport(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
519 max = vga_lastmodenumber(); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
520 if (verbose >= 2) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
521 printf("vo_svga: Max mode : %i\n",max); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
522 for (i = 1; i <= max; i++) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
523 if (vga_hasmode(i) > 0) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
524 minfo = vga_getmodeinfo(i); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
525 switch (minfo->colors) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
526 case 32768: bpp_avail |= BPP_15; break; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
527 case 65536: bpp_avail |= BPP_16; break; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
528 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
529 switch (minfo->bytesperpixel) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
530 case 3: bpp_avail |= BPP_24; break; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
531 case 4: bpp_avail |= BPP_32; break; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
532 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
533 if (verbose >= 2) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
534 printf("vo_svga: Mode found: %s\n",vga_getmodename(i)); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
535 if (add_mode(i, *minfo)) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
536 return(1); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
537 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
538 return(0); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
539 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
540 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
541 |
285 | 542 static uint32_t query_format(uint32_t format) { |
485 | 543 uint32_t res = 0; |
407 | 544 |
483 | 545 if (!checked) { |
546 if (checksupportedmodes()) // Looking for available video modes | |
547 return(0); | |
548 } | |
485 | 549 |
550 // if (vo_dbpp) => There is NO conversion!!! | |
551 if (vo_dbpp) { | |
712 | 552 if (format == IMGFMT_YV12) return (1); |
485 | 553 switch (vo_dbpp) { |
488 | 554 case 32: if ((format == IMGFMT_RGB32) || (format == IMGFMT_BGR32)) |
485 | 555 return ((bpp_avail & BPP_32) ? 1 : 0); |
556 break; | |
488 | 557 case 24: if ((format == IMGFMT_RGB24) || (format == IMGFMT_BGR24)) |
485 | 558 return ((bpp_avail & BPP_24) ? 1 : 0); |
559 break; | |
488 | 560 case 16: if ((format == IMGFMT_RGB16) || (format == IMGFMT_BGR16)) |
485 | 561 return ((bpp_avail & BPP_16) ? 1 : 0); |
562 break; | |
488 | 563 case 15: if ((format == IMGFMT_RGB15) || (format == IMGFMT_BGR15)) |
485 | 564 return ((bpp_avail & BPP_15) ? 1 : 0); |
565 break; | |
407 | 566 } |
488 | 567 } else { |
485 | 568 switch (format) { |
569 case IMGFMT_RGB32: | |
488 | 570 case IMGFMT_BGR32: return ((bpp_avail & BPP_32) ? 1 : 0); break; |
485 | 571 case IMGFMT_RGB24: |
488 | 572 case IMGFMT_BGR24: { |
485 | 573 res = (bpp_avail & BPP_24) ? 1 : 0; |
574 if (!res) | |
575 res = (bpp_avail & BPP_32) ? 1 : 0; | |
576 return (res); | |
577 } break; | |
578 case IMGFMT_RGB16: | |
488 | 579 case IMGFMT_BGR16: return ((bpp_avail & BPP_16) ? 1 : 0); break; |
485 | 580 case IMGFMT_RGB15: |
488 | 581 case IMGFMT_BGR15: { |
485 | 582 res = (bpp_avail & BPP_15) ? 1 : 0; |
583 if (!res) | |
584 res = (bpp_avail & BPP_16) ? 1 : 0; | |
585 return (res); | |
586 } break; | |
587 case IMGFMT_YV12: return (1); break; | |
285 | 588 } |
488 | 589 } |
285 | 590 return (0); |
591 } | |
592 | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
593 static void putbox(int x, int y, int w, int h, uint8_t *buf, int prog) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
594 int base, add, wid; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
595 if(oldmethod) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
596 wid=w*BYTESPERPIXEL; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
597 add=wid*prog; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
598 while( (h--) > 0 ) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
599 memcpy(buffer+x*BYTESPERPIXEL+(y++)*LINEWIDTH, buf, wid); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
600 buf+=add; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
601 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
602 } else { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
603 wid=w*BYTESPERPIXEL; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
604 add=wid*prog; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
605 base=frame*HEIGHT; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
606 while( (h--) > 0 ) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
607 vga_drawscansegment(buf, x, (y++)+base, wid); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
608 buf+=add; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
609 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
610 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
611 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
612 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
613 static void fillbox(int x, int y, int w, int h, uint32_t c) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
614 putbox(x,y,w,h,buf0,0); |
285 | 615 } |
616 | |
617 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, | |
618 unsigned char *srca, int stride) { | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
619 int base; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
620 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
621 if(oldmethod) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
622 base=buffer; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
623 } else |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
624 base=((frame*HEIGHT+y_pos)*WIDTH+x_pos)*BYTESPERPIXEL + GRAPH_MEM ; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
625 |
327 | 626 switch (bpp) { |
627 case 32: | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
628 vo_draw_alpha_rgb32(w, h, src, srca, stride, base+4*(y0*WIDTH+x0), 4*WIDTH); |
327 | 629 break; |
630 case 24: | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
631 vo_draw_alpha_rgb24(w, h, src, srca, stride, base+3*(y0*WIDTH+x0), 3*WIDTH); |
327 | 632 break; |
633 case 16: | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
634 vo_draw_alpha_rgb16(w, h, src, srca, stride, base+2*(y0*WIDTH+x0), 2*WIDTH); |
327 | 635 break; |
636 case 15: | |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
637 vo_draw_alpha_rgb15(w, h, src, srca, stride, base+2*(y0*WIDTH+x0), 2*WIDTH); |
327 | 638 break; |
639 } | |
285 | 640 } |
4352 | 641 |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
642 static uint32_t get_image(mp_image_t *mpi) |
4352 | 643 { |
5679
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
644 if (/* zoomFlag || */ |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
645 !IMGFMT_IS_BGR(mpi->imgfmt) || |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
646 ((mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
647 (mpi->flags & MP_IMGFLAG_PLANAR) || |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
648 (mpi->flags & MP_IMGFLAG_YUV) /* |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
649 (mpi->width != image_width) || |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
650 (mpi->height != image_height) */ |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
651 ) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
652 return(VO_FALSE); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
653 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
654 /* |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
655 if (Flip_Flag) |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
656 { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
657 mpi->stride[0] = -image_width*((bpp+7)/8); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
658 mpi->planes[0] = ImageData - mpi->stride[0]*(image_height-1); |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
659 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
660 else |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
661 */ |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
662 { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
663 mpi->stride[0] = LINEWIDTH; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
664 if(oldmethod) { |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
665 mpi->planes[0] = buffer; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
666 } else |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
667 mpi->planes[0] = GRAPH_MEM; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
668 } |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
669 mpi->flags |= MP_IMGFLAG_DIRECT; |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
670 |
30f196ff3bec
This patch replaces vo_svga.c with an improved version that does not use
arpi
parents:
4596
diff
changeset
|
671 return(VO_TRUE); |
4352 | 672 } |
673 |