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