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