comparison libvo/vo_dga.c @ 680:fbd9327b899b

- now features 24->32 conversion (this is actually faster than letting the codec produce depth 32 in the first place for avis :-))) )
author acki2
date Tue, 01 May 2001 22:37:37 +0000
parents ee2dac2cc633
children 2094b195a9bc
comparison
equal deleted inserted replaced
679:ad25efe7a2bc 680:fbd9327b899b
21 * BGR_32_24_888 21 * BGR_32_24_888
22 * 22 *
23 * - works only on x86 architectures 23 * - works only on x86 architectures
24 * 24 *
25 * $Log$ 25 * $Log$
26 * Revision 1.19 2001/05/01 22:37:37 acki2
27 * - now features 24->32 conversion (this is actually faster than letting the
28 * codec produce depth 32 in the first place for avis :-))) )
29 *
26 * Revision 1.18 2001/05/01 20:24:31 acki2 30 * Revision 1.18 2001/05/01 20:24:31 acki2
27 * - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok? 31 * - now mpeg is fast again (no more offscreen buffer rubbish) But is it really ok?
28 * 32 *
29 * Revision 1.17 2001/04/24 11:42:04 pontscho 33 * Revision 1.17 2001/04/24 11:42:04 pontscho
30 * clean up 34 * clean up
123 127
124 128
125 //------------------------------------------------------------------ 129 //------------------------------------------------------------------
126 130
127 131
128 #define BITSPP (vo_dga_modes[vo_dga_active_mode].vdm_bitspp) 132 //#define BITSPP (vo_dga_modes[vo_dga_active_mode].vdm_bitspp)
129 #define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp) 133 //#define BYTESPP (vo_dga_modes[vo_dga_active_mode].vdm_bytespp)
130 134
131 #define HW_MODE (vo_dga_modes[vo_dga_active_mode]) 135 #define HW_MODE (vo_dga_modes[vo_dga_hw_mode])
132 136 #define SRC_MODE (vo_dga_modes[vo_dga_src_mode])
133 137
134 struct vd_modes { 138 struct vd_modes {
135 int vdm_mplayer_depth; 139 int vdm_mplayer_depth;
136 int vdm_supported; 140 int vdm_supported;
137 int vdm_depth; 141 int vdm_depth;
138 int vdm_bitspp; 142 int vdm_bitspp;
139 int vdm_bytespp; 143 int vdm_bytespp;
140 int vdm_rmask; 144 int vdm_rmask;
141 int vdm_gmask; 145 int vdm_gmask;
142 int vdm_bmask; 146 int vdm_bmask;
147 int vdm_hw_mode;
148 int vdm_conversion_func;
143 }; 149 };
144 150
145 //------------------------------------------------------------------ 151 //------------------------------------------------------------------
146 152
153 #define VDM_CONV_NATIVE 0
154 #define VDM_CONV_15TO16 1
155 #define VDM_CONV_24TO32 2
156
147 static struct vd_modes vo_dga_modes[] = { 157 static struct vd_modes vo_dga_modes[] = {
148 158 // these entries describe HW modes
149 { 0, 0, 0, 0, 0, 0, 0, 0}, 159 // however, we use the same entries to tell mplayer what we support
150 { 15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f }, 160 // so the last two values describe, which HW mode to use and which conversion
151 { 16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f }, 161 // function to use for a mode that is not supported by HW
152 { 24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff}, 162
153 { 32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff} 163 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
164 { 15, 0, 15, 16, 2, 0x7c00, 0x03e0, 0x001f, 2, VDM_CONV_15TO16 },
165 { 16, 0, 16, 16, 2, 0xf800, 0x07e0, 0x001f, 2, VDM_CONV_NATIVE },
166 { 24, 0, 24, 24, 3, 0xff0000, 0x00ff00, 0x0000ff, 4, VDM_CONV_24TO32},
167 { 32, 0, 24, 32, 4, 0x00ff0000, 0x0000ff00, 0x000000ff, 4, VDM_CONV_NATIVE}
154 }; 168 };
155 169
156 static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes); 170 static int vo_dga_mode_num = sizeof(vo_dga_modes)/sizeof(struct vd_modes);
157 171
172 // enable a HW mode (by description)
158 int vd_EnableMode( int depth, int bitspp, 173 int vd_EnableMode( int depth, int bitspp,
159 int rmask, int gmask, int bmask){ 174 int rmask, int gmask, int bmask){
160 int i; 175 int i;
161 for(i=1; i<vo_dga_mode_num; i++){ 176 for(i=1; i<vo_dga_mode_num; i++){
162 if(vo_dga_modes[i].vdm_depth == depth && 177 if(vo_dga_modes[i].vdm_depth == depth &&
163 vo_dga_modes[i].vdm_bitspp == bitspp && 178 vo_dga_modes[i].vdm_bitspp == bitspp &&
164 vo_dga_modes[i].vdm_rmask == rmask && 179 vo_dga_modes[i].vdm_rmask == rmask &&
165 vo_dga_modes[i].vdm_gmask == gmask && 180 vo_dga_modes[i].vdm_gmask == gmask &&
166 vo_dga_modes[i].vdm_bmask == bmask){ 181 vo_dga_modes[i].vdm_bmask == bmask){
167 vo_dga_modes[i].vdm_supported = 1; 182 vo_dga_modes[i].vdm_supported = 1;
183 vo_dga_modes[i].vdm_hw_mode = i;
184 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE;
168 return i; 185 return i;
169 } 186 }
170 } 187 }
171 return 0; 188 return 0;
172 } 189 }
181 vo_dga_modes[index].vdm_bmask == bmask) 198 vo_dga_modes[index].vdm_bmask == bmask)
182 ? 1 : 0); 199 ? 1 : 0);
183 } 200 }
184 201
185 202
203 // enable a HW mode (mplayer_depth decides which)
186 int vd_ValidateMode( int mplayer_depth){ 204 int vd_ValidateMode( int mplayer_depth){
187 int i; 205 int i;
188 if(mplayer_depth == 0)return 0; 206 if(mplayer_depth == 0)return 0;
189 for(i=1; i<vo_dga_mode_num; i++){ 207 for(i=1; i<vo_dga_mode_num; i++){
190 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth ){ 208 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth ){
191 vo_dga_modes[i].vdm_supported = 1; 209 vo_dga_modes[i].vdm_supported = 1;
210 vo_dga_modes[i].vdm_hw_mode = i;
211 vo_dga_modes[i].vdm_conversion_func = VDM_CONV_NATIVE;
192 return i; 212 return i;
193 } 213 }
194 } 214 }
195 return 0; 215 return 0;
196 } 216 }
197 217
218 // do we support this mode? (not important whether native or conversion)
198 int vd_ModeValid( int mplayer_depth){ 219 int vd_ModeValid( int mplayer_depth){
199 int i; 220 int i;
200 if(mplayer_depth == 0)return 0; 221 if(mplayer_depth == 0)return 0;
201 for(i=1; i<vo_dga_mode_num; i++){ 222 for(i=1; i<vo_dga_mode_num; i++){
202 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth && 223 if(vo_dga_modes[i].vdm_mplayer_depth == mplayer_depth &&
211 232
212 #define VO_DGA_MAX_STRING_LEN 100 233 #define VO_DGA_MAX_STRING_LEN 100
213 static char stringbuf[VO_DGA_MAX_STRING_LEN]; 234 static char stringbuf[VO_DGA_MAX_STRING_LEN];
214 stringbuf[VO_DGA_MAX_STRING_LEN-1]=0; 235 stringbuf[VO_DGA_MAX_STRING_LEN-1]=0;
215 snprintf(stringbuf, VO_DGA_MAX_STRING_LEN-2, 236 snprintf(stringbuf, VO_DGA_MAX_STRING_LEN-2,
216 "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x (-bpp %d)", 237 "depth=%d, bpp=%d, r=%06x, g=%06x, b=%06x, %s (-bpp %d)",
217 vo_dga_modes[index].vdm_depth, 238 vo_dga_modes[index].vdm_depth,
218 vo_dga_modes[index].vdm_bitspp, 239 vo_dga_modes[index].vdm_bitspp,
219 vo_dga_modes[index].vdm_rmask, 240 vo_dga_modes[index].vdm_rmask,
220 vo_dga_modes[index].vdm_gmask, 241 vo_dga_modes[index].vdm_gmask,
221 vo_dga_modes[index].vdm_bmask, 242 vo_dga_modes[index].vdm_bmask,
243 vo_dga_modes[index].vdm_supported ?
244 (vo_dga_modes[index].vdm_conversion_func == VDM_CONV_NATIVE ?
245 "native (fast), " : "conversion (slow),") :
246 "not supported :-( ",
222 vo_dga_modes[index].vdm_mplayer_depth); 247 vo_dga_modes[index].vdm_mplayer_depth);
223 return stringbuf; 248 return stringbuf;
224 } 249 }
225 250
226 //----------------------------------------------------------------- 251 //-----------------------------------------------------------------
247 static int vo_dga_src_skip; // bytes to skip after copying one 272 static int vo_dga_src_skip; // bytes to skip after copying one
248 // line 273 // line
249 // (not supported yet) in src 274 // (not supported yet) in src
250 static int vo_dga_vp_skip; // dto. for dest 275 static int vo_dga_vp_skip; // dto. for dest
251 static int vo_dga_lines; // num of lines to copy 276 static int vo_dga_lines; // num of lines to copy
252 static int vo_dga_active_mode = 0; // index in mode list that is used 277 static int vo_dga_hw_mode = 0; // index in mode list that is actually
253 // for movie 278 // used by framebuffer
279 static int vo_dga_src_mode = 0; // index in mode list that is used by
280 // codec
254 static int vo_dga_XServer_mode = 0;// index in mode list for resolution 281 static int vo_dga_XServer_mode = 0;// index in mode list for resolution
255 // XServer is running 282 // XServer is running
256 283
257 static int vo_dga_dbf_mem_offset; // offset in bytes for alternative 284 static int vo_dga_dbf_mem_offset; // offset in bytes for alternative
258 // framebuffer (0 if dbf is not 285 // framebuffer (0 if dbf is not
352 379
353 char *s, *d; 380 char *s, *d;
354 381
355 s = *src; 382 s = *src;
356 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]); 383 d = (&((char *)vo_dga_base)[vo_dga_vp_offset + vo_dga_dbf_current * vo_dga_dbf_mem_offset]);
357 rep_movsl(d, s, lpl, vo_dga_vp_skip, numlines ); 384
358 385 switch(SRC_MODE.vdm_conversion_func){
386 case VDM_CONV_NATIVE:
387 rep_movsl(d, s, lpl, vo_dga_vp_skip, numlines );
388 break;
389 case VDM_CONV_15TO16:
390 printf("vo_dga: 15 to 16 not implemented yet!!!\n");
391 break;
392 case VDM_CONV_24TO32:
393 {
394 int i,k,l,m;
395 for(i = 0; i< vo_dga_lines; i++ ){
396 for(k = 0; k< vo_dga_src_width; k+=2 ){
397 l = *(((uint32_t *)s)++);
398 m = (l & 0xff000000)>> 24 ;
399 *(((uint32_t *)d)++) = l & 0x00ffffff;
400 m |= *(((uint16_t *)s)++) << 8;
401 *(((uint32_t *)d)++) = m;
402 }
403 d+= vp_skip;
404 }
405 }
406 //printf("vo_dga: 24 to 32 not implemented yet!!!\n");
407 break;
408 }
359 return 0; 409 return 0;
360 } 410 }
361 411
362 //--------------------------------------------------------- 412 //---------------------------------------------------------
363 413
394 static uint32_t draw_slice( uint8_t *src[],int stride[], 444 static uint32_t draw_slice( uint8_t *src[],int stride[],
395 int w,int h,int x,int y ) 445 int w,int h,int x,int y )
396 { 446 {
397 447
398 yuv2rgb( vo_dga_base + vo_dga_dbf_current * vo_dga_dbf_mem_offset + vo_dga_vp_offset + 448 yuv2rgb( vo_dga_base + vo_dga_dbf_current * vo_dga_dbf_mem_offset + vo_dga_vp_offset +
399 (vo_dga_width * y +x) * BYTESPP, 449 (vo_dga_width * y +x) * HW_MODE.vdm_bytespp,
400 src[0], src[1], src[2], 450 src[0], src[1], src[2],
401 w,h, vo_dga_width * BYTESPP, 451 w,h, vo_dga_width * HW_MODE.vdm_bytespp,
402 stride[0],stride[1] ); 452 stride[0],stride[1] );
403 return 0; 453 return 0;
404 }; 454 };
405 455
406 //--------------------------------------------------------- 456 //---------------------------------------------------------
436 return 0; 486 return 0;
437 } 487 }
438 if( !vo_init() ){ 488 if( !vo_init() ){
439 vd_printf(VD_ERR, "vo_dga: vo_init() failed!\n"); 489 vd_printf(VD_ERR, "vo_dga: vo_init() failed!\n");
440 return 1; 490 return 1;
441 } 491 }
442 vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen); 492 vo_dga_XServer_mode = vd_ValidateMode(vo_depthonscreen);
443 493
444 if(vo_dga_XServer_mode ==0){ 494 if(vo_dga_XServer_mode ==0){
445 #ifndef HAVE_DGA2 495 #ifndef HAVE_DGA2
446 vd_printf(VD_ERR, "vo_dga: Your X-Server is not running in a "); 496 vd_printf(VD_ERR, "vo_dga: Your X-Server is not running in a ");
447 vd_printf(VD_ERR, "resolution supported by DGA driver!\n"); 497 vd_printf(VD_ERR, "resolution supported by DGA driver!\n");
448 #endif 498 #endif
449 }else{ 499 }//else{
450 vd_printf(VD_INFO, "vo_dga: X running at: %s\n", 500 // vd_printf(VD_INFO, "vo_dga: X running at: %s\n",
451 vd_GetModeString(vo_dga_XServer_mode)); 501 // vd_GetModeString(vo_dga_XServer_mode));
452 } 502 //}
453 503
454 #ifdef HAVE_DGA2 504 #ifdef HAVE_DGA2
455 modelines=XDGAQueryModes(qdisp, XDefaultScreen(qdisp),&modecount); 505 modelines=XDGAQueryModes(qdisp, XDefaultScreen(qdisp),&modecount);
456 if(modelines){ 506 if(modelines){
457 for(i=0; i< modecount; i++){ 507 for(i=0; i< modecount; i++){
470 modelines[i].redMask, 520 modelines[i].redMask,
471 modelines[i].greenMask, 521 modelines[i].greenMask,
472 modelines[i].blueMask); 522 modelines[i].blueMask);
473 } 523 }
474 XFree(modelines); 524 XFree(modelines);
475 dga_depths_init = 1; 525
476 } 526 }
477 #endif 527 #endif
478 528 dga_depths_init = 1;
479 XCloseDisplay(qdisp); 529 XCloseDisplay(qdisp);
480 530
481 for(i=0; i<vo_dga_mode_num; i++){ 531 if( !vo_dga_modes[1].vdm_supported && vo_dga_modes[2].vdm_supported ){
482 if(vo_dga_modes[i].vdm_supported != 0){ 532 vo_dga_modes[1].vdm_supported = 1;
483 vd_printf(VD_INFO, "vo_dga: Supporting mode: %s", vd_GetModeString(i)); 533 }
484 if(vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth){ 534
485 vo_dga_modes[i].vdm_supported = 0; 535 if( !vo_dga_modes[3].vdm_supported && vo_dga_modes[4].vdm_supported ){
486 vd_printf(VD_INFO, " ...disabled by -bpp %d", vo_dbpp ); 536 vo_dga_modes[3].vdm_supported = 1;
487 } 537 }
488 vd_printf(VD_INFO, "\n"); 538
539 for(i=1; i<vo_dga_mode_num; i++){
540 vd_printf(VD_INFO, "vo_dga: Mode: %s", vd_GetModeString(i));
541 if(vo_dbpp && vo_dbpp != vo_dga_modes[i].vdm_mplayer_depth){
542 vo_dga_modes[i].vdm_supported = 0;
543 vd_printf(VD_INFO, " ...disabled by -bpp %d", vo_dbpp );
489 } 544 }
545 vd_printf(VD_INFO, "\n");
490 } 546 }
491 } 547 }
492 548
549 // TODO: respect bit for native/not native
493 if( format==IMGFMT_YV12 ) return 7; 550 if( format==IMGFMT_YV12 ) return 7;
494 551
495 if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR && 552 if( (format&IMGFMT_BGR_MASK) == IMGFMT_BGR &&
496 vd_ModeValid(format&0xff)) return 7; 553 vd_ModeValid(format&0xff)) return 7;
497 554
647 } 704 }
648 705
649 if( !vo_dbpp ){ 706 if( !vo_dbpp ){
650 707
651 if (format == IMGFMT_YV12){ 708 if (format == IMGFMT_YV12){
652 vo_dga_active_mode = vo_dga_XServer_mode; 709 vo_dga_src_mode = vo_dga_XServer_mode;
653 }else if((format & IMGFMT_BGR_MASK) == IMGFMT_BGR){ 710 }else if((format & IMGFMT_BGR_MASK) == IMGFMT_BGR){
654 vo_dga_active_mode = vd_ModeValid( format & 0xff ); 711 vo_dga_src_mode = vd_ModeValid( format & 0xff );
655 } 712 }
656 }else{ 713 }else{
657 vo_dga_active_mode = vd_ModeValid(vo_dbpp); 714 vo_dga_src_mode = vd_ModeValid(vo_dbpp);
658 } 715 }
659 716 vo_dga_hw_mode = SRC_MODE.vdm_hw_mode;
660 if(!vo_dga_active_mode){ 717
718 if( format == IMGFMT_YV12 && vo_dga_src_mode != vo_dga_hw_mode ){
719 vd_printf(VD_ERR,
720 "vo_dga: YV12 supports native modes only. Using %d instead of selected %d.\n",
721 HW_MODE.vdm_mplayer_depth,
722 SRC_MODE.vdm_mplayer_depth );
723 vo_dga_src_mode = vo_dga_hw_mode;
724 }
725
726 if(!vo_dga_src_mode){
661 vd_printf(VD_ERR, "vo_dga: unsupported video format!\n"); 727 vd_printf(VD_ERR, "vo_dga: unsupported video format!\n");
662 return 1; 728 return 1;
663 } 729 }
664 730
665 if((vo_dga_dpy = XOpenDisplay(0))==NULL){ 731 if((vo_dga_dpy = XOpenDisplay(0))==NULL){
688 if(vd_ModeEqual( modelines[i].depth, 754 if(vd_ModeEqual( modelines[i].depth,
689 modelines[i].bitsPerPixel, 755 modelines[i].bitsPerPixel,
690 modelines[i].redMask, 756 modelines[i].redMask,
691 modelines[i].greenMask, 757 modelines[i].greenMask,
692 modelines[i].blueMask, 758 modelines[i].blueMask,
693 vo_dga_active_mode)){ 759 vo_dga_hw_mode)){
694 760
695 vd_printf(VD_DBG, "maxy: %4d, depth: %2d, %4dx%4d, ", 761 vd_printf(VD_DBG, "maxy: %4d, depth: %2d, %4dx%4d, ",
696 modelines[i].maxViewportY, modelines[i].depth, 762 modelines[i].maxViewportY, modelines[i].depth,
697 modelines[i].imageWidth, modelines[i].imageHeight ); 763 modelines[i].imageWidth, modelines[i].imageHeight );
698 if ( check_res(i, wanted_width, wanted_height, modelines[i].depth, 764 if ( check_res(i, wanted_width, wanted_height, modelines[i].depth,
701 (unsigned) modelines[i].verticalRefresh, 767 (unsigned) modelines[i].verticalRefresh,
702 &mX, &mY, &mVBI )) j = i; 768 &mX, &mY, &mVBI )) j = i;
703 } 769 }
704 } 770 }
705 vd_printf(VD_INFO, 771 vd_printf(VD_INFO,
706 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n", 772 "vo_dga: Selected hardware mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d.\n",
707 mX, mY, mVBI, 773 mX, mY, mVBI,
708 vo_dga_modes[vo_dga_active_mode].vdm_depth, 774 HW_MODE.vdm_depth,
709 vo_dga_modes[vo_dga_active_mode].vdm_bitspp, 775 HW_MODE.vdm_bitspp);
710 width, height); 776 vd_printf(VD_INFO,
711 777 "vo_dga: Video parameters by codec: %3d x %3d, depth %2d, bitspp %2d.\n",
778 width, height,
779 SRC_MODE.vdm_depth,
780 SRC_MODE.vdm_bitspp);
712 vo_dga_vp_width =mX; 781 vo_dga_vp_width =mX;
713 vo_dga_vp_height = mY; 782 vo_dga_vp_height = mY;
714 vo_dga_width = modelines[j].bytesPerScanline / BYTESPP ; 783 vo_dga_width = modelines[j].bytesPerScanline / HW_MODE.vdm_bytespp ;
715 dga_modenum = modelines[j].num; 784 dga_modenum = modelines[j].num;
716 max_vpy_pos = modelines[j].maxViewportY; 785 max_vpy_pos = modelines[j].maxViewportY;
717 786
718 XFree(modelines); 787 XFree(modelines);
719 modelines = NULL; 788 modelines = NULL;
741 XF86VidModeGetAllModeLines(vo_dga_dpy,screen,&modecount,&vo_dga_vidmodes); 810 XF86VidModeGetAllModeLines(vo_dga_dpy,screen,&modecount,&vo_dga_vidmodes);
742 811
743 if(vo_dga_vidmodes != NULL ){ 812 if(vo_dga_vidmodes != NULL ){
744 for (i=0; i<modecount; i++){ 813 for (i=0; i<modecount; i++){
745 if ( check_res(i, wanted_width, wanted_height, 814 if ( check_res(i, wanted_width, wanted_height,
746 vo_dga_modes[vo_dga_active_mode].vdm_depth, 815 vo_dga_modes[vo_dga_hw_mode].vdm_depth,
747 vo_dga_vidmodes[i]->hdisplay, 816 vo_dga_vidmodes[i]->hdisplay,
748 vo_dga_vidmodes[i]->vdisplay, 817 vo_dga_vidmodes[i]->vdisplay,
749 GET_VREFRESH(vo_dga_vidmodes[i]->dotclock, 818 GET_VREFRESH(vo_dga_vidmodes[i]->dotclock,
750 vo_dga_vidmodes[i]->htotal, 819 vo_dga_vidmodes[i]->htotal,
751 vo_dga_vidmodes[i]->vtotal), 820 vo_dga_vidmodes[i]->vtotal),
753 } 822 }
754 823
755 vd_printf(VD_INFO, 824 vd_printf(VD_INFO,
756 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n", 825 "vo_dga: Selected video mode %4d x %4d @ %3d Hz @ depth %2d, bitspp %2d, video %3d x %3d.\n",
757 mX, mY, mVBI, 826 mX, mY, mVBI,
758 vo_dga_modes[vo_dga_active_mode].vdm_depth, 827 vo_dga_modes[vo_dga_hw_mode].vdm_depth,
759 vo_dga_modes[vo_dga_active_mode].vdm_bitspp, 828 vo_dga_modes[vo_dga_hw_mode].vdm_bitspp,
760 width, height); 829 width, height);
761 }else{ 830 }else{
762 vd_printf(VD_INFO, "vo_dga: XF86VidMode returned no screens - using current resolution.\n"); 831 vd_printf(VD_INFO, "vo_dga: XF86VidMode returned no screens - using current resolution.\n");
763 } 832 }
764 dga_modenum = j; 833 dga_modenum = j;
836 #endif 905 #endif
837 906
838 // do some more checkings here ... 907 // do some more checkings here ...
839 908
840 if( format==IMGFMT_YV12 ){ 909 if( format==IMGFMT_YV12 ){
841 yuv2rgb_init( vo_dga_modes[vo_dga_active_mode].vdm_mplayer_depth , MODE_RGB ); 910 yuv2rgb_init( vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth , MODE_RGB );
842 vd_printf( VD_DBG, "vo_dga: Using mplayer depth %d for YV12\n", 911 vd_printf( VD_DBG, "vo_dga: Using mplayer depth %d for YV12\n",
843 vo_dga_modes[vo_dga_active_mode].vdm_mplayer_depth); 912 vo_dga_modes[vo_dga_hw_mode].vdm_mplayer_depth);
844 } 913 }
845 914
846 vd_printf(VD_DBG, "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n", 915 vd_printf(VD_DBG, "vo_dga: bytes/line: %d, screen res: %dx%d, depth: %d, base: %08x, bpp: %d\n",
847 vo_dga_width, vo_dga_vp_width, 916 vo_dga_width, vo_dga_vp_width,
848 vo_dga_vp_height, BYTESPP, vo_dga_base, 917 vo_dga_vp_height, HW_MODE.vdm_bytespp, vo_dga_base,
849 BITSPP); 918 HW_MODE.vdm_bitspp);
850 919
851 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1; 920 x_off = (vo_dga_vp_width - vo_dga_src_width)>>1;
852 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1; 921 y_off = (vo_dga_vp_height - vo_dga_src_height)>>1;
853 922
854 vo_dga_bytes_per_line = vo_dga_src_width * BYTESPP; 923 vo_dga_bytes_per_line = vo_dga_src_width * HW_MODE.vdm_bytespp;
855 vo_dga_lines = vo_dga_src_height; 924 vo_dga_lines = vo_dga_src_height;
856 925
857 vo_dga_src_offset = 0; 926 vo_dga_src_offset = 0;
858 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * BYTESPP; 927 vo_dga_vp_offset = (y_off * vo_dga_width + x_off ) * HW_MODE.vdm_bytespp;
859 928
860 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * BYTESPP; // todo 929 vo_dga_vp_skip = (vo_dga_width - vo_dga_src_width) * HW_MODE.vdm_bytespp; // todo
861 930
862 vd_printf(VD_DBG, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n", 931 vd_printf(VD_DBG, "vo_dga: vp_off=%d, vp_skip=%d, bpl=%d\n",
863 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line); 932 vo_dga_vp_offset, vo_dga_vp_skip, vo_dga_bytes_per_line);
864 933
865 934
872 941
873 // set up variables for double buffering ... 942 // set up variables for double buffering ...
874 // note: set vo_dga_dbf_mem_offset to NULL to disable doublebuffering 943 // note: set vo_dga_dbf_mem_offset to NULL to disable doublebuffering
875 944
876 vo_dga_dbf_y_offset = y_off + vo_dga_src_height; 945 vo_dga_dbf_y_offset = y_off + vo_dga_src_height;
877 vo_dga_dbf_mem_offset = vo_dga_width * BYTESPP * vo_dga_dbf_y_offset; 946 vo_dga_dbf_mem_offset = vo_dga_width * HW_MODE.vdm_bytespp * vo_dga_dbf_y_offset;
878 vo_dga_dbf_current = 0; 947 vo_dga_dbf_current = 0;
879 948
880 // if(format ==IMGFMT_YV12 ) 949 // if(format ==IMGFMT_YV12 )
881 //vo_dga_dbf_mem_offset = 0; 950 //vo_dga_dbf_mem_offset = 0;
882 // disable doublebuffering for YV12 951 // disable doublebuffering for YV12
891 // now clear screen 960 // now clear screen
892 { 961 {
893 int size = vo_dga_width * 962 int size = vo_dga_width *
894 (vo_dga_vp_height + (vo_dga_dbf_mem_offset != 0 ? 963 (vo_dga_vp_height + (vo_dga_dbf_mem_offset != 0 ?
895 (vo_dga_src_height+y_off) : 0)) * 964 (vo_dga_src_height+y_off) : 0)) *
896 BYTESPP; 965 HW_MODE.vdm_bytespp;
897 #ifndef HAVE_DGA2 966 #ifndef HAVE_DGA2
898 vd_printf(VD_DBG, "vo_dga: wanted size=%d, fb-size=%d\n", size, ram); 967 vd_printf(VD_DBG, "vo_dga: wanted size=%d, fb-size=%d\n", size, ram);
899 if(size>ram*1024){ 968 if(size>ram*1024){
900 vo_dga_dbf_mem_offset = 0; 969 vo_dga_dbf_mem_offset = 0;
901 vd_printf(VD_INFO, "vo_dga: Not enough memory for double buffering!\n"); 970 vd_printf(VD_INFO, "vo_dga: Not enough memory for double buffering!\n");
902 size -= (vo_dga_src_height+y_off) * vo_dga_width * BYTESPP; 971 size -= (vo_dga_src_height+y_off) * vo_dga_width * HW_MODE.vdm_bytespp;
903 } 972 }
904 #endif 973 #endif
905 974
906 vd_printf(VD_INFO, "vo_dga: Clearing framebuffer (%d bytes). If mplayer exits", size); 975 vd_printf(VD_INFO, "vo_dga: Clearing framebuffer (%d bytes). If mplayer exits", size);
907 vd_printf(VD_INFO, " here, you haven't enough memory on your card.\n"); 976 vd_printf(VD_INFO, " here, you haven't enough memory on your card.\n");