comparison libvo/vo_sdl.c @ 18234:a107276371a8

Part 5 and final of otvos attila's oattila AT chello-hu mp_msg changes, with lots of corrections
author reynaldo
date Mon, 24 Apr 2006 04:23:53 +0000
parents 3fe3b2b3a6ce
children 5766a9d21992
comparison
equal deleted inserted replaced
18233:30fcc199bec7 18234:a107276371a8
105 #include <string.h> 105 #include <string.h>
106 #include <inttypes.h> 106 #include <inttypes.h>
107 107
108 #include "mp_msg.h" 108 #include "mp_msg.h"
109 #include "config.h" 109 #include "config.h"
110 #include "mp_msg.h"
111 #include "help_mp.h"
110 #include "video_out.h" 112 #include "video_out.h"
111 #include "video_out_internal.h" 113 #include "video_out_internal.h"
112 114
113 #include "fastmemcpy.h" 115 #include "fastmemcpy.h"
114 #include "sub.h" 116 #include "sub.h"
139 141
140 142
141 #ifdef SDL_ENABLE_LOCKS 143 #ifdef SDL_ENABLE_LOCKS
142 #define SDL_OVR_LOCK(x) if (SDL_LockYUVOverlay (priv->overlay)) { \ 144 #define SDL_OVR_LOCK(x) if (SDL_LockYUVOverlay (priv->overlay)) { \
143 if( mp_msg_test(MSGT_VO,MSGL_V) ) { \ 145 if( mp_msg_test(MSGT_VO,MSGL_V) ) { \
144 printf("SDL: Couldn't lock YUV overlay\n");} \ 146 mp_msg(MSGT_VO,MSGL_V, "SDL: Couldn't lock YUV overlay\n"); } \
145 return x; \ 147 return x; \
146 } 148 }
147 #define SDL_OVR_UNLOCK SDL_UnlockYUVOverlay (priv->overlay); 149 #define SDL_OVR_UNLOCK SDL_UnlockYUVOverlay (priv->overlay);
148 150
149 #define SDL_SRF_LOCK(srf, x) if(SDL_MUSTLOCK(srf)) { \ 151 #define SDL_SRF_LOCK(srf, x) if(SDL_MUSTLOCK(srf)) { \
150 if(SDL_LockSurface (srf)) { \ 152 if(SDL_LockSurface (srf)) { \
151 if( mp_msg_test(MSGT_VO,MSGL_V) ) { \ 153 if( mp_msg_test(MSGT_VO,MSGL_V) ) { \
152 printf("SDL: Couldn't lock RGB surface\n"); } \ 154 mp_msg(MSGT_VO,MSGL_V, "SDL: Couldn't lock RGB surface\n"); } \
153 return x; \ 155 return x; \
154 } \ 156 } \
155 } 157 }
156 158
157 #define SDL_SRF_UNLOCK(srf) if(SDL_MUSTLOCK(srf)) \ 159 #define SDL_SRF_UNLOCK(srf) if(SDL_MUSTLOCK(srf)) \
422 424
423 425
424 /* other default values */ 426 /* other default values */
425 #ifdef SDL_NOHWSURFACE 427 #ifdef SDL_NOHWSURFACE
426 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 428 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
427 printf("SDL: using software-surface\n"); } 429 mp_msg(MSGT_VO,MSGL_V, "SDL: using software-surface\n"); }
428 priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ANYFORMAT; 430 priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ANYFORMAT;
429 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ANYFORMAT; 431 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ANYFORMAT;
430 // XXX:FIXME: ASYNCBLIT should be enabled for SMP systems 432 // XXX:FIXME: ASYNCBLIT should be enabled for SMP systems
431 #else 433 #else
432 /*if((strcmp(priv->driver, "dga") == 0) && (priv->mode)) { 434 /*if((strcmp(priv->driver, "dga") == 0) && (priv->mode)) {
435 priv->sdlflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT; 437 priv->sdlflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT;
436 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT; 438 priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT;
437 } 439 }
438 else { */ 440 else { */
439 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 441 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
440 printf("SDL: using hardware-surface\n"); } 442 mp_msg(MSGT_VO,MSGL_V, "SDL: using hardware-surface\n"); }
441 priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE/*|SDL_ANYFORMAT*/; 443 priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE/*|SDL_ANYFORMAT*/;
442 priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN/*|SDL_ANYFORMAT*/; 444 priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN/*|SDL_ANYFORMAT*/;
443 // XXX:FIXME: ASYNCBLIT should be enabled for SMP systems 445 // XXX:FIXME: ASYNCBLIT should be enabled for SMP systems
444 //} 446 //}
445 #endif 447 #endif
471 * That's all we have. If this fails there's nothing left. 473 * That's all we have. If this fails there's nothing left.
472 * Theoretically there could be Fullscreenmodes left - we ignore this for now. 474 * Theoretically there could be Fullscreenmodes left - we ignore this for now.
473 */ 475 */
474 priv->sdlflags &= ~SDL_HWSURFACE; 476 priv->sdlflags &= ~SDL_HWSURFACE;
475 if ((!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) && (!priv->fullmodes)) { 477 if ((!SDL_ListModes (vidInfo->vfmt, priv->sdlflags)) && (!priv->fullmodes)) {
476 printf("SDL: Couldn't get any acceptable SDL Mode for output.\n"); 478 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SDL_CouldntGetAnyAcceptableSDLModeForOutput);
477 return -1; 479 return -1;
478 } 480 }
479 } 481 }
480 482
481 483
486 */ 488 */
487 priv->bpp = vidInfo->vfmt->BitsPerPixel; 489 priv->bpp = vidInfo->vfmt->BitsPerPixel;
488 if (priv->mode == YUV && priv->bpp < 16) { 490 if (priv->mode == YUV && priv->bpp < 16) {
489 491
490 if( mp_msg_test(MSGT_VO,MSGL_V) ) 492 if( mp_msg_test(MSGT_VO,MSGL_V) )
491 printf("SDL: Your SDL display target wants to be at a color " 493 mp_msg(MSGT_VO,MSGL_V, "SDL: Your SDL display target wants to be at a color "
492 "depth of (%d), but we need it to be at least 16 " 494 "depth of (%d), but we need it to be at least 16 "
493 "bits, so we need to emulate 16-bit color. This is " 495 "bits, so we need to emulate 16-bit color. This is "
494 "going to slow things down; you might want to " 496 "going to slow things down; you might want to "
495 "increase your display's color depth, if possible.\n", 497 "increase your display's color depth, if possible.\n",
496 priv->bpp); 498 priv->bpp);
565 567
566 #if 0 568 #if 0
567 static SDL_Rect aspect(int srcw, int srch, int dstw, int dsth) { 569 static SDL_Rect aspect(int srcw, int srch, int dstw, int dsth) {
568 SDL_Rect newres; 570 SDL_Rect newres;
569 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 571 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
570 printf("SDL Aspect: src: %ix%i dst: %ix%i\n", srcw, srch, dstw, dsth); } 572 mp_msg(MSGT_VO,MSGL_V, "SDL Aspect-Destinationres: %ix%i (x: %i, y: %i)\n", newres.w, newres.h, newres.x, newres.y); }
571 newres.h = ((float)dstw / (float)srcw * (float)srch) * ((float)dsth/((float)dstw/(MONITOR_ASPECT))); 573 newres.h = ((float)dstw / (float)srcw * (float)srch) * ((float)dsth/((float)dstw/(MONITOR_ASPECT)));
572 if(newres.h > dsth) { 574 if(newres.h > dsth) {
573 newres.w = ((float)dsth / (float)newres.h) * dstw; 575 newres.w = ((float)dsth / (float)newres.h) * dstw;
574 newres.h = dsth; 576 newres.h = dsth;
575 newres.x = (dstw - newres.w) / 2; 577 newres.x = (dstw - newres.w) / 2;
580 newres.x = 0; 582 newres.x = 0;
581 newres.y = (dsth - newres.h) / 2; 583 newres.y = (dsth - newres.h) / 2;
582 } 584 }
583 585
584 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 586 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
585 printf("SDL Aspect-Destinationres: %ix%i (x: %i, y: %i)\n", newres.w, newres.h, newres.x, newres.y); } 587 mp_msg(MSGT_VO,MSGL_V, "SDL Mode: %d: %d x %d\n", i, priv->fullmodes[i]->w, priv->fullmodes[i]->h); }
586 588
587 return newres; 589 return newres;
588 } 590 }
589 #endif 591 #endif
590 592
656 priv->dstheight = height; 658 priv->dstheight = height;
657 659
658 setup_surfaces(); 660 setup_surfaces();
659 } 661 }
660 else 662 else
661 printf("set_video_mode: SDL_SetVideoMode failed: %s\n", SDL_GetError()); 663 mp_msg(MSGT_VO,MSGL_WARN, "set_video_mode: SDL_SetVideoMode failed: %s\n", SDL_GetError());
662 } 664 }
663 665
664 static void set_fullmode (int mode) { 666 static void set_fullmode (int mode) {
665 struct sdl_priv_s *priv = &sdl_priv; 667 struct sdl_priv_s *priv = &sdl_priv;
666 SDL_Surface *newsurface = NULL; 668 SDL_Surface *newsurface = NULL;
682 } 684 }
683 else if (mode < 0) { 685 else if (mode < 0) {
684 int i,j,imax; 686 int i,j,imax;
685 mode = 0; // Default to the biggest mode avaible 687 mode = 0; // Default to the biggest mode avaible
686 if ( mp_msg_test(MSGT_VO,MSGL_V) ) for(i=0;priv->fullmodes[i];++i) 688 if ( mp_msg_test(MSGT_VO,MSGL_V) ) for(i=0;priv->fullmodes[i];++i)
687 printf("SDL Mode: %d: %d x %d\n", i, priv->fullmodes[i]->w, priv->fullmodes[i]->h); 689 mp_msg(MSGT_VO,MSGL_V, "SDL Mode: %d: %d x %d\n", i, priv->fullmodes[i]->w, priv->fullmodes[i]->h);
688 for(i = findArrayEnd(priv->fullmodes) - 1; i >=0; i--) { 690 for(i = findArrayEnd(priv->fullmodes) - 1; i >=0; i--) {
689 if( (priv->fullmodes[i]->w >= priv->dstwidth) && 691 if( (priv->fullmodes[i]->w >= priv->dstwidth) &&
690 (priv->fullmodes[i]->h >= priv->dstheight) ) { 692 (priv->fullmodes[i]->h >= priv->dstheight) ) {
691 imax = i; 693 imax = i;
692 for (j = findArrayEnd(priv->fullmodes) - 1; j >=0; j--) { 694 for (j = findArrayEnd(priv->fullmodes) - 1; j >=0; j--) {
697 mode = imax; 699 mode = imax;
698 break; 700 break;
699 } 701 }
700 } 702 }
701 if ( mp_msg_test(MSGT_VO,MSGL_V) ) { 703 if ( mp_msg_test(MSGT_VO,MSGL_V) ) {
702 printf("SET SDL Mode: %d: %d x %d\n", mode, priv->fullmodes[mode]->w, priv->fullmodes[mode]->h); } 704 mp_msg(MSGT_VO,MSGL_V, "SET SDL Mode: %d: %d x %d\n", mode, priv->fullmodes[mode]->w, priv->fullmodes[mode]->h); }
703 priv->fullmode = mode; 705 priv->fullmode = mode;
704 screen_surface_h = priv->fullmodes[mode]->h; 706 screen_surface_h = priv->fullmodes[mode]->h;
705 screen_surface_w = priv->fullmodes[mode]->w; 707 screen_surface_w = priv->fullmodes[mode]->w;
706 } 708 }
707 else { 709 else {
756 SDL_FillRect(priv->surface, NULL, 0); 758 SDL_FillRect(priv->surface, NULL, 0);
757 SDL_SRF_UNLOCK(priv->surface) 759 SDL_SRF_UNLOCK(priv->surface)
758 setup_surfaces(); 760 setup_surfaces();
759 } 761 }
760 else 762 else
761 printf("set_fullmode: SDL_SetVideoMode failed: %s\n", SDL_GetError()); 763 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_SetVideoModeFailedFull, SDL_GetError());
762 } 764 }
763 765
764 766
765 /** 767 /**
766 * Initialize an SDL surface and an SDL YUV overlay. 768 * Initialize an SDL surface and an SDL YUV overlay.
778 { 780 {
779 struct sdl_priv_s *priv = &sdl_priv; 781 struct sdl_priv_s *priv = &sdl_priv;
780 782
781 switch(format){ 783 switch(format){
782 case IMGFMT_I420: 784 case IMGFMT_I420:
783 printf("SDL: Mapping I420 to IYUV\n"); 785 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_MappingI420ToIYUV);
784 format = SDL_IYUV_OVERLAY; 786 format = SDL_IYUV_OVERLAY;
785 case IMGFMT_YV12: 787 case IMGFMT_YV12:
786 case IMGFMT_IYUV: 788 case IMGFMT_IYUV:
787 case IMGFMT_YUY2: 789 case IMGFMT_YUY2:
788 case IMGFMT_UYVY: 790 case IMGFMT_UYVY:
800 case IMGFMT_RGB24: 802 case IMGFMT_RGB24:
801 case IMGFMT_RGB32: 803 case IMGFMT_RGB32:
802 priv->mode = RGB; 804 priv->mode = RGB;
803 break; 805 break;
804 default: 806 default:
805 printf("SDL: Unsupported image format (0x%X)\n",format); 807 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_UnsupportedImageFormat,format);
806 return -1; 808 return -1;
807 } 809 }
808 810
809 if ( vo_config_count ) sdl_close(); 811 if ( vo_config_count ) sdl_close();
810 812
811 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 813 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
812 printf("SDL: Using 0x%X (%s) image format\n", format, vo_format_name(format)); } 814 mp_msg(MSGT_VO,MSGL_V, "SDL: Using 0x%X (%s) image format\n", format, vo_format_name(format)); }
813 815
814 if(priv->mode != YUV) { 816 if(priv->mode != YUV) {
815 priv->sdlflags |= SDL_ANYFORMAT; 817 priv->sdlflags |= SDL_ANYFORMAT;
816 priv->sdlfullflags |= SDL_ANYFORMAT; 818 priv->sdlfullflags |= SDL_ANYFORMAT;
817 } 819 }
855 */ 857 */
856 // printf("SDL: flags are set to: %i\n", flags); 858 // printf("SDL: flags are set to: %i\n", flags);
857 // printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height); 859 // printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height);
858 if(flags&VOFLAG_FLIPPING) { 860 if(flags&VOFLAG_FLIPPING) {
859 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 861 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
860 printf("SDL: using flipped video (only with RGB/BGR/packed YUV)\n"); } 862 mp_msg(MSGT_VO,MSGL_V, "SDL: using flipped video (only with RGB/BGR/packed YUV)\n"); }
861 priv->flip = 1; 863 priv->flip = 1;
862 } 864 }
863 if(flags&VOFLAG_FULLSCREEN) { 865 if(flags&VOFLAG_FULLSCREEN) {
864 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 866 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
865 printf("SDL: setting zoomed fullscreen without modeswitching\n"); } 867 mp_msg(MSGT_VO,MSGL_V, "SDL: setting zoomed fullscreen without modeswitching\n");}
866 printf("SDL: Info - please use -vm or -zoom to switch to best resolution.\n"); 868 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_InfoPleaseUseVmOrZoom);
867 priv->fulltype = VOFLAG_FULLSCREEN; 869 priv->fulltype = VOFLAG_FULLSCREEN;
868 set_fullmode(priv->fullmode); 870 set_fullmode(priv->fullmode);
869 /*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags))) 871 /*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)))
870 SDL_ShowCursor(0);*/ 872 SDL_ShowCursor(0);*/
871 } else 873 } else
872 if(flags&VOFLAG_MODESWITCHING) { 874 if(flags&VOFLAG_MODESWITCHING) {
873 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 875 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
874 printf("SDL: setting zoomed fullscreen with modeswitching\n"); } 876 mp_msg(MSGT_VO,MSGL_V, "SDL: setting zoomed fullscreen with modeswitching\n"); }
875 priv->fulltype = VOFLAG_MODESWITCHING; 877 priv->fulltype = VOFLAG_MODESWITCHING;
876 set_fullmode(priv->fullmode); 878 set_fullmode(priv->fullmode);
877 /*if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags))) 879 /*if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags)))
878 SDL_ShowCursor(0);*/ 880 SDL_ShowCursor(0);*/
879 } else 881 } else
880 if(flags&VOFLAG_SWSCALE) { 882 if(flags&VOFLAG_SWSCALE) {
881 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 883 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
882 printf("SDL: setting zoomed fullscreen with modeswitching\n"); } 884 mp_msg(MSGT_VO,MSGL_V, "SDL: setting zoomed fullscreen with modeswitching\n"); }
883 priv->fulltype = VOFLAG_SWSCALE; 885 priv->fulltype = VOFLAG_SWSCALE;
884 set_fullmode(priv->fullmode); 886 set_fullmode(priv->fullmode);
885 } 887 }
886 else { 888 else {
887 if((strcmp(priv->driver, "x11") == 0) 889 if((strcmp(priv->driver, "x11") == 0)
889 ||(strcmp(priv->driver, "directx") == 0) 891 ||(strcmp(priv->driver, "directx") == 0)
890 ||(strcmp(priv->driver, "Quartz") == 0) 892 ||(strcmp(priv->driver, "Quartz") == 0)
891 ||(strcmp(priv->driver, "cgx") == 0) 893 ||(strcmp(priv->driver, "cgx") == 0)
892 ||((strcmp(priv->driver, "aalib") == 0) && priv->X)){ 894 ||((strcmp(priv->driver, "aalib") == 0) && priv->X)){
893 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 895 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
894 printf("SDL: setting windowed mode\n"); } 896 mp_msg(MSGT_VO,MSGL_V, "SDL: setting windowed mode\n"); }
895 set_video_mode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags); 897 set_video_mode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags);
896 } 898 }
897 else { 899 else {
898 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 900 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
899 printf("SDL: setting zoomed fullscreen with modeswitching\n"); } 901 mp_msg(MSGT_VO,MSGL_V, "SDL: setting zoomed fullscreen with modeswitching\n"); }
900 priv->fulltype = VOFLAG_SWSCALE; 902 priv->fulltype = VOFLAG_SWSCALE;
901 set_fullmode(priv->fullmode); 903 set_fullmode(priv->fullmode);
902 } 904 }
903 } 905 }
904 906
905 if(!priv->surface) { // cannot SetVideoMode 907 if(!priv->surface) { // cannot SetVideoMode
906 printf("SDL: failed to set video mode: %s\n", SDL_GetError()); 908 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_FailedToSetVideoMode, SDL_GetError());
907 return -1; 909 return -1;
908 } 910 }
909 911
910 return 0; 912 return 0;
911 } 913 }
989 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0/*0xFF000000*/); 991 priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, surfwidth, surfheight, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0/*0xFF000000*/);
990 break; 992 break;
991 default: 993 default:
992 /* Initialize and create the YUV Overlay used for video out */ 994 /* Initialize and create the YUV Overlay used for video out */
993 if (!(priv->overlay = SDL_CreateYUVOverlay (surfwidth, surfheight, priv->format, priv->surface))) { 995 if (!(priv->overlay = SDL_CreateYUVOverlay (surfwidth, surfheight, priv->format, priv->surface))) {
994 printf ("SDL: Couldn't create a YUV overlay: %s\n", SDL_GetError()); 996 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_CouldntCreateAYUVOverlay, SDL_GetError());
995 return -1; 997 return -1;
996 } 998 }
997 priv->framePlaneY = priv->width * priv->height; 999 priv->framePlaneY = priv->width * priv->height;
998 priv->framePlaneUV = (priv->width * priv->height) >> 2; 1000 priv->framePlaneUV = (priv->width * priv->height) >> 2;
999 priv->framePlaneYUY = priv->width * priv->height * 2; 1001 priv->framePlaneYUY = priv->width * priv->height * 2;
1002 priv->stridePlaneYUY = priv->width * 2; 1004 priv->stridePlaneYUY = priv->width * 2;
1003 } 1005 }
1004 1006
1005 if(priv->mode != YUV) { 1007 if(priv->mode != YUV) {
1006 if(!priv->rgbsurface) { 1008 if(!priv->rgbsurface) {
1007 printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError()); 1009 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_CouldntCreateARGBSurface, SDL_GetError());
1008 return -1; 1010 return -1;
1009 } 1011 }
1010 1012
1011 priv->dblit = 0; 1013 priv->dblit = 0;
1012 1014
1013 if((priv->format&0xFF) != priv->bpp) 1015 if((priv->format&0xFF) != priv->bpp)
1014 printf("SDL: using depth/colorspace conversion, this will slow things" 1016 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_UsingDepthColorspaceConversion, priv->format&0xFF, priv->bpp);
1015 "down (%ibpp -> %ibpp).\n", priv->format&0xFF, priv->bpp);
1016 1017
1017 priv->framePlaneRGB = priv->width * priv->height * priv->rgbsurface->format->BytesPerPixel; 1018 priv->framePlaneRGB = priv->width * priv->height * priv->rgbsurface->format->BytesPerPixel;
1018 priv->stridePlaneRGB = priv->width * priv->rgbsurface->format->BytesPerPixel; 1019 priv->stridePlaneRGB = priv->width * priv->rgbsurface->format->BytesPerPixel;
1019 } 1020 }
1020 1021
1138 dst = priv->overlay->pixels[2] + priv->overlay->pitches[2]*y + x; 1139 dst = priv->overlay->pixels[2] + priv->overlay->pitches[2]*y + x;
1139 memcpy_pic(dst, image[2], w, h, priv->overlay->pitches[2], stride[2]); 1140 memcpy_pic(dst, image[2], w, h, priv->overlay->pitches[2], stride[2]);
1140 1141
1141 break; 1142 break;
1142 default: 1143 default:
1143 printf("SDL: unsupported image format in draw_slice, contact MPlayer developers!\n"); 1144 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_UnsupportedImageFormatInDrawslice);
1144 } 1145 }
1145 1146
1146 SDL_OVR_UNLOCK 1147 SDL_OVR_UNLOCK
1147 1148
1148 return 0; 1149 return 0;
1180 //if(!(priv->surface->flags & SDL_FULLSCREEN)) { 1181 //if(!(priv->surface->flags & SDL_FULLSCREEN)) {
1181 priv->windowsize.w = priv->surface->w; 1182 priv->windowsize.w = priv->surface->w;
1182 priv->windowsize.h = priv->surface->h; 1183 priv->windowsize.h = priv->surface->h;
1183 //} 1184 //}
1184 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { 1185 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) {
1185 printf("SDL: Window resize\n"); } 1186 mp_msg(MSGT_VO,MSGL_DBG3, "SDL: Window resize\n"); }
1186 break; 1187 break;
1187 1188
1188 case SDL_MOUSEBUTTONDOWN: 1189 case SDL_MOUSEBUTTONDOWN:
1189 if(vo_nomouse_input) 1190 if(vo_nomouse_input)
1190 break; 1191 break;
1221 #else 1222 #else
1222 case SDL_KEYDOWN: 1223 case SDL_KEYDOWN:
1223 #endif 1224 #endif
1224 keypressed = event.key.keysym.sym; 1225 keypressed = event.key.keysym.sym;
1225 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { 1226 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
1226 printf("SDL: Key pressed: '%i'\n", keypressed); } 1227 mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Key pressed: '%i'\n", keypressed); }
1227 1228
1228 /* c key pressed. c cycles through available fullscreenmodes, if we have some */ 1229 /* c key pressed. c cycles through available fullscreenmodes, if we have some */
1229 if ( ((keypressed == SDLK_c)) && (priv->fullmodes) ) { 1230 if ( ((keypressed == SDLK_c)) && (priv->fullmodes) ) {
1230 /* select next fullscreen mode */ 1231 /* select next fullscreen mode */
1231 priv->fullmode++; 1232 priv->fullmode++;
1232 if (priv->fullmode > (findArrayEnd(priv->fullmodes) - 1)) priv->fullmode = 0; 1233 if (priv->fullmode > (findArrayEnd(priv->fullmodes) - 1)) priv->fullmode = 0;
1233 set_fullmode(priv->fullmode); 1234 set_fullmode(priv->fullmode);
1234 1235
1235 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { 1236 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
1236 printf("SDL: Set next available fullscreen mode.\n"); } 1237 mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Set next available fullscreen mode.\n"); }
1237 } 1238 }
1238 1239
1239 else if ( keypressed == SDLK_n ) { 1240 else if ( keypressed == SDLK_n ) {
1240 #ifdef HAVE_X11 1241 #ifdef HAVE_X11
1241 aspect(&priv->dstwidth, &priv->dstheight,A_NOZOOM); 1242 aspect(&priv->dstwidth, &priv->dstheight,A_NOZOOM);
1243 if (priv->surface->w != priv->dstwidth || priv->surface->h != priv->dstheight) { 1244 if (priv->surface->w != priv->dstwidth || priv->surface->h != priv->dstheight) {
1244 set_video_mode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags); 1245 set_video_mode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags);
1245 priv->windowsize.w = priv->surface->w; 1246 priv->windowsize.w = priv->surface->w;
1246 priv->windowsize.h = priv->surface->h; 1247 priv->windowsize.h = priv->surface->h;
1247 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { 1248 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
1248 printf("SDL: Normal size\n"); } 1249 mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Normal size\n"); }
1249 } else 1250 } else
1250 if (priv->surface->w != priv->dstwidth * 2 || priv->surface->h != priv->dstheight * 2) { 1251 if (priv->surface->w != priv->dstwidth * 2 || priv->surface->h != priv->dstheight * 2) {
1251 set_video_mode(priv->dstwidth * 2, priv->dstheight * 2, priv->bpp, priv->sdlflags); 1252 set_video_mode(priv->dstwidth * 2, priv->dstheight * 2, priv->bpp, priv->sdlflags);
1252 priv->windowsize.w = priv->surface->w; 1253 priv->windowsize.w = priv->surface->w;
1253 priv->windowsize.h = priv->surface->h; 1254 priv->windowsize.h = priv->surface->h;
1254 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { 1255 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
1255 printf("SDL: Double size\n"); } 1256 mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Double size\n"); }
1256 } 1257 }
1257 } 1258 }
1258 1259
1259 else switch(keypressed){ 1260 else switch(keypressed){
1260 case SDLK_RETURN: mplayer_put_key(KEY_ENTER);break; 1261 case SDLK_RETURN: mplayer_put_key(KEY_ENTER);break;
1509 case IMGFMT_RGB32: 1510 case IMGFMT_RGB32:
1510 case IMGFMT_BGR32: 1511 case IMGFMT_BGR32:
1511 if(!priv->dblit) { 1512 if(!priv->dblit) {
1512 /* blit to the RGB surface */ 1513 /* blit to the RGB surface */
1513 if(SDL_BlitSurface (priv->rgbsurface, NULL, priv->surface, NULL)) 1514 if(SDL_BlitSurface (priv->rgbsurface, NULL, priv->surface, NULL))
1514 printf("SDL: Blit failed: %s\n", SDL_GetError()); 1515 mp_msg(MSGT_VO,MSGL_WARN, MSGTR_LIBVO_SDL_BlitFailed, SDL_GetError());
1515 } 1516 }
1516 1517
1517 /* update screen */ 1518 /* update screen */
1518 //SDL_UpdateRect(priv->surface, 0, 0, priv->surface->clip_rect.w, priv->surface->clip_rect.h); 1519 //SDL_UpdateRect(priv->surface, 0, 0, priv->surface->clip_rect.w, priv->surface->clip_rect.h);
1519 if(priv->osd_has_changed) { 1520 if(priv->osd_has_changed) {
1573 { 1574 {
1574 #ifdef HAVE_X11 1575 #ifdef HAVE_X11
1575 struct sdl_priv_s *priv = &sdl_priv; 1576 struct sdl_priv_s *priv = &sdl_priv;
1576 if(priv->X) { 1577 if(priv->X) {
1577 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 1578 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
1578 printf("SDL: activating XScreensaver/DPMS\n"); } 1579 mp_msg(MSGT_VO,MSGL_V, "SDL: activating XScreensaver/DPMS\n"); }
1579 vo_x11_uninit(); 1580 vo_x11_uninit();
1580 } 1581 }
1581 #endif 1582 #endif
1582 sdl_close(); 1583 sdl_close();
1583 1584
1584 /* Cleanup SDL */ 1585 /* Cleanup SDL */
1585 if(SDL_WasInit(SDL_INIT_VIDEO)) 1586 if(SDL_WasInit(SDL_INIT_VIDEO))
1586 SDL_QuitSubSystem(SDL_INIT_VIDEO); 1587 SDL_QuitSubSystem(SDL_INIT_VIDEO);
1587 1588
1588 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { 1589 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) {
1589 printf("SDL: Closed Plugin\n"); } 1590 mp_msg(MSGT_VO,MSGL_DBG3, "SDL: Closed Plugin\n"); }
1590 1591
1591 } 1592 }
1592 1593
1593 static int preinit(const char *arg) 1594 static int preinit(const char *arg)
1594 { 1595 {
1611 priv->rgbsurface = NULL; 1612 priv->rgbsurface = NULL;
1612 priv->overlay = NULL; 1613 priv->overlay = NULL;
1613 priv->surface = NULL; 1614 priv->surface = NULL;
1614 1615
1615 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) { 1616 if( mp_msg_test(MSGT_VO,MSGL_DBG3) ) {
1616 printf("SDL: Opening Plugin\n"); } 1617 mp_msg(MSGT_VO,MSGL_DBG3, "SDL: Opening Plugin\n"); }
1617 1618
1618 if(sdl_driver) { 1619 if(sdl_driver) {
1619 setenv("SDL_VIDEODRIVER", sdl_driver, 1); 1620 setenv("SDL_VIDEODRIVER", sdl_driver, 1);
1620 free(sdl_driver); 1621 free(sdl_driver);
1621 } 1622 }
1635 priv->bpp = 0; 1636 priv->bpp = 0;
1636 1637
1637 /* initialize the SDL Video system */ 1638 /* initialize the SDL Video system */
1638 if (!SDL_WasInit(SDL_INIT_VIDEO)) { 1639 if (!SDL_WasInit(SDL_INIT_VIDEO)) {
1639 if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)) { 1640 if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE)) {
1640 printf("SDL: Initializing of SDL failed: %s.\n", SDL_GetError()); 1641 mp_msg(MSGT_VO,MSGL_ERR, MSGTR_LIBVO_SDL_InitializingOfSDLFailed, SDL_GetError());
1641 return -1; 1642 return -1;
1642 } 1643 }
1643 } 1644 }
1644 1645
1645 SDL_VideoDriverName(priv->driver, 8); 1646 SDL_VideoDriverName(priv->driver, 8);
1646 printf("SDL: Using driver: %s\n", priv->driver); 1647 mp_msg(MSGT_VO,MSGL_INFO, MSGTR_LIBVO_SDL_UsingDriver, priv->driver);
1647 1648
1648 priv->X = 0; 1649 priv->X = 0;
1649 #ifdef HAVE_X11 1650 #ifdef HAVE_X11
1650 if(vo_init()) { 1651 if(vo_init()) {
1651 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 1652 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
1652 printf("SDL: deactivating XScreensaver/DPMS\n"); } 1653 mp_msg(MSGT_VO,MSGL_V, "SDL: deactivating XScreensaver/DPMS\n"); }
1653 priv->XWidth = vo_screenwidth; 1654 priv->XWidth = vo_screenwidth;
1654 priv->XHeight = vo_screenheight; 1655 priv->XHeight = vo_screenheight;
1655 priv->X = 1; 1656 priv->X = 1;
1656 if( mp_msg_test(MSGT_VO,MSGL_V) ) { 1657 if( mp_msg_test(MSGT_VO,MSGL_V) ) {
1657 printf("SDL: X11 Resolution %ix%i\n", priv->XWidth, priv->XHeight); } 1658 mp_msg(MSGT_VO,MSGL_V, "SDL: X11 Resolution %ix%i\n", priv->XWidth, priv->XHeight); }
1658 } 1659 }
1659 #endif 1660 #endif
1660 1661
1661 return 0; 1662 return 0;
1662 } 1663 }
1718 case VOCTRL_FULLSCREEN: 1719 case VOCTRL_FULLSCREEN:
1719 if (priv->surface->flags & SDL_FULLSCREEN) { 1720 if (priv->surface->flags & SDL_FULLSCREEN) {
1720 set_video_mode(priv->windowsize.w, priv->windowsize.h, priv->bpp, priv->sdlflags); 1721 set_video_mode(priv->windowsize.w, priv->windowsize.h, priv->bpp, priv->sdlflags);
1721 SDL_ShowCursor(1); 1722 SDL_ShowCursor(1);
1722 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { 1723 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
1723 printf("SDL: Windowed mode\n"); } 1724 mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Windowed mode\n"); }
1724 } else if (priv->fullmodes) { 1725 } else if (priv->fullmodes) {
1725 set_fullmode(priv->fullmode); 1726 set_fullmode(priv->fullmode);
1726 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) { 1727 if( mp_msg_test(MSGT_VO,MSGL_DBG2) ) {
1727 printf("SDL: Set fullscreen mode\n"); } 1728 mp_msg(MSGT_VO,MSGL_DBG2, "SDL: Set fullscreen mode\n"); }
1728 } 1729 }
1729 return VO_TRUE; 1730 return VO_TRUE;
1730 } 1731 }
1731 1732
1732 return VO_NOTIMPL; 1733 return VO_NOTIMPL;