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