Mercurial > mplayer.hg
annotate libvo/vo_vesa.c @ 2688:e9f6634c6374
Code cleanup
author | nick |
---|---|
date | Sun, 04 Nov 2001 17:01:12 +0000 |
parents | 44ff6b5c7cea |
children | 6a5b6b16d85c |
rev | line source |
---|---|
2519 | 1 /* |
2244 | 2 * video_out_vesa.c |
3 * | |
4 * Copyright (C) Nick Kurshev <nickols_k@mail.ru> - Oct 2001 | |
5 * | |
6 * You can redistribute this file under terms and conditions | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
7 * of GNU General Public licence v2. |
2244 | 8 * This file is partly based on vbetest.c from lrmi distributive. |
9 */ | |
10 | |
11 /* | |
12 TODO: | |
13 - hw YUV support (need volunteers who have corresponding hardware) | |
2649 | 14 - triple buffering (if it will really speedup playback). |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
15 note: triple buffering requires VBE 3.0. |
2244 | 16 - refresh rate support (need additional info from mplayer) |
17 */ | |
18 #include <stdio.h> | |
2446 | 19 #include <stdlib.h> |
2244 | 20 #include <string.h> |
21 #include <stddef.h> | |
22 #include <limits.h> | |
23 | |
24 #include "config.h" | |
25 #include "video_out.h" | |
26 #include "video_out_internal.h" | |
27 | |
2537 | 28 #ifdef HAVE_MEMALIGN |
29 #include <malloc.h> | |
30 #endif | |
31 | |
2244 | 32 #include "fastmemcpy.h" |
33 #include "yuv2rgb.h" | |
2337 | 34 #include "sub.h" |
2244 | 35 #include "linux/vbelib.h" |
36 #include "bswap.h" | |
37 | |
2298 | 38 #include "../postproc/swscale.h" |
2504 | 39 #include "../postproc/rgb2rgb.h" |
2298 | 40 |
2244 | 41 LIBVO_EXTERN(vesa) |
42 extern int verbose; | |
43 | |
2649 | 44 #define MAX_BUFFERS 3 |
45 | |
2244 | 46 #ifndef max |
47 #define max(a,b) ((a)>(b)?(a):(b)) | |
48 #endif | |
49 #ifndef min | |
50 #define min(a,b) ((a)<(b)?(a):(b)) | |
51 #endif | |
52 | |
2688 | 53 #define UNUSED(x) ((void)(x)) /**< Removes warning about unused arguments */ |
2244 | 54 |
55 static vo_info_t vo_info = | |
56 { | |
57 "VESA VBE 2.0 video output", | |
58 "vesa", | |
59 "Nick Kurshev <nickols_k@mail.ru>", | |
60 "Requires ROOT privileges" | |
61 }; | |
62 | |
63 /* driver data */ | |
64 | |
65 struct win_frame | |
66 { | |
67 uint8_t *ptr; /* pointer to window's frame memory */ | |
68 uint32_t low; /* lowest boundary of frame */ | |
69 uint32_t high; /* highest boundary of frame */ | |
2610 | 70 char idx; /* indicates index of relocatable frame (A=0 or B=1) |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
71 special case for DGA: idx=-1 |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
72 idx=-2 indicates invalid frame, exists only in init() */ |
2244 | 73 }; |
74 | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
75 static void (*cpy_blk_fnc)(unsigned long,uint8_t *,unsigned long) = NULL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
76 |
2298 | 77 static int vesa_zoom=0; /* software scaling */ |
78 static unsigned int scale_xinc=0; | |
79 static unsigned int scale_yinc=0; | |
80 | |
2504 | 81 static uint32_t image_bpp,image_width, image_height; /* source image dimension */ |
2329 | 82 static int32_t x_offset,y_offset; /* to center image on screen */ |
2244 | 83 static unsigned init_mode; /* mode before run of mplayer */ |
84 static void *init_state = NULL; /* state before run of mplayer */ | |
85 static struct win_frame win; /* real-mode window to video memory */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
86 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */ |
2244 | 87 static unsigned video_mode; /* selected video mode for playback */ |
88 static struct VesaModeInfoBlock video_mode_info; | |
2331 | 89 static int flip_trigger = 0; |
2337 | 90 static void (*draw_alpha_fnc)(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride); |
2676 | 91 static void (*rgb2rgb_fnc)(const uint8_t *src,uint8_t *dst,uint32_t src_size); |
2244 | 92 |
2649 | 93 /* multibuffering */ |
94 uint8_t* video_base; /* should be never changed */ | |
95 uint32_t multi_buff[MAX_BUFFERS]; /* contains offsets of buffers */ | |
96 uint8_t multi_size=0; /* total number of buffers */ | |
97 uint8_t multi_idx=0; /* active buffer */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
98 |
2649 | 99 #define HAS_DGA() (win.idx == -1) |
2244 | 100 #define MOVIE_MODE (MODE_ATTR_COLOR | MODE_ATTR_GRAPHICS) |
2649 | 101 #define FRAME_MODE (MODE_WIN_RELOCATABLE | MODE_WIN_WRITEABLE) |
102 | |
2244 | 103 static char * vbeErrToStr(int err) |
104 { | |
105 char *retval; | |
106 static char sbuff[80]; | |
107 if((err & VBE_VESA_ERROR_MASK) == VBE_VESA_ERROR_MASK) | |
108 { | |
2255 | 109 sprintf(sbuff,"VESA failed = 0x4f%x",(err & VBE_VESA_ERRCODE_MASK)>>8); |
2244 | 110 retval = sbuff; |
111 } | |
112 else | |
113 switch(err) | |
114 { | |
115 case VBE_OK: retval = "No error"; break; | |
116 case VBE_VM86_FAIL: retval = "vm86() syscall failed"; break; | |
117 case VBE_OUT_OF_DOS_MEM: retval = "Out of DOS memory"; break; | |
118 case VBE_OUT_OF_MEM: retval = "Out of memory"; break; | |
2360 | 119 case VBE_BROKEN_BIOS: retval = "Broken BIOS or DOS TSR"; break; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
120 default: sprintf(sbuff,"Unknown or internal error: %i",err); retval=sbuff; break; |
2244 | 121 } |
122 return retval; | |
123 } | |
124 | |
125 #define PRINT_VBE_ERR(name,err) { printf("vo_vesa: %s returns: %s\n",name,vbeErrToStr(err)); fflush(stdout); } | |
126 | |
127 static void vesa_term( void ) | |
128 { | |
129 int err; | |
130 if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err); | |
131 if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
132 if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
133 if(dga_buffer && !HAS_DGA()) free(dga_buffer); |
2244 | 134 vbeDestroy(); |
135 } | |
136 | |
137 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high) | |
138 #define VIDEO_PTR(offset) (win.ptr + offset - win.low) | |
139 | |
140 static inline void __vbeSwitchBank(unsigned long offset) | |
141 { | |
142 unsigned long gran; | |
143 unsigned new_offset; | |
144 int err; | |
145 gran = video_mode_info.WinGranularity*1024; | |
146 new_offset = offset / gran; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
147 if(HAS_DGA()) { err = -1; goto show_err; } |
2244 | 148 if((err=vbeSetWindow(win.idx,new_offset)) != VBE_OK) |
149 { | |
2610 | 150 show_err: |
2686 | 151 vesa_term(); |
2244 | 152 PRINT_VBE_ERR("vbeSetWindow",err); |
153 printf("vo_vesa: Fatal error occured! Can't continue\n"); | |
154 exit(-1); | |
155 } | |
156 win.low = new_offset * gran; | |
157 win.high = win.low + video_mode_info.WinSize*1024; | |
158 } | |
159 | |
160 static void __vbeSetPixel(int x, int y, int r, int g, int b) | |
161 { | |
162 int x_res = video_mode_info.XResolution; | |
163 int y_res = video_mode_info.YResolution; | |
164 int shift_r = video_mode_info.RedFieldPosition; | |
165 int shift_g = video_mode_info.GreenFieldPosition; | |
166 int shift_b = video_mode_info.BlueFieldPosition; | |
167 int pixel_size = (video_mode_info.BitsPerPixel+7)/8; | |
168 int bpl = video_mode_info.BytesPerScanLine; | |
2676 | 169 int color; |
170 unsigned offset; | |
2244 | 171 |
172 if (x < 0 || x >= x_res || y < 0 || y >= y_res) return; | |
173 r >>= 8 - video_mode_info.RedMaskSize; | |
174 g >>= 8 - video_mode_info.GreenMaskSize; | |
175 b >>= 8 - video_mode_info.BlueMaskSize; | |
176 color = (r << shift_r) | (g << shift_g) | (b << shift_b); | |
177 offset = y * bpl + (x * pixel_size); | |
178 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | |
179 memcpy(VIDEO_PTR(offset), &color, pixel_size); | |
180 } | |
181 | |
182 /* | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
183 Copies part of frame to video memory. Data should be in the same format |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
184 as video memory. |
2244 | 185 */ |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
186 static void __vbeCopyBlockFast(unsigned long offset,uint8_t *image,unsigned long size) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
187 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
188 memcpy(&win.ptr[offset],image,size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
189 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
190 |
2244 | 191 static void __vbeCopyBlock(unsigned long offset,uint8_t *image,unsigned long size) |
192 { | |
193 unsigned long delta,src_idx = 0; | |
194 while(size) | |
195 { | |
196 if(!VALID_WIN_FRAME(offset)) __vbeSwitchBank(offset); | |
197 delta = min(size,win.high - offset); | |
198 memcpy(VIDEO_PTR(offset),&image[src_idx],delta); | |
199 src_idx += delta; | |
200 offset += delta; | |
201 size -= delta; | |
202 } | |
203 } | |
204 | |
205 /* | |
206 Copies frame to video memory. Data should be in the same format as video | |
207 memory. | |
208 */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
209 |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
210 #define PIXEL_SIZE() ((video_mode_info.BitsPerPixel+7)/8) |
2676 | 211 #define SCREEN_LINE_SIZE(pixel_size) (video_mode_info.XResolution*(pixel_size) ) |
212 #define IMAGE_LINE_SIZE(pixel_size) (image_width*(pixel_size)) | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
213 |
2244 | 214 static void __vbeCopyData(uint8_t *image) |
215 { | |
2308 | 216 unsigned long i,j,image_offset,offset; |
2244 | 217 unsigned pixel_size,image_line_size,screen_line_size,x_shift; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
218 pixel_size = PIXEL_SIZE(); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
219 screen_line_size = SCREEN_LINE_SIZE(pixel_size); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
220 image_line_size = IMAGE_LINE_SIZE(pixel_size); |
2306 | 221 if(image_width == video_mode_info.XResolution) |
222 { | |
223 /* Special case for zooming */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
224 (*cpy_blk_fnc)(y_offset*screen_line_size,image,image_line_size*image_height); |
2306 | 225 } |
226 else | |
2244 | 227 { |
2306 | 228 x_shift = x_offset*pixel_size; |
2308 | 229 for(j=0,i=y_offset;j<image_height;i++,j++) |
2306 | 230 { |
231 offset = i*screen_line_size+x_shift; | |
232 image_offset = j*image_line_size; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
233 (*cpy_blk_fnc)(offset,&image[image_offset],image_line_size); |
2306 | 234 } |
2244 | 235 } |
236 } | |
2328 | 237 |
2244 | 238 /* is called for yuv only */ |
239 static uint32_t draw_slice(uint8_t *image[], int stride[], int w,int h,int x,int y) | |
240 { | |
2504 | 241 if(verbose > 2) |
242 printf("vo_vesa: draw_slice was called: w=%u h=%u x=%u y=%u\n",w,h,x,y); | |
2298 | 243 if(vesa_zoom) |
244 { | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
245 uint8_t *dst[3]= {dga_buffer, NULL, NULL}; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
246 int dst_stride; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
247 if(HAS_DGA()) dst[0] += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
248 dst_stride = PIXEL_SIZE()*(HAS_DGA()?video_mode_info.XResolution:image_width); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
249 SwScale_YV12slice(image,stride,y,h,dst,dst_stride, |
2298 | 250 image_width, video_mode_info.BitsPerPixel, |
251 scale_xinc, scale_yinc); | |
252 } | |
253 else | |
254 { | |
2331 | 255 uint8_t *yuv_slice; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
256 int rgb_stride; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
257 yuv_slice=dga_buffer; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
258 if(HAS_DGA()) yuv_slice += y_offset*SCREEN_LINE_SIZE(PIXEL_SIZE())+x_offset*PIXEL_SIZE(); |
2636 | 259 rgb_stride = HAS_DGA()?video_mode_info.XResolution:image_width; |
260 yuv_slice+=(rgb_stride*y+x)*PIXEL_SIZE(); | |
261 rgb_stride *= PIXEL_SIZE(); | |
2331 | 262 yuv2rgb(yuv_slice, image[0], image[1], image[2], w, h, |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
263 rgb_stride, stride[0], stride[1]); |
2298 | 264 } |
2331 | 265 flip_trigger = 1; |
2298 | 266 return 0; |
2244 | 267 } |
268 | |
2649 | 269 static void draw_alpha_32(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
270 { | |
271 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
272 vo_draw_alpha_rgb32(w,h,src,srca,stride,dga_buffer+4*(y0*dstride+x0),4*dstride); | |
2337 | 273 } |
274 | |
2649 | 275 static void draw_alpha_24(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
276 { | |
277 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
278 vo_draw_alpha_rgb24(w,h,src,srca,stride,dga_buffer+3*(y0*dstride+x0),3*dstride); | |
2337 | 279 } |
280 | |
2649 | 281 static void draw_alpha_16(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
282 { | |
283 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
284 vo_draw_alpha_rgb16(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); | |
2337 | 285 } |
286 | |
2649 | 287 static void draw_alpha_15(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
288 { | |
289 unsigned int dstride=HAS_DGA()?video_mode_info.XResolution:image_width; | |
290 vo_draw_alpha_rgb15(w,h,src,srca,stride,dga_buffer+2*(y0*dstride+x0),2*dstride); | |
2337 | 291 } |
292 | |
2649 | 293 static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsigned char *srca, int stride) |
294 { | |
2688 | 295 UNUSED(x0); |
296 UNUSED(y0); | |
297 UNUSED(w); | |
298 UNUSED(h); | |
299 UNUSED(src); | |
300 UNUSED(srca); | |
301 UNUSED(stride); | |
2337 | 302 } |
303 | |
304 | |
2244 | 305 static void draw_osd(void) |
306 { | |
2649 | 307 uint32_t w,h; |
2504 | 308 if(verbose > 2) |
309 printf("vo_vesa: draw_osd was called\n"); | |
2649 | 310 w = HAS_DGA()?video_mode_info.XResolution:image_width; |
311 h = HAS_DGA()?video_mode_info.YResolution:image_height; | |
312 if(dga_buffer) vo_draw_text(w,h,draw_alpha_fnc); | |
2244 | 313 } |
314 | |
315 static void flip_page(void) | |
316 { | |
2504 | 317 if(verbose > 2) |
318 printf("vo_vesa: flip_page was called\n"); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
319 if(flip_trigger) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
320 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
321 if(!HAS_DGA()) __vbeCopyData(dga_buffer); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
322 flip_trigger = 0; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
323 } |
2649 | 324 if(vo_doublebuffering && multi_size > 1) |
325 { | |
2686 | 326 int err; |
327 if((err=vbeSetDisplayStart(multi_buff[multi_idx],1)) != VBE_OK) | |
328 { | |
329 vesa_term(); | |
330 PRINT_VBE_ERR("vbeSetDispayStart",err); | |
331 printf("vo_vesa: Fatal error occured! Can't continue\n"); | |
332 exit(EXIT_FAILURE); | |
333 } | |
334 multi_idx = multi_idx ? 0 : 1; | |
335 win.ptr = dga_buffer = video_base + multi_buff[multi_idx]; | |
2649 | 336 } |
337 /* | |
338 else | |
339 if(tripple_buffering) | |
340 { | |
341 vbeSetScheduledDisplayStart(multi_buffer[multi_idx],1); | |
342 multi_idx++; | |
343 if(multi_idx > 2) multi_idx = 0; | |
344 win.ptr = dga_buffer = video_base + multi_buffer[multi_idx]; | |
345 } | |
346 */ | |
2244 | 347 } |
348 | |
349 /* is called for rgb only */ | |
350 static uint32_t draw_frame(uint8_t *src[]) | |
351 { | |
2649 | 352 uint8_t *data = src[0]; |
2504 | 353 if(verbose > 2) |
354 printf("vo_vesa: draw_frame was called\n"); | |
355 if(rgb2rgb_fnc) | |
356 { | |
2649 | 357 if(HAS_DGA()) |
358 { | |
359 size_t i, psize, ssize, dsize; | |
2676 | 360 uint8_t *dest; |
361 const uint8_t *sptr; | |
2649 | 362 psize = PIXEL_SIZE(); |
363 dsize = SCREEN_LINE_SIZE(psize); | |
2676 | 364 ssize = IMAGE_LINE_SIZE((image_bpp+7)/8); |
365 dest = dga_buffer + y_offset*dsize + x_offset*psize; | |
2649 | 366 sptr = src[0]; |
367 for(i=0;i<image_height;i++) | |
368 { | |
369 (*rgb2rgb_fnc)(sptr,dest,ssize); | |
370 sptr += ssize; | |
371 dest += dsize; | |
372 } | |
373 } | |
374 else | |
375 { | |
376 (*rgb2rgb_fnc)(src[0],dga_buffer,image_width*image_height*image_bpp); | |
377 data = dga_buffer; | |
378 } | |
2504 | 379 if(verbose > 2) |
380 printf("vo_vesa: rgb2rgb_fnc was called\n"); | |
381 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
382 if(!rgb2rgb_fnc || !HAS_DGA()) __vbeCopyData(data); |
2504 | 383 return 0; |
2244 | 384 } |
385 | |
386 static uint32_t query_format(uint32_t format) | |
387 { | |
388 uint32_t retval; | |
2504 | 389 if(verbose > 2) |
390 printf("vo_vesa: query_format was called: %x (%s)\n",format,vo_format_name(format)); | |
2244 | 391 switch(format) |
392 { | |
393 case IMGFMT_YV12: | |
2637 | 394 #if 0 /* Should be tested better */ |
2244 | 395 case IMGFMT_I420: |
396 case IMGFMT_IYUV: | |
397 #endif | |
398 case IMGFMT_RGB8: | |
399 case IMGFMT_RGB15: | |
400 case IMGFMT_RGB16: | |
401 case IMGFMT_RGB24: | |
402 case IMGFMT_RGB32: | |
403 case IMGFMT_BGR8: | |
404 case IMGFMT_BGR15: | |
405 case IMGFMT_BGR16: | |
406 case IMGFMT_BGR24: | |
407 case IMGFMT_BGR32: | |
408 retval = 1; break; | |
409 default: | |
410 if(verbose) | |
411 printf("vo_vesa: unknown format: %x = %s\n",format,vo_format_name(format)); | |
412 retval = 0; | |
413 } | |
414 return retval; | |
415 } | |
416 | |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
417 static void vesa_aspect(uint32_t width,uint32_t height, |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
418 uint32_t xres,uint32_t yres, |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
419 uint32_t *image_width,uint32_t *image_height) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
420 { |
2331 | 421 float aspect_factor; |
2328 | 422 aspect_factor = (float)width / height; |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
423 *image_width = xres; |
2328 | 424 *image_height = xres /aspect_factor; |
425 if(verbose) printf("vo_vesa: aspect factor = %f(%ux%u) *image=%ux%u screen=%ux%u\n",aspect_factor,width,height,*image_width,*image_height,xres,yres); | |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
426 if((*image_height) > yres) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
427 { |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
428 *image_height = yres; |
2328 | 429 *image_width = yres * aspect_factor; |
2329 | 430 if(verbose) printf("vo_vesa: Y > X therefore *image=%ux%u\n",*image_width,*image_height); |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
431 } |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
432 } |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
433 |
2686 | 434 static void paintBkGnd( void ) |
435 { | |
436 int x_res = video_mode_info.XResolution; | |
437 int y_res = video_mode_info.YResolution; | |
438 int x, y; | |
439 | |
440 for (y = 0; y < y_res; ++y) | |
441 { | |
442 for (x = 0; x < x_res; ++x) | |
443 { | |
444 int r, g, b; | |
445 if ((x & 16) ^ (y & 16)) | |
446 { | |
447 r = x * 255 / x_res; | |
448 g = y * 255 / y_res; | |
449 b = 255 - x * 255 / x_res; | |
450 } | |
451 else | |
452 { | |
453 r = 255 - x * 255 / x_res; | |
454 g = y * 255 / y_res; | |
455 b = 255 - y * 255 / y_res; | |
456 } | |
457 __vbeSetPixel(x, y, r, g, b); | |
458 } | |
459 } | |
460 } | |
461 | |
2293 | 462 static char *model2str(unsigned char type) |
463 { | |
464 char *retval; | |
465 switch(type) | |
466 { | |
467 case memText: retval = "Text"; break; | |
468 case memCGA: retval="CGA"; break; | |
469 case memHercules: retval="Hercules"; break; | |
470 case memPL: retval="Planar"; break; | |
471 case memPK: retval="Packed pixel"; break; | |
472 case mem256: retval="256"; break; | |
473 case memRGB: retval="Direct color RGB"; break; | |
474 case memYUV: retval="Direct color YUV"; break; | |
475 default: retval="Unknown"; break; | |
476 } | |
477 return retval; | |
478 } | |
479 | |
2649 | 480 unsigned fillMultiBuffer( unsigned long vsize, unsigned nbuffs ) |
481 { | |
482 unsigned long screen_size, offset; | |
483 unsigned total,i; | |
484 screen_size = video_mode_info.XResolution*video_mode_info.YResolution*((video_mode_info.BitsPerPixel+7)/8); | |
485 if(screen_size%64) screen_size=((screen_size/64)*64)+64; | |
486 total = vsize / screen_size; | |
487 if(verbose) printf("vo_vesa: Can use %u video buffers\n",total); | |
488 i = 0; | |
489 offset = 0; | |
490 total = min(total,nbuffs); | |
491 while(i < total) { multi_buff[i++] = offset; offset += screen_size; } | |
492 if(!i) | |
493 printf("vo_vesa: Your have too small size of video memory for this mode:\n" | |
494 "vo_vesa: Requires: %08lX exists: %08lX\n", screen_size, vsize); | |
495 return i; | |
496 } | |
497 | |
498 #define SUBDEV_NODGA 0x00000001UL | |
499 #define SUBDEV_FORCEDGA 0x00000002UL | |
500 uint32_t parseSubDevice(const char *sd) | |
501 { | |
502 uint32_t flags; | |
503 flags = 0; | |
504 if(strcmp(sd,"nodga") == 0) { flags |= SUBDEV_NODGA; flags &= ~(SUBDEV_FORCEDGA); } | |
505 else | |
506 if(strcmp(sd,"dga") == 0) { flags &= ~(SUBDEV_NODGA); flags |= SUBDEV_FORCEDGA; } | |
507 else if(verbose) printf("vo_vesa: Unknown subcommand: %s\n", sd); | |
508 return flags; | |
509 } | |
510 | |
2244 | 511 /* fullscreen: |
512 * bit 0 (0x01) means fullscreen (-fs) | |
513 * bit 1 (0x02) means mode switching (-vm) | |
514 * bit 2 (0x04) enables software scaling (-zoom) | |
2335 | 515 * bit 3 (0x08) enables flipping (-flip) (NK: and for what?) |
2244 | 516 */ |
517 static uint32_t | |
2329 | 518 init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) |
2244 | 519 { |
520 struct VbeInfoBlock vib; | |
521 struct VesaModeInfoBlock vmib; | |
522 size_t i,num_modes; | |
2649 | 523 uint32_t w,h, sd_flags; |
2244 | 524 unsigned short *mode_ptr,win_seg; |
525 unsigned bpp,best_x = UINT_MAX,best_y=UINT_MAX,best_mode_idx = UINT_MAX; | |
2337 | 526 int err,fs_mode,yuv_fmt; |
2244 | 527 image_width = width; |
528 image_height = height; | |
2336 | 529 fs_mode = 0; |
2504 | 530 rgb2rgb_fnc = NULL; |
2649 | 531 sd_flags = 0; |
532 if(vo_subdevice) sd_flags = parseSubDevice(vo_subdevice); | |
2329 | 533 if(flags & 0x8) |
2244 | 534 { |
2329 | 535 printf("vo_vesa: switch -flip is not supported\n"); |
2244 | 536 } |
2329 | 537 if(flags & 0x04) vesa_zoom = 1; |
2336 | 538 if(flags & 0x01) |
539 { | |
540 if(vesa_zoom) vesa_zoom = 2; | |
541 else fs_mode = 1; | |
542 } | |
2244 | 543 if((err=vbeInit()) != VBE_OK) { PRINT_VBE_ERR("vbeInit",err); return -1; } |
544 memcpy(vib.VESASignature,"VBE2",4); | |
545 if((err=vbeGetControllerInfo(&vib)) != VBE_OK) | |
546 { | |
547 PRINT_VBE_ERR("vbeGetControllerInfo",err); | |
548 printf("vo_vesa: possible reason: No VBE2 BIOS found\n"); | |
549 return -1; | |
550 } | |
551 /* Print general info here */ | |
552 printf("vo_vesa: Found VESA VBE BIOS Version %x.%x Revision: %x\n", | |
553 (int)(vib.VESAVersion >> 8) & 0xff, | |
554 (int)(vib.VESAVersion & 0xff), | |
555 (int)(vib.OemSoftwareRev & 0xffff)); | |
2255 | 556 printf("vo_vesa: Video memory: %u Kb\n",vib.TotalMemory*64); |
557 printf("vo_vesa: VESA Capabilities: %s %s %s %s %s\n" | |
558 ,vib.Capabilities & VBE_DAC_8BIT ? "8-bit DAC," : "6-bit DAC," | |
559 ,vib.Capabilities & VBE_NONVGA_CRTC ? "non-VGA CRTC,":"VGA CRTC," | |
560 ,vib.Capabilities & VBE_SNOWED_RAMDAC ? "snowed RAMDAC,":"normal RAMDAC," | |
561 ,vib.Capabilities & VBE_STEREOSCOPIC ? "stereoscopic,":"no stereoscopic," | |
562 ,vib.Capabilities & VBE_STEREO_EVC ? "Stereo EVC":"no stereo"); | |
563 printf("vo_vesa: !!! Below will be printed OEM info. !!!\n"); | |
564 printf("vo_vesa: You should watch 5 OEM related lines below else you've broken vm86\n"); | |
2244 | 565 printf("vo_vesa: OEM info: %s\n",vib.OemStringPtr); |
2255 | 566 printf("vo_vesa: OEM Revision: %x\n",vib.OemSoftwareRev); |
567 printf("vo_vesa: OEM vendor: %s\n",vib.OemVendorNamePtr); | |
568 printf("vo_vesa: OEM Product Name: %s\n",vib.OemProductNamePtr); | |
569 printf("vo_vesa: OEM Product Rev: %s\n",vib.OemProductRevPtr); | |
570 printf("vo_vesa: Hint: To get workable TV-Out you should have plugged tv-connector in\n" | |
571 "vo_vesa: before booting PC since VESA BIOS initializes itself only during POST\n"); | |
2244 | 572 /* Find best mode here */ |
573 num_modes = 0; | |
574 mode_ptr = vib.VideoModePtr; | |
575 while(*mode_ptr++ != 0xffff) num_modes++; | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
576 yuv_fmt = 0; |
2244 | 577 switch(format) |
578 { | |
579 case IMGFMT_BGR8: | |
580 case IMGFMT_RGB8: bpp = 8; break; | |
581 case IMGFMT_BGR15: | |
582 case IMGFMT_RGB15: bpp = 15; break; | |
583 case IMGFMT_YV12: | |
584 case IMGFMT_I420: | |
2553 | 585 case IMGFMT_IYUV: yuv_fmt = 1; |
586 default: | |
2244 | 587 case IMGFMT_BGR16: |
588 case IMGFMT_RGB16: bpp = 16; break; | |
589 case IMGFMT_BGR24: | |
590 case IMGFMT_RGB24: bpp = 24; break; | |
591 case IMGFMT_BGR32: | |
592 case IMGFMT_RGB32: bpp = 32; break; | |
593 } | |
2504 | 594 image_bpp = bpp; |
595 if(vo_dbpp) bpp = vo_dbpp; | |
596 if(yuv_fmt) yuv2rgb_init(bpp, MODE_RGB); | |
2337 | 597 switch(bpp) |
598 { | |
599 case 15: draw_alpha_fnc = draw_alpha_15; break; | |
600 case 16: draw_alpha_fnc = draw_alpha_16; break; | |
601 case 24: draw_alpha_fnc = draw_alpha_24; break; | |
602 case 32: draw_alpha_fnc = draw_alpha_32; break; | |
603 default: draw_alpha_fnc = draw_alpha_null; break; | |
604 } | |
2244 | 605 if(verbose) |
606 { | |
2304 | 607 printf("vo_vesa: Requested mode: %ux%u@%u (%s)\n",width,height,bpp,vo_format_name(format)); |
2244 | 608 printf("vo_vesa: Total modes found: %u\n",num_modes); |
609 mode_ptr = vib.VideoModePtr; | |
610 printf("vo_vesa: Mode list:"); | |
611 for(i = 0;i < num_modes;i++) | |
612 { | |
613 printf(" %04X",mode_ptr[i]); | |
614 } | |
615 printf("\nvo_vesa: Modes in detail:\n"); | |
616 } | |
617 mode_ptr = vib.VideoModePtr; | |
2335 | 618 if(vesa_zoom) |
619 { | |
620 image_width = d_width; | |
621 image_height= d_height; | |
622 } | |
623 if(vo_screenwidth) w = vo_screenwidth; | |
624 else w = max(image_width,width); | |
625 if(vo_screenheight) h = vo_screenheight; | |
626 else h = max(image_height,height); | |
2244 | 627 for(i=0;i < num_modes;i++) |
628 { | |
629 if((err=vbeGetModeInfo(mode_ptr[i],&vmib)) != VBE_OK) | |
630 { | |
631 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
632 return -1; | |
633 } | |
2329 | 634 if(vmib.XResolution >= w && |
635 vmib.YResolution >= h && | |
2244 | 636 (vmib.ModeAttributes & MOVIE_MODE) == MOVIE_MODE && |
637 vmib.BitsPerPixel == bpp && | |
638 vmib.MemoryModel == memRGB) | |
639 { | |
2293 | 640 if(vmib.XResolution <= best_x && |
641 vmib.YResolution <= best_y) | |
2244 | 642 { |
643 best_x = vmib.XResolution; | |
644 best_y = vmib.YResolution; | |
645 best_mode_idx = i; | |
646 } | |
647 } | |
648 if(verbose) | |
649 { | |
2298 | 650 printf("vo_vesa: Mode (%03u): mode=%04X %ux%u@%u attr=%04X\n" |
2293 | 651 "vo_vesa: #planes=%u model=%u(%s) #pages=%u\n" |
652 "vo_vesa: winA=%X(attr=%u) winB=%X(attr=%u) winSize=%u winGran=%u\n" | |
2446 | 653 "vo_vesa: direct_color=%u DGA_phys_addr=%08lX\n" |
2244 | 654 ,i,mode_ptr[i],vmib.XResolution,vmib.YResolution,vmib.BitsPerPixel,vmib.ModeAttributes |
2293 | 655 ,vmib.NumberOfPlanes,vmib.MemoryModel,model2str(vmib.MemoryModel),vmib.NumberOfImagePages |
2244 | 656 ,vmib.WinASegment,vmib.WinAAttributes,vmib.WinBSegment,vmib.WinBAttributes,vmib.WinSize,vmib.WinGranularity |
657 ,vmib.DirectColorModeInfo,vmib.PhysBasePtr); | |
658 if(vmib.MemoryModel == 6 || vmib.MemoryModel == 7) | |
659 printf("vo_vesa: direct_color_info = %u:%u:%u:%u\n" | |
660 ,vmib.RedMaskSize,vmib.GreenMaskSize,vmib.BlueMaskSize,vmib.RsvdMaskSize); | |
661 fflush(stdout); | |
662 } | |
663 } | |
664 if(best_mode_idx != UINT_MAX) | |
665 { | |
666 video_mode = vib.VideoModePtr[best_mode_idx]; | |
667 fflush(stdout); | |
668 if((err=vbeGetMode(&init_mode)) != VBE_OK) | |
669 { | |
670 PRINT_VBE_ERR("vbeGetMode",err); | |
671 return -1; | |
672 } | |
673 if(verbose) printf("vo_vesa: Initial video mode: %x\n",init_mode); | |
674 if((err=vbeGetModeInfo(video_mode,&video_mode_info)) != VBE_OK) | |
675 { | |
676 PRINT_VBE_ERR("vbeGetModeInfo",err); | |
677 return -1; | |
678 } | |
2329 | 679 printf("vo_vesa: Using VESA mode (%u) = %x [%ux%u@%u]\n" |
680 ,best_mode_idx,video_mode,video_mode_info.XResolution | |
681 ,video_mode_info.YResolution,video_mode_info.BitsPerPixel); | |
2649 | 682 if(sd_flags & SUBDEV_NODGA) video_mode_info.PhysBasePtr = 0; |
2336 | 683 if( vesa_zoom || fs_mode ) |
2298 | 684 { |
2304 | 685 if( format==IMGFMT_YV12 ) |
686 { | |
687 /* software scale */ | |
2329 | 688 if(vesa_zoom > 1) |
2335 | 689 vesa_aspect(image_width,image_height, |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
690 video_mode_info.XResolution,video_mode_info.YResolution, |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
691 &image_width,&image_height); |
2336 | 692 else |
693 if(fs_mode) | |
694 { | |
695 image_width = video_mode_info.XResolution; | |
696 image_height = video_mode_info.YResolution; | |
697 vesa_zoom = 1; | |
698 } | |
2304 | 699 scale_xinc=(width << 16) / image_width - 2; /* needed for proper rounding */ |
700 scale_yinc=(height << 16) / image_height + 2; | |
701 SwScale_Init(); | |
702 if(verbose) printf("vo_vesa: Using SCALE\n"); | |
703 } | |
704 else | |
705 { | |
706 printf("vo_vesa: Can't apply zooming to non YV12 formats\n"); | |
707 return -1; | |
708 } | |
2298 | 709 } |
2504 | 710 if(format != IMGFMT_YV12 && image_bpp != video_mode_info.BitsPerPixel) |
711 { | |
712 if(image_bpp == 24 && video_mode_info.BitsPerPixel == 32) rgb2rgb_fnc = rgb24to32; | |
713 else | |
2505 | 714 if(image_bpp == 32 && video_mode_info.BitsPerPixel == 24) rgb2rgb_fnc = rgb32to24; |
715 else | |
2506 | 716 if(image_bpp == 15 && video_mode_info.BitsPerPixel == 16) rgb2rgb_fnc = rgb15to16; |
717 else | |
2504 | 718 { |
719 printf("vo_vesa: Can't convert %u to %u\n",image_bpp,video_mode_info.BitsPerPixel); | |
720 return -1; | |
721 } | |
2554 | 722 printf("vo_vesa: using %u-bpp to %u-bpp sw convertor\n",image_bpp,video_mode_info.BitsPerPixel); |
2504 | 723 } |
2244 | 724 if((video_mode_info.WinAAttributes & FRAME_MODE) == FRAME_MODE) |
725 win.idx = 0; /* frame A */ | |
726 else | |
727 if((video_mode_info.WinBAttributes & FRAME_MODE) == FRAME_MODE) | |
728 win.idx = 1; /* frame B */ | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
729 else win.idx = -2; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
730 /* Try use DGA instead */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
731 if(video_mode_info.PhysBasePtr && vib.TotalMemory && (video_mode_info.ModeAttributes & MODE_ATTR_LINEAR)) |
2244 | 732 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
733 void *lfb; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
734 unsigned long vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
735 vsize = vib.TotalMemory*64*1024; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
736 lfb = vbeMapVideoBuffer(video_mode_info.PhysBasePtr,vsize); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
737 if(lfb == NULL) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
738 printf("vo_vesa: Can't use DGA. Force bank switching mode. :(\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
739 else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
740 { |
2649 | 741 video_base = win.ptr = lfb; |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
742 win.low = 0UL; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
743 win.high = vsize; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
744 win.idx = -1; /* HAS_DGA() is on */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
745 video_mode |= VESA_MODE_USE_LINEAR; |
2649 | 746 printf("vo_vesa: Using DGA (physical resources: %08lXh, %08lXh)" |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
747 ,video_mode_info.PhysBasePtr |
2649 | 748 ,vsize); |
749 if(verbose) printf(" at %08lXh",(unsigned long)lfb); | |
750 printf("\n"); | |
751 if(!(multi_size = fillMultiBuffer(vsize,2))) return -1; | |
752 if(vo_doublebuffering && multi_size < 2) | |
753 printf("vo_vesa: Can't use double buffering: not enough video memory\n"); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
754 } |
2244 | 755 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
756 if(win.idx == -2) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
757 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
758 printf("vo_vesa: Can't find neither DGA nor relocatable window's frame.\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
759 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
760 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
761 if(!HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
762 { |
2649 | 763 if(sd_flags & SUBDEV_FORCEDGA) |
764 { | |
765 printf("vo_vesa: you've forced DGA. Exiting\n"); | |
766 return -1; | |
767 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
768 if(!(win_seg = win.idx == 0 ? video_mode_info.WinASegment:video_mode_info.WinBSegment)) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
769 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
770 printf("vo_vesa: Can't find valid window address\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
771 return -1; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
772 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
773 win.ptr = PhysToVirtSO(win_seg,0); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
774 win.low = 0L; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
775 win.high= video_mode_info.WinSize*1024; |
2649 | 776 printf("vo_vesa: Using bank switching mode (physical resources: %08lXh, %08lXh)\n" |
777 ,(unsigned long)win.ptr,(unsigned long)win.high); | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
778 } |
2329 | 779 if(video_mode_info.XResolution > image_width) |
780 x_offset = (video_mode_info.XResolution - image_width) / 2; | |
781 else x_offset = 0; | |
782 if(video_mode_info.YResolution > image_height) | |
783 y_offset = (video_mode_info.YResolution - image_height) / 2; | |
784 else y_offset = 0; | |
2305
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
785 if(verbose) |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
786 printf("vo_vesa: image: %ux%u screen = %ux%u x_offset = %u y_offset = %u\n" |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
787 ,image_width,image_height |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
788 ,video_mode_info.XResolution,video_mode_info.YResolution |
82c17b134946
Fixed half-image bug and added computing of correct aspect during zooming
nick
parents:
2304
diff
changeset
|
789 ,x_offset,y_offset); |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
790 if(HAS_DGA()) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
791 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
792 dga_buffer = win.ptr; /* Trickly ;) */ |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
793 cpy_blk_fnc = __vbeCopyBlockFast; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
794 } |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
795 else |
2610 | 796 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
797 cpy_blk_fnc = __vbeCopyBlock; |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
798 if(yuv_fmt || rgb2rgb_fnc) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
799 { |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
800 #ifdef HAVE_MEMALIGN |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
801 if(!(dga_buffer = memalign(64,video_mode_info.XResolution*video_mode_info.YResolution*video_mode_info.BitsPerPixel))) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
802 #else |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
803 if(!(dga_buffer = malloc(video_mode_info.XResolution*video_mode_info.YResolution*video_mode_info.BitsPerPixel))) |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
804 #endif |
2610 | 805 { |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
806 printf("vo_vesa: Can't allocate temporary buffer\n"); |
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
807 return -1; |
2610 | 808 } |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
809 if(verbose) printf("vo_vesa: dga emulator was allocated = %p\n",dga_buffer); |
2337 | 810 } |
2504 | 811 } |
2244 | 812 if((err=vbeSaveState(&init_state)) != VBE_OK) |
813 { | |
814 PRINT_VBE_ERR("vbeSaveState",err); | |
815 return -1; | |
816 } | |
817 if((err=vbeSetMode(video_mode,NULL)) != VBE_OK) | |
818 { | |
819 PRINT_VBE_ERR("vbeSetMode",err); | |
820 return -1; | |
821 } | |
822 /* Now we are in video mode!!!*/ | |
2337 | 823 /* Below 'return -1' is impossible */ |
2244 | 824 if(verbose) |
825 { | |
826 printf("vo_vesa: Graphics mode was activated\n"); | |
827 fflush(stdout); | |
828 } | |
829 } | |
830 else | |
831 { | |
2255 | 832 printf("vo_vesa: Can't find mode for: %ux%u@%u\n",width,height,bpp); |
2244 | 833 return -1; |
834 } | |
835 if(verbose) | |
836 { | |
837 printf("vo_vesa: VESA initialization complete\n"); | |
838 fflush(stdout); | |
839 } | |
2688 | 840 if(HAS_DGA() && vo_doublebuffering) |
2244 | 841 { |
2686 | 842 for(i=0;i<MAX_BUFFERS;i++) |
843 { | |
844 win.ptr = dga_buffer = video_base + multi_buff[i]; | |
845 if(verbose) paintBkGnd(); | |
846 } | |
2244 | 847 } |
2686 | 848 else |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
849 { |
2686 | 850 if(verbose) paintBkGnd(); |
851 { | |
852 int x; | |
853 x = (video_mode_info.XResolution/video_mode_info.XCharSize)/2-strlen(title)/2; | |
854 if(x < 0) x = 0; | |
855 vbeWriteString(x,0,7,title); | |
856 } | |
2633
fe5ab8c660de
Qualitative speedup decoding when video card supports DGA!
nick
parents:
2610
diff
changeset
|
857 } |
2244 | 858 return 0; |
859 } | |
860 | |
861 static const vo_info_t* | |
862 get_info(void) | |
863 { | |
2504 | 864 if(verbose > 2) |
865 printf("vo_vesa: get_info was called\n"); | |
2244 | 866 return &vo_info; |
867 } | |
868 | |
869 static void | |
870 uninit(void) | |
871 { | |
2686 | 872 vesa_term(); |
2504 | 873 if(verbose > 2) |
874 printf("vo_vesa: uninit was called\n"); | |
2244 | 875 } |
876 | |
877 | |
878 static void check_events(void) | |
879 { | |
2504 | 880 if(verbose > 2) |
881 printf("vo_vesa: check_events was called\n"); | |
2244 | 882 /* Nothing to do */ |
883 } |