Mercurial > mplayer.hg
comparison libvo/vo_xv.c @ 5509:1e90dd889c34
initialization moved to preinit(), query_format now really checks for supported formats
author | arpi |
---|---|
date | Sun, 07 Apr 2002 02:10:39 +0000 |
parents | ea1ae0e3ea19 |
children | e01c664def74 |
comparison
equal
deleted
inserted
replaced
5508:53ce50ac2ce2 | 5509:1e90dd889c34 |
---|---|
312 char *hello = (title == NULL) ? "Xv render" : title; | 312 char *hello = (title == NULL) ? "Xv render" : title; |
313 // char *name = ":0.0"; | 313 // char *name = ":0.0"; |
314 XSizeHints hint; | 314 XSizeHints hint; |
315 XVisualInfo vinfo; | 315 XVisualInfo vinfo; |
316 XEvent xev; | 316 XEvent xev; |
317 XvPortID xv_p; | |
318 | 317 |
319 XGCValues xgcv; | 318 XGCValues xgcv; |
320 XSetWindowAttributes xswa; | 319 XSetWindowAttributes xswa; |
321 unsigned long xswamask; | 320 unsigned long xswamask; |
322 #ifdef HAVE_XF86VM | 321 #ifdef HAVE_XF86VM |
340 #ifdef HAVE_XF86VM | 339 #ifdef HAVE_XF86VM |
341 if( flags&0x02 ) vm = 1; | 340 if( flags&0x02 ) vm = 1; |
342 #endif | 341 #endif |
343 flip_flag=flags&8; | 342 flip_flag=flags&8; |
344 num_buffers=vo_doublebuffering?NUM_BUFFERS:1; | 343 num_buffers=vo_doublebuffering?NUM_BUFFERS:1; |
344 | |
345 /* check image formats */ | |
346 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); | |
347 xv_format=0; | |
348 if(format==IMGFMT_BGR24) format=IMGFMT_YV12; | |
349 for(i = 0; i < formats; i++){ | |
350 printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); | |
351 if (fo[i].id == format) xv_format = fo[i].id; | |
352 } | |
353 if (!xv_format) return -1; | |
345 | 354 |
346 if (!vo_init()) return -1; | |
347 | |
348 aspect_save_screenres(vo_screenwidth,vo_screenheight); | 355 aspect_save_screenres(vo_screenwidth,vo_screenheight); |
349 | 356 |
350 #ifdef HAVE_NEW_GUI | 357 #ifdef HAVE_NEW_GUI |
351 if ( vo_window == None ) | 358 if ( vo_window == None ) |
352 { | 359 { |
437 #endif | 444 #endif |
438 #ifdef HAVE_NEW_GUI | 445 #ifdef HAVE_NEW_GUI |
439 } | 446 } |
440 #endif | 447 #endif |
441 | 448 |
442 xv_port = 0; | |
443 if (Success == XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)) | |
444 { | |
445 /* check for Xvideo support */ | |
446 if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)) | |
447 { | |
448 printf("Xv: XvQueryAdaptors failed"); | |
449 return -1; | |
450 } | |
451 /* check adaptors */ | |
452 for (i = 0; i < adaptors && xv_port == 0; i++) | |
453 { | |
454 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
455 for (xv_p = ai[i].base_id; xv_p < ai[i].base_id+ai[i].num_ports; ++xv_p) | |
456 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) { | |
457 xv_port = xv_p; | |
458 break; | |
459 } else { | |
460 printf("Xv: could not grab port %i\n", (int)xv_p); | |
461 } | |
462 } | |
463 /* check image formats */ | |
464 if (xv_port != 0) | |
465 { | |
466 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); | |
467 xv_format=0; | |
468 if(format==IMGFMT_BGR24) format=IMGFMT_YV12; | |
469 for(i = 0; i < formats; i++){ | |
470 printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); | |
471 if (fo[i].id == format) xv_format = fo[i].id; | |
472 } | |
473 if (!xv_format) xv_port = 0; | |
474 } | |
475 | |
476 if (xv_port != 0) | |
477 { | |
478 printf( "using Xvideo port %d for hw scaling\n",xv_port ); | 449 printf( "using Xvideo port %d for hw scaling\n",xv_port ); |
479 | 450 |
480 switch (xv_format){ | 451 switch (xv_format){ |
481 case IMGFMT_YV12: | 452 case IMGFMT_YV12: |
482 case IMGFMT_I420: | 453 case IMGFMT_I420: |
511 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); | 482 drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); |
512 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); | 483 printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight ); |
513 } | 484 } |
514 saver_off(mDisplay); // turning off screen saver | 485 saver_off(mDisplay); // turning off screen saver |
515 return 0; | 486 return 0; |
516 } | |
517 } | |
518 | |
519 printf("Sorry, Xv not supported by this X11 version/driver\n"); | |
520 printf("******** Try with -vo x11 or -vo sdl *********\n"); | |
521 return 1; | |
522 } | 487 } |
523 | 488 |
524 static const vo_info_t * get_info(void) | 489 static const vo_info_t * get_info(void) |
525 { return &vo_info; } | 490 { return &vo_info; } |
526 | 491 |
743 } | 708 } |
744 | 709 |
745 | 710 |
746 static uint32_t query_format(uint32_t format) | 711 static uint32_t query_format(uint32_t format) |
747 { | 712 { |
748 | 713 int flag=1; |
714 /* check image formats */ | |
715 fo = XvListImageFormats(mDisplay, xv_port, (int*)&formats); | |
716 if(format==IMGFMT_BGR24){ format=IMGFMT_YV12;flag|=2;} // conversion! | |
717 for(i = 0; i < formats; i++){ | |
718 // printf("Xvideo image format: 0x%x (%4.4s) %s\n", fo[i].id,(char*)&fo[i].id, (fo[i].format == XvPacked) ? "packed" : "planar"); | |
719 if (fo[i].id == format) return flag; //xv_format = fo[i].id; | |
720 } | |
721 return 0; | |
722 | |
723 /* | |
749 switch(format){ | 724 switch(format){ |
750 case IMGFMT_YUY2: | 725 case IMGFMT_YUY2: |
751 case IMGFMT_UYVY: | 726 case IMGFMT_UYVY: |
752 case IMGFMT_YVYU: | 727 case IMGFMT_YVYU: |
753 | 728 |
758 case IMGFMT_BGR24: | 733 case IMGFMT_BGR24: |
759 | 734 |
760 // umm, this is a kludge, we need to ask the server.. (see init function above) | 735 // umm, this is a kludge, we need to ask the server.. (see init function above) |
761 return 1; | 736 return 1; |
762 } | 737 } |
763 | |
764 return 0; | 738 return 0; |
739 */ | |
765 | 740 |
766 } | 741 } |
767 | 742 |
768 static void uninit(void) | 743 static void uninit(void) |
769 { | 744 { |
770 int i; | 745 int i; |
771 if(!mDisplay) return; | 746 if(!mDisplay) return; |
772 saver_on(mDisplay); // screen saver back on | 747 saver_on(mDisplay); // screen saver back on |
773 for( i=0;i<num_buffers;i++ ) deallocate_xvimage( i ); | 748 if(vo_config_count) for( i=0;i<num_buffers;i++ ) deallocate_xvimage( i ); |
774 #ifdef HAVE_XF86VM | 749 #ifdef HAVE_XF86VM |
775 vo_vm_close(mDisplay); | 750 vo_vm_close(mDisplay); |
776 #endif | 751 #endif |
777 vo_x11_uninit(mDisplay, vo_window); | 752 if(vo_config_count) vo_x11_uninit(mDisplay, vo_window); |
778 } | 753 } |
779 | 754 |
780 static uint32_t preinit(const char *arg) | 755 static uint32_t preinit(const char *arg) |
781 { | 756 { |
757 XvPortID xv_p; | |
782 if(arg) | 758 if(arg) |
783 { | 759 { |
784 printf("vo_xv: Unknown subdevice: %s\n",arg); | 760 printf("vo_xv: Unknown subdevice: %s\n",arg); |
785 return ENOSYS; | 761 return ENOSYS; |
786 } | 762 } |
763 if (!vo_init()) return -1; | |
764 | |
765 xv_port = 0; | |
766 /* check for Xvideo extension */ | |
767 if (Success != XvQueryExtension(mDisplay,&ver,&rel,&req,&ev,&err)){ | |
768 printf("Sorry, Xv not supported by this X11 version/driver\n"); | |
769 printf("******** Try with -vo x11 or -vo sdl *********\n"); | |
770 return -1; | |
771 } | |
772 | |
773 /* check for Xvideo support */ | |
774 if (Success != XvQueryAdaptors(mDisplay,DefaultRootWindow(mDisplay), &adaptors,&ai)){ | |
775 printf("Xv: XvQueryAdaptors failed"); | |
776 return -1; | |
777 } | |
778 | |
779 /* check adaptors */ | |
780 for (i = 0; i < adaptors && xv_port == 0; i++){ | |
781 if ((ai[i].type & XvInputMask) && (ai[i].type & XvImageMask)) | |
782 for (xv_p = ai[i].base_id; xv_p < ai[i].base_id+ai[i].num_ports; ++xv_p) | |
783 if (!XvGrabPort(mDisplay, xv_p, CurrentTime)) { | |
784 xv_port = xv_p; | |
785 break; | |
786 } else { | |
787 printf("Xv: could not grab port %i\n", (int)xv_p); | |
788 } | |
789 } | |
790 if(!xv_port){ | |
791 printf("Couldn't find free Xvideo port - maybe other applications keep open it\n"); | |
792 return -1; | |
793 } | |
794 | |
787 return 0; | 795 return 0; |
788 } | 796 } |
789 | 797 |
790 static void query_vaa(vo_vaa_t *vaa) | 798 static void query_vaa(vo_vaa_t *vaa) |
791 { | 799 { |