comparison libvo/vo_svga.c @ 28646:9b58b40350f7

Cosmetics. Remove all trailing whitespaces and convert the few tabs into spaces.
author iive
date Sat, 21 Feb 2009 00:30:53 +0000
parents 7681eab10aea
children c8e199e21100
comparison
equal deleted inserted replaced
28645:5baf473d1a09 28646:9b58b40350f7
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 */ 23 */
24 24
25 /* 25 /*
26 Wrangings: 26 Wrangings:
27 - 1bpp doesn't work right for me with '-double' and svgalib 1.4.3, 27 - 1bpp doesn't work right for me with '-double' and svgalib 1.4.3,
28 but works OK with svgalib 1.9.17 28 but works OK with svgalib 1.9.17
29 - The HW acceleration is not tested - svgalibs supports few chipsets, 29 - The HW acceleration is not tested - svgalibs supports few chipsets,
30 and i don't have any of them. If it works for you then let me know. 30 and i don't have any of them. If it works for you then let me know.
31 I will remove this warning after confirm its status. 31 I will remove this warning after confirm its status.
32 - retrace sync works only in doublebuffer mode. 32 - retrace sync works only in doublebuffer mode.
33 - the retrace sync may slow down decoding a lot - mplayer is blocked while 33 - the retrace sync may slow down decoding a lot - mplayer is blocked while
34 waiting for retrace 34 waiting for retrace
35 - denoise3d fails to find common colorspace, use -vf denoise3d,scale 35 - denoise3d fails to find common colorspace, use -vf denoise3d,scale
36 36
37 TODO: 37 TODO:
38 - let choose_best_mode take aspect into account 38 - let choose_best_mode take aspect into account
39 - set palette from mpi->palette or mpi->plane[1] 39 - set palette from mpi->palette or mpi->plane[1]
40 - make faster OSD black bars clear - need some OSD changes 40 - make faster OSD black bars clear - need some OSD changes
41 - Make nicer CONFIG parsing 41 - Make nicer CONFIG parsing
42 - change video mode logical width to match img->stride[0] - for HW only 42 - change video mode logical width to match img->stride[0] - for HW only
43 */ 43 */
44 44
45 #include <stdio.h> 45 #include <stdio.h>
46 #include <stdlib.h> 46 #include <stdlib.h>
47 #include <string.h> 47 #include <string.h>
66 //#include "mp_image.h" 66 //#include "mp_image.h"
67 67
68 #include <assert.h> 68 #include <assert.h>
69 69
70 //silence warnings, probably it have to go in some global header 70 //silence warnings, probably it have to go in some global header
71 #define UNUSED(x) ((void)(x)) 71 #define UNUSED(x) ((void)(x))
72 72
73 73
74 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src, 74 static void draw_alpha(int x0, int y0, int w, int h, unsigned char *src,
75 unsigned char *srca, int stride); 75 unsigned char *srca, int stride);
76 static uint32_t get_image(mp_image_t *mpi); 76 static uint32_t get_image(mp_image_t *mpi);
140 getch2_disable(); 140 getch2_disable();
141 memset(zerobuf,0,sizeof(zerobuf)); 141 memset(zerobuf,0,sizeof(zerobuf));
142 force_vm=force_native=squarepix=0; 142 force_vm=force_native=squarepix=0;
143 sync_flip=vo_vsync; 143 sync_flip=vo_vsync;
144 blackbar_osd=0; 144 blackbar_osd=0;
145 145
146 if(arg)while(*arg) { 146 if(arg)while(*arg) {
147 #ifdef CONFIG_VIDIX 147 #ifdef CONFIG_VIDIX
148 if(memcmp(arg,"vidix",5)==0) { 148 if(memcmp(arg,"vidix",5)==0) {
149 i=6; 149 i=6;
150 while(arg[i] && arg[i]!=':') i++; 150 while(arg[i] && arg[i]!=':') i++;
151 strncpy(vidix_name, arg+6, i-6); 151 strncpy(vidix_name, arg+6, i-6);
152 vidix_name[i-5]=0; 152 vidix_name[i-5]=0;
158 if(!strncmp(arg,"sq",2)) { 158 if(!strncmp(arg,"sq",2)) {
159 squarepix=1; 159 squarepix=1;
160 arg+=2; 160 arg+=2;
161 if( *arg == ':' ) arg++; 161 if( *arg == ':' ) arg++;
162 } 162 }
163 163
164 if(!strncmp(arg,"native",6)) { 164 if(!strncmp(arg,"native",6)) {
165 force_native=1; 165 force_native=1;
166 arg+=6; 166 arg+=6;
167 if( *arg == ':' ) arg++; 167 if( *arg == ':' ) arg++;
168 } 168 }
176 if(!strncmp(arg,"retrace",7)) { 176 if(!strncmp(arg,"retrace",7)) {
177 sync_flip=1; 177 sync_flip=1;
178 arg+=7; 178 arg+=7;
179 if( *arg == ':' ) arg++; 179 if( *arg == ':' ) arg++;
180 } 180 }
181 181
182 if(*arg) { 182 if(*arg) {
183 i=0; 183 i=0;
184 while(arg[i] && arg[i]!=':')i++; 184 while(arg[i] && arg[i]!=':')i++;
185 if(i<64){ 185 if(i<64){
186 strncpy(s, arg, i); 186 strncpy(s, arg, i);
187 s[i]=0; 187 s[i]=0;
188 188
189 force_vm=vga_getmodenumber(s); 189 force_vm=vga_getmodenumber(s);
190 if(force_vm>0) { 190 if(force_vm>0) {
191 if( mp_msg_test(MSGT_VO,MSGL_V) ) mp_msg(MSGT_VO,MSGL_V, "vo_svga: Forcing mode %i\n",force_vm); 191 if( mp_msg_test(MSGT_VO,MSGL_V) ) mp_msg(MSGT_VO,MSGL_V, "vo_svga: Forcing mode %i\n",force_vm);
192 }else{ 192 }else{
193 force_vm = 0; 193 force_vm = 0;
194 } 194 }
195 } 195 }
196 arg+=i; 196 arg+=i;
197 if(*arg==':')arg++; 197 if(*arg==':')arg++;
198 } 198 }
199 } 199 }
200 200
201 rez = vga_init(); 201 rez = vga_init();
202 if(rez != 0){ 202 if(rez != 0){
203 mp_msg(MSGT_VO,MSGL_ERR, "vo_svga: vga_init() returned error=%d\n",rez); 203 mp_msg(MSGT_VO,MSGL_ERR, "vo_svga: vga_init() returned error=%d\n",rez);
204 } 204 }
205 return !!rez; 205 return !!rez;
211 211
212 if (mode_capabilities&CAP_ACCEL_CLEAR){ 212 if (mode_capabilities&CAP_ACCEL_CLEAR){
213 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) 213 if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
214 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n", 214 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: clearing box %d,%d - %d,%d with HW acceleration\n",
215 x,y,w,h); 215 x,y,w,h);
216 if(mode_capabilities&CAP_ACCEL_BACKGR) 216 if(mode_capabilities&CAP_ACCEL_BACKGR)
217 vga_accel(ACCEL_SYNC); 217 vga_accel(ACCEL_SYNC);
218 vga_accel(ACCEL_SETFGCOLOR,0);//black 218 vga_accel(ACCEL_SETFGCOLOR,0);//black
219 vga_accel(ACCEL_FILLBOX,x,y,w,h); 219 vga_accel(ACCEL_FILLBOX,x,y,w,h);
220 return; 220 return;
221 } 221 }
252 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n"); 252 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: drawing direct rendered surface\n");
253 cpage=(uint32_t)mpi->priv; 253 cpage=(uint32_t)mpi->priv;
254 assert((cpage>=0)&&(cpage<max_pages)); 254 assert((cpage>=0)&&(cpage<max_pages));
255 return VO_TRUE; //it's already done 255 return VO_TRUE; //it's already done
256 } 256 }
257 // if (mpi->flags&MP_IMGFLAGS_DRAWBACK) 257 // if (mpi->flags&MP_IMGFLAGS_DRAWBACK)
258 // return VO_TRUE;//direct render method 2 258 // return VO_TRUE;//direct render method 2
259 259
260 //find a free page to draw into 260 //find a free page to draw into
261 //if there is no one then use the current one 261 //if there is no one then use the current one
262 page = page_find_free(); 262 page = page_find_free();
263 if(page>=0) cpage=page; 263 if(page>=0) cpage=page;
264 PageStore[cpage].locks=PAGE_BUSY; 264 PageStore[cpage].locks=PAGE_BUSY;
265 265
266 // these variables are used in loops 266 // these variables are used in loops
267 x = mpi->x; 267 x = mpi->x;
268 y = mpi->y; 268 y = mpi->y;
269 w = mpi->w; 269 w = mpi->w;
270 h = mpi->h; 270 h = mpi->h;
271 stride = mpi->stride[0]; 271 stride = mpi->stride[0];
272 rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8; 272 rgbplane = mpi->planes[0] + y*stride + (x*mpi->bpp)/8;
273 x+=x_pos;//center 273 x+=x_pos;//center
274 y+=y_pos; 274 y+=y_pos;
275 275
276 if(mpi->bpp >= 8){//for modes<8 use only native 276 if(mpi->bpp >= 8){//for modes<8 use only native
277 if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) && 277 if( (mode_capabilities&CAP_ACCEL_PUTIMAGE) && (x==0) && (w==mpi->width) &&
278 (stride == mode_stride) ){ //only monolite image can be accelerated 278 (stride == mode_stride) ){ //only monolite image can be accelerated
279 w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source 279 w=(stride*8)/mpi->bpp;//we transfer pixels in the stride so the source
280 //ACCELERATE 280 //ACCELERATE
284 vga_accel(ACCEL_SYNC); 284 vga_accel(ACCEL_SYNC);
285 285
286 vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane); 286 vga_accel(ACCEL_PUTIMAGE,x,y+PageStore[cpage].yoffset,w,h,rgbplane);
287 return VO_TRUE; 287 return VO_TRUE;
288 } 288 }
289 289
290 if( mode_capabilities&CAP_LINEAR){ 290 if( mode_capabilities&CAP_LINEAR){
291 //DIRECT 291 //DIRECT
292 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) 292 if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
293 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); 293 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Direct memcpy (x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
294 bytesperline=(w*mpi->bpp)/8; 294 bytesperline=(w*mpi->bpp)/8;
295 base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8; 295 base=PageStore[cpage].vbase + (y*mode_stride) + (x*mpi->bpp)/8;
296 296
297 for(i=0;i<h;i++){ 297 for(i=0;i<h;i++){
298 mem2agpcpy(base,rgbplane,bytesperline); 298 mem2agpcpy(base,rgbplane,bytesperline);
299 base+=mode_stride; 299 base+=mode_stride;
300 rgbplane+=stride; 300 rgbplane+=stride;
301 } 301 }
302 return VO_TRUE; 302 return VO_TRUE;
303 } 303 }
304 }//(modebpp>=8 304 }//(modebpp>=8
305 305
306 306
307 //NATIVE 307 //NATIVE
308 { 308 {
309 int length; 309 int length;
310 length=(w*mpi->bpp)/8; 310 length=(w*mpi->bpp)/8;
311 //one byte per pixel! svgalib innovation 311 //one byte per pixel! svgalib innovation
312 if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w; 312 if(mpi->imgfmt==IMGFMT_RG4B || mpi->imgfmt==IMGFMT_BG4B) length=w;
313 313
314 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) 314 if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
315 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h); 315 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: using Native vga_draw(x=%d,y=%d,w=%d,h=%d)\n",x,y,w,h);
316 y+=PageStore[cpage].yoffset;//y position of the page beggining 316 y+=PageStore[cpage].yoffset;//y position of the page beggining
317 for(i=0;i<h;i++){ 317 for(i=0;i<h;i++){
318 vga_drawscansegment(rgbplane,x,y+i,length); 318 vga_drawscansegment(rgbplane,x,y+i,length);
328 case 16: return 4; 328 case 16: return 4;
329 case 256: return 8; 329 case 256: return 8;
330 case 32768: return 15; 330 case 32768: return 15;
331 case 65536: return 16; 331 case 65536: return 16;
332 case 1<<24: return 8*vminfo->bytesperpixel; 332 case 1<<24: return 8*vminfo->bytesperpixel;
333 } 333 }
334 return 0; 334 return 0;
335 } 335 }
336 336
337 static int find_best_svga_mode(int req_w,int req_h, int req_bpp){ 337 static int find_best_svga_mode(int req_w,int req_h, int req_bpp){
338 int badness,prev_badness; 338 int badness,prev_badness;
352 if( vga_hasmode(i) == 0 ) continue; 352 if( vga_hasmode(i) == 0 ) continue;
353 if( req_bpp != bpp_from_vminfo(vminfo) )continue; 353 if( req_bpp != bpp_from_vminfo(vminfo) )continue;
354 if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue; 354 if( (vminfo->width < req_w) || (vminfo->height < req_h) ) continue;
355 badness=(vminfo->width * vminfo->height) - (req_h * req_w); 355 badness=(vminfo->width * vminfo->height) - (req_h * req_w);
356 //put here aspect calculations 356 //put here aspect calculations
357 if(squarepix) 357 if(squarepix)
358 if( vminfo->width*3 != vminfo->height*4 ) continue; 358 if( vminfo->width*3 != vminfo->height*4 ) continue;
359 359
360 if( bestmode==0 || prev_badness >= badness ){//modeX etc... 360 if( bestmode==0 || prev_badness >= badness ){//modeX etc...
361 prev_badness=badness; 361 prev_badness=badness;
362 bestmode=i; 362 bestmode=i;
383 switch (request) { 383 switch (request) {
384 case VOCTRL_SET_EQUALIZER: 384 case VOCTRL_SET_EQUALIZER:
385 { 385 {
386 va_list ap; 386 va_list ap;
387 int value; 387 int value;
388 388
389 va_start(ap, data); 389 va_start(ap, data);
390 value = va_arg(ap, int); 390 value = va_arg(ap, int);
391 va_end(ap); 391 va_end(ap);
392 392
393 return vidix_control(request, data, value); 393 return vidix_control(request, data, value);
394 } 394 }
395 case VOCTRL_GET_EQUALIZER: 395 case VOCTRL_GET_EQUALIZER:
396 { 396 {
397 va_list ap; 397 va_list ap;
398 int *value; 398 int *value;
399 399
400 va_start(ap, data); 400 va_start(ap, data);
401 value = va_arg(ap, int*); 401 value = va_arg(ap, int*);
402 va_end(ap); 402 va_end(ap);
403 403
404 return vidix_control(request, data, value); 404 return vidix_control(request, data, value);
419 uint32_t format) { 419 uint32_t format) {
420 int32_t req_w = width;// (d_width > 0 ? d_width : width); 420 int32_t req_w = width;// (d_width > 0 ? d_width : width);
421 int32_t req_h = height;// (d_height > 0 ? d_height : height); 421 int32_t req_h = height;// (d_height > 0 ? d_height : height);
422 uint16_t vid_mode = 0; 422 uint16_t vid_mode = 0;
423 int32_t req_bpp; 423 int32_t req_bpp;
424 424
425 uint32_t accflags; 425 uint32_t accflags;
426 if( mp_msg_test(MSGT_VO,MSGL_V) ) 426 if( mp_msg_test(MSGT_VO,MSGL_V) )
427 mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height, 427 mp_msg(MSGT_VO,MSGL_V, "vo_svga: config(%i, %i, %i, %i, %08x, %s, %08x)\n", width, height,
428 d_width, d_height, flags, title, format); 428 d_width, d_height, flags, title, format);
429 //Only RGB modes supported 429 //Only RGB modes supported
430 if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;} 430 if (!IMGFMT_IS_RGB(format) && !IMGFMT_IS_BGR(format)) {assert(0);return -1;}
431 req_bpp = IMGFMT_BGR_DEPTH(format); 431 req_bpp = IMGFMT_BGR_DEPTH(format);
432 432
433 if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;} 433 if( vo_dbpp!=0 && vo_dbpp!=req_bpp) {assert(0);return-1;}
434 434
435 if(!force_vm) { 435 if(!force_vm) {
436 if ( mp_msg_test(MSGT_VO,MSGL_V) ) { 436 if ( mp_msg_test(MSGT_VO,MSGL_V) ) {
437 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n"); 437 mp_msg(MSGT_VO,MSGL_V, "vo_svga: Looking for the best resolution...\n");
438 mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp); 438 mp_msg(MSGT_VO,MSGL_V, "vo_svga: req_w: %d, req_h: %d, bpp: %d\n",req_w,req_h,req_bpp);
439 } 439 }
440 vid_mode=find_best_svga_mode(req_w,req_h,req_bpp); 440 vid_mode=find_best_svga_mode(req_w,req_h,req_bpp);
441 if(vid_mode==0) 441 if(vid_mode==0)
442 return 1; 442 return 1;
443 modeinfo=vga_getmodeinfo(vid_mode); 443 modeinfo=vga_getmodeinfo(vid_mode);
444 }else{//force_vm 444 }else{//force_vm
445 vid_mode=force_vm; 445 vid_mode=force_vm;
446 if(vga_hasmode(vid_mode) == 0){ 446 if(vga_hasmode(vid_mode) == 0){
454 vid_mode,vga_getmodename(vid_mode)); 454 vid_mode,vga_getmodename(vid_mode));
455 return 1; 455 return 1;
456 } 456 }
457 } 457 }
458 mode_bpp=bpp_from_vminfo(modeinfo); 458 mode_bpp=bpp_from_vminfo(modeinfo);
459 459
460 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode, 460 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_Vidmode,
461 vid_mode,modeinfo->width,modeinfo->height,mode_bpp); 461 vid_mode,modeinfo->width,modeinfo->height,mode_bpp);
462 462
463 if (vga_setmode(vid_mode) == -1) { 463 if (vga_setmode(vid_mode) == -1) {
464 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode); 464 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SVGA_VgasetmodeFailed,vid_mode);
465 uninit(); 465 uninit();
466 return 1; // error 466 return 1; // error
467 } 467 }
474 /* set 121 palette for 4 bpp */ 474 /* set 121 palette for 4 bpp */
475 else if(mode_bpp==4){ 475 else if(mode_bpp==4){
476 int i; 476 int i;
477 for(i=0; i<16; i++) 477 for(i=0; i<16; i++)
478 vga_setpalette(i, ((i>>3)&1)*63, ((i>>1)&3)*21, (i&1)*63); 478 vga_setpalette(i, ((i>>3)&1)*63, ((i>>1)&3)*21, (i&1)*63);
479 } 479 }
480 //if we change the logical width, we should know the granularity 480 //if we change the logical width, we should know the granularity
481 stride_granularity=8;//according to man vga_logicalwidth 481 stride_granularity=8;//according to man vga_logicalwidth
482 if(modeinfo->flags & EXT_INFO_AVAILABLE){ 482 if(modeinfo->flags & EXT_INFO_AVAILABLE){
483 stride_granularity=modeinfo->linewidth_unit; 483 stride_granularity=modeinfo->linewidth_unit;
484 } 484 }
494 if((accflags & ACCELFLAG_SETMODE) && (accflags & ACCELFLAG_SYNC)){ 494 if((accflags & ACCELFLAG_SETMODE) && (accflags & ACCELFLAG_SYNC)){
495 vga_accel(ACCEL_SETMODE,BLITS_IN_BACKGROUND); 495 vga_accel(ACCEL_SETMODE,BLITS_IN_BACKGROUND);
496 mode_capabilities|=CAP_ACCEL_BACKGR;//can draw in backgraund 496 mode_capabilities|=CAP_ACCEL_BACKGR;//can draw in backgraund
497 } 497 }
498 } 498 }
499 if(modeinfo->flags & IS_LINEAR){ 499 if(modeinfo->flags & IS_LINEAR){
500 mode_capabilities|=CAP_LINEAR; //don't use bank & vga_draw 500 mode_capabilities|=CAP_LINEAR; //don't use bank & vga_draw
501 } 501 }
502 else{ 502 else{
503 if(modeinfo->flags & CAPABLE_LINEAR){ 503 if(modeinfo->flags & CAPABLE_LINEAR){
504 int vid_mem_size; 504 int vid_mem_size;
515 } 515 }
516 if(mode_capabilities&CAP_ACCEL_PUTIMAGE){ 516 if(mode_capabilities&CAP_ACCEL_PUTIMAGE){
517 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration); 517 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHasHardwareAcceleration);
518 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow); 518 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_IfItWorksForYouIWouldLikeToKnow);
519 } 519 }
520 520
521 //here is the place to handle strides for accel_ modes; 521 //here is the place to handle strides for accel_ modes;
522 mode_stride=modeinfo->linewidth; 522 mode_stride=modeinfo->linewidth;
523 //we may try to set a bigger stride for video mode that will match the mpi->stride, 523 //we may try to set a bigger stride for video mode that will match the mpi->stride,
524 //this way we will transfer more data, but HW put_image can do it in backgraund! 524 //this way we will transfer more data, but HW put_image can do it in backgraund!
525 525
526 //now let's see how many pages we can use 526 //now let's see how many pages we can use
527 max_pages = modeinfo->maxpixels/(modeinfo->height * modeinfo->width); 527 max_pages = modeinfo->maxpixels/(modeinfo->height * modeinfo->width);
528 if(max_pages > MAXPAGES) max_pages = MAXPAGES; 528 if(max_pages > MAXPAGES) max_pages = MAXPAGES;
529 if(!vo_doublebuffering) max_pages=1; 529 if(!vo_doublebuffering) max_pages=1;
530 //fill PageStore structs 530 //fill PageStore structs
531 { 531 {
542 max_pages=i;//page 0 will never come here 542 max_pages=i;//page 0 will never come here
543 break; 543 break;
544 } 544 }
545 PageStore[i].yoffset = i * modeinfo->height;//starting y offset 545 PageStore[i].yoffset = i * modeinfo->height;//starting y offset
546 PageStore[i].vbase = GRAPH_MEM + i*modeinfo->height*mode_stride; //memory base address 546 PageStore[i].vbase = GRAPH_MEM + i*modeinfo->height*mode_stride; //memory base address
547 PageStore[i].doffset = dof; //display offset 547 PageStore[i].doffset = dof; //display offset
548 PageStore[i].locks = PAGE_EMPTY; 548 PageStore[i].locks = PAGE_EMPTY;
549 } 549 }
550 } 550 }
551 assert(max_pages>0); 551 assert(max_pages>0);
552 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages); 552 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_VideoModeHas,max_pages);
566 x_pos &= ~(15); //align x offset position to 16 pixels 566 x_pos &= ~(15); //align x offset position to 16 pixels
567 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos); 567 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_CenteringImageStartAt,x_pos,y_pos);
568 568
569 #ifdef CONFIG_VIDIX 569 #ifdef CONFIG_VIDIX
570 570
571 if(vidix_name[0]){ 571 if(vidix_name[0]){
572 vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height, 572 vidix_init(width, height, x_pos, y_pos, modeinfo->width, modeinfo->height,
573 format, mode_bpp, modeinfo->width,modeinfo->height); 573 format, mode_bpp, modeinfo->width,modeinfo->height);
574 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height, 574 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SVGA_UsingVidix,width,height,
575 modeinfo->width,modeinfo->height); 575 modeinfo->width,modeinfo->height);
576 vidix_start(); 576 vidix_start();
577 /*set colorkey*/ 577 /*set colorkey*/
578 if(vidix_grkey_support()){ 578 if(vidix_grkey_support()){
579 vidix_grkey_get(&gr_key); 579 vidix_grkey_get(&gr_key);
580 gr_key.key_op = KEYS_PUT; 580 gr_key.key_op = KEYS_PUT;
581 if (!(vo_colorkey & 0xFF000000)) { 581 if (!(vo_colorkey & 0xFF000000)) {
582 gr_key.ckey.op = CKEY_TRUE; 582 gr_key.ckey.op = CKEY_TRUE;
583 gr_key.ckey.red = (vo_colorkey & 0x00FF0000) >> 16; 583 gr_key.ckey.red = (vo_colorkey & 0x00FF0000) >> 16;
584 gr_key.ckey.green = (vo_colorkey & 0x0000FF00) >> 8; 584 gr_key.ckey.green = (vo_colorkey & 0x0000FF00) >> 8;
585 gr_key.ckey.blue = vo_colorkey & 0x000000FF; 585 gr_key.ckey.blue = vo_colorkey & 0x000000FF;
586 } else 586 } else
587 gr_key.ckey.op = CKEY_FALSE; 587 gr_key.ckey.op = CKEY_FALSE;
588 vidix_grkey_set(&gr_key); 588 vidix_grkey_set(&gr_key);
589 } 589 }
590 } 590 }
591 #endif 591 #endif
592 592
593 vga_setdisplaystart(0); 593 vga_setdisplaystart(0);
594 return 0; 594 return 0;
595 } 595 }
596 596
615 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 615 if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
616 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: draw_osd()\n"); 616 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: draw_osd()\n");
617 //only modes with bytesperpixel>0 can draw OSD 617 //only modes with bytesperpixel>0 can draw OSD
618 if(modeinfo->bytesperpixel==0) return; 618 if(modeinfo->bytesperpixel==0) return;
619 if(!(mode_capabilities&CAP_LINEAR)) return;//force_native will remove OSD 619 if(!(mode_capabilities&CAP_LINEAR)) return;//force_native will remove OSD
620 620
621 if(blackbar_osd){ 621 if(blackbar_osd){
622 //111 622 //111
623 //3 4 623 //3 4
624 //222 624 //222
625 svga_clear_box(0,0 + PageStore[cpage].yoffset, 625 svga_clear_box(0,0 + PageStore[cpage].yoffset,
626 modeinfo->width, y_pos); 626 modeinfo->width, y_pos);
627 svga_clear_box(0, image_height + y_pos + PageStore[cpage].yoffset, 627 svga_clear_box(0, image_height + y_pos + PageStore[cpage].yoffset,
628 modeinfo->width, modeinfo->height-(image_height+ y_pos)); 628 modeinfo->width, modeinfo->height-(image_height+ y_pos));
629 svga_clear_box(0, y_pos + PageStore[cpage].yoffset, 629 svga_clear_box(0, y_pos + PageStore[cpage].yoffset,
630 x_pos, image_height); 630 x_pos, image_height);
631 svga_clear_box(image_width + x_pos, y_pos + PageStore[cpage].yoffset, 631 svga_clear_box(image_width + x_pos, y_pos + PageStore[cpage].yoffset,
632 modeinfo->width-(x_pos+image_width), image_height); 632 modeinfo->width-(x_pos+image_width), image_height);
633 // vo_remove_text(modeinfo->width, modeinfo->height, clear_alpha); 633 // vo_remove_text(modeinfo->width, modeinfo->height, clear_alpha);
634 vo_draw_text(modeinfo->width, modeinfo->height, draw_alpha); 634 vo_draw_text(modeinfo->width, modeinfo->height, draw_alpha);
635 }else{ 635 }else{
636 vo_draw_text(image_width, image_height, draw_alpha); 636 vo_draw_text(image_width, image_height, draw_alpha);
646 if(sync_flip && old_page!=cpage){ 646 if(sync_flip && old_page!=cpage){
647 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga:vga_waitretrace\n"); 647 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga:vga_waitretrace\n");
648 vga_waitretrace(); 648 vga_waitretrace();
649 } 649 }
650 vga_setdisplaystart(PageStore[cpage].doffset); 650 vga_setdisplaystart(PageStore[cpage].doffset);
651 651
652 old_page=cpage;//cpage will be overwriten on next draw_image 652 old_page=cpage;//cpage will be overwriten on next draw_image
653 } 653 }
654 654
655 static void check_events(void) { 655 static void check_events(void) {
656 } 656 }
670 vga_modeinfo * vminfo; 670 vga_modeinfo * vminfo;
671 671
672 if ( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 672 if ( mp_msg_test(MSGT_VO,MSGL_DBG4) )
673 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: query_format=%X \n",format); 673 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: query_format=%X \n",format);
674 //only RGB modes supported 674 //only RGB modes supported
675 if( (!IMGFMT_IS_RGB(format)) && (!IMGFMT_IS_BGR(format)) ) return 0; 675 if( (!IMGFMT_IS_RGB(format)) && (!IMGFMT_IS_BGR(format)) ) return 0;
676 676
677 // Reject different endian 677 // Reject different endian
678 #ifdef WORDS_BIGENDIAN 678 #ifdef WORDS_BIGENDIAN
679 if (IMGFMT_IS_BGR(format)) return 0; 679 if (IMGFMT_IS_BGR(format)) return 0;
680 #else 680 #else
713 if(!blackbar_osd) { 713 if(!blackbar_osd) {
714 //drawing in the image, so place the stuff there 714 //drawing in the image, so place the stuff there
715 x0+=x_pos; 715 x0+=x_pos;
716 y0+=y_pos; 716 y0+=y_pos;
717 } 717 }
718 718
719 if( mp_msg_test(MSGT_VO,MSGL_DBG4) ) 719 if( mp_msg_test(MSGT_VO,MSGL_DBG4) )
720 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: OSD draw in page %d\n",cpage); 720 mp_msg(MSGT_VO,MSGL_DBG4, "vo_svga: OSD draw in page %d\n",cpage);
721 base=PageStore[cpage].vbase + y0*mode_stride + x0*modeinfo->bytesperpixel; 721 base=PageStore[cpage].vbase + y0*mode_stride + x0*modeinfo->bytesperpixel;
722 switch (mode_bpp) { 722 switch (mode_bpp) {
723 case 32: 723 case 32:
724 vo_draw_alpha_rgb32(w, h, src, srca, stride, base, mode_stride); 724 vo_draw_alpha_rgb32(w, h, src, srca, stride, base, mode_stride);
725 break; 725 break;
726 case 24: 726 case 24:
727 vo_draw_alpha_rgb24(w, h, src, srca, stride, base, mode_stride); 727 vo_draw_alpha_rgb24(w, h, src, srca, stride, base, mode_stride);
728 break; 728 break;
729 case 16: 729 case 16:
730 vo_draw_alpha_rgb16(w, h, src, srca, stride, base, mode_stride); 730 vo_draw_alpha_rgb16(w, h, src, srca, stride, base, mode_stride);
731 break; 731 break;
736 } 736 }
737 737
738 static uint32_t get_image(mp_image_t *mpi){ 738 static uint32_t get_image(mp_image_t *mpi){
739 int page; 739 int page;
740 740
741 if(!IMGFMT_IS_BGR(mpi->imgfmt) && !IMGFMT_IS_RGB(mpi->imgfmt) ){ 741 if(!IMGFMT_IS_BGR(mpi->imgfmt) && !IMGFMT_IS_RGB(mpi->imgfmt) ){
742 assert(0);//should never happen 742 assert(0);//should never happen
743 return VO_FALSE; 743 return VO_FALSE;
744 } 744 }
745 745
746 if ( 746 if (
747 ( (mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) || 747 ( (mpi->type != MP_IMGTYPE_STATIC) && (mpi->type != MP_IMGTYPE_TEMP)) ||
748 (mpi->flags & MP_IMGFLAG_PLANAR) || 748 (mpi->flags & MP_IMGFLAG_PLANAR) ||
749 (mpi->flags & MP_IMGFLAG_YUV) 749 (mpi->flags & MP_IMGFLAG_YUV)
750 ) 750 )
759 if(page >= 0){ 759 if(page >= 0){
760 PageStore[page].locks=PAGE_BUSY; 760 PageStore[page].locks=PAGE_BUSY;
761 761
762 mpi->flags |= MP_IMGFLAG_DIRECT; 762 mpi->flags |= MP_IMGFLAG_DIRECT;
763 mpi->stride[0] = mode_stride; 763 mpi->stride[0] = mode_stride;
764 mpi->planes[0] = PageStore[page].vbase + 764 mpi->planes[0] = PageStore[page].vbase +
765 y_pos*mode_stride + (x_pos*mpi->bpp)/8; 765 y_pos*mode_stride + (x_pos*mpi->bpp)/8;
766 mpi->priv=(void *)page; 766 mpi->priv=(void *)page;
767 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) 767 if( mp_msg_test(MSGT_VO,MSGL_DBG3) )
768 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: direct render allocated! page=%d\n",page); 768 mp_msg(MSGT_VO,MSGL_DBG3, "vo_svga: direct render allocated! page=%d\n",page);
769 return VO_TRUE; 769 return VO_TRUE;