[Mplayer-cvslog] CVS: main/libvo vo_sdl.c,1.46,1.47

Felix Buenemann atmosfear at users.sourceforge.net
Fri Jun 22 21:56:43 CEST 2001


Update of /cvsroot/mplayer/main/libvo
In directory usw-pr-cvs1:/tmp/cvs-serv7533/libvo

Modified Files:
	vo_sdl.c 
Log Message:
Drastic! speedup of rgb code. Removed nonsens memhole fixes.


Index: vo_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_sdl.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** vo_sdl.c	2001/06/21 22:47:55	1.46
--- vo_sdl.c	2001/06/22 19:56:41	1.47
***************
*** 95,103 ****
  #undef SDL_NOHWSURFACE
  
- /* if defined, don't use depth/colorspace-conversions for rgb/bgr
-  * also no scaling done then, much faster (~2 times)!
-  */
- #undef SDL_DIRECT_BLIT
- 
  //#define BUGGY_SDL //defined by configure
  
--- 95,98 ----
***************
*** 259,263 ****
      			vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0)+1,2*priv->width);
  		break;
! #ifdef SDL_DIRECT_BLIT		
  		case IMGFMT_RGB15:
  		case IMGFMT_BGR15:
--- 254,260 ----
      			vo_draw_alpha_yuy2(w,h,src,srca,stride,((uint8_t *) *(priv->overlay->pixels))+2*(priv->width*y0+x0)+1,2*priv->width);
  		break;
! 		default:
! 		if((priv->format&0xFF) == priv->bpp)		
! 		switch(priv->format) {
  		case IMGFMT_RGB15:
  		case IMGFMT_BGR15:
***************
*** 276,280 ****
      			vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+4*(y0*priv->width+x0),4*priv->width);
  		break;
! #else		
  		case IMGFMT_RGB15:
  		case IMGFMT_BGR15:
--- 273,279 ----
      			vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->surface->pixels)+4*(y0*priv->width+x0),4*priv->width);
  		break;
! 		}
! 		else
! 		switch(priv->format) {		
  		case IMGFMT_RGB15:
  		case IMGFMT_BGR15:
***************
*** 293,297 ****
      			vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+4*(y0*priv->width+x0),4*priv->width);
  		break;
! #endif		
    	}	
  }
--- 292,296 ----
      			vo_draw_alpha_rgb32(w,h,src,srca,stride,((uint8_t *) priv->rgbsurface->pixels)+4*(y0*priv->width+x0),4*priv->width);
  		break;
! 		}		
    	}	
  }
***************
*** 364,380 ****
  	#ifdef SDL_NOHWSURFACE
  		if(verbose) printf("SDL: using software-surface\n");
! 		priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT;
! 		priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT;
  	#else	
! 		if((strcmp(priv->driver, "dga") == 0) && (priv->mode)) {
  			if(verbose) printf("SDL: using software-surface\n");
! 			priv->sdlflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL;
! 			priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL;
  		}	
! 		else {	
  			if(verbose) printf("SDL: using hardware-surface\n");
! 			priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL;
! 			priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_HWACCEL;
! 		}	
  	#endif	
  	
--- 363,379 ----
  	#ifdef SDL_NOHWSURFACE
  		if(verbose) printf("SDL: using software-surface\n");
! 		priv->sdlflags = SDL_SWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_ANYFORMAT;
! 		priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_ANYFORMAT;
  	#else	
! 		/*if((strcmp(priv->driver, "dga") == 0) && (priv->mode)) {
  			if(verbose) printf("SDL: using software-surface\n");
! 			priv->sdlflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT;
! 			priv->sdlfullflags = SDL_SWSURFACE|SDL_FULLSCREEN|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT;
  		}	
! 		else {	*/
  			if(verbose) printf("SDL: using hardware-surface\n");
! 			priv->sdlflags = SDL_HWSURFACE|SDL_RESIZABLE|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT;
! 			priv->sdlfullflags = SDL_HWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF|SDL_ASYNCBLIT|SDL_HWACCEL|SDL_ANYFORMAT;
! 		//}	
  	#endif	
  	
***************
*** 713,719 ****
  	  	if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n");
  		printf("SDL: Info - please use -vm (unscaled) or -zoom (scaled) for best fullscreen experience\n");
- 		if (priv->surface)
- 		    SDL_FreeSurface(priv->surface);
-           	priv->surface = NULL;
  		priv->fulltype = FS;
  		set_fullmode(priv->fullmode);
--- 712,715 ----
***************
*** 724,730 ****
  	 	if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n");
  		printf("SDL: Info - please use -zoom switch to scale video\n");
- 		if (priv->surface)
- 		    SDL_FreeSurface(priv->surface);
-           	priv->surface = NULL;
  		priv->fulltype = VM;
  		set_fullmode(priv->fullmode);
--- 720,723 ----
***************
*** 735,741 ****
  	 	if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
  		printf("SDL: Info - please use -vm switch instead if you don't want scaled video\n");
- 		if (priv->surface)
- 		    SDL_FreeSurface(priv->surface);
-           	priv->surface = NULL;
  		priv->fulltype = ZOOM;
  		set_fullmode(priv->fullmode);
--- 728,731 ----
***************
*** 753,759 ****
  			if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
  			printf("SDL: Info - please use -vm switch instead if you don't want scaled video\n");
- 			if (priv->surface)
- 			    SDL_FreeSurface(priv->surface);
- 			priv->surface = NULL;
  			priv->fulltype = ZOOM;
  			set_fullmode(priv->fullmode);
--- 743,746 ----
***************
*** 776,781 ****
  		// FIXME: colorkey detect based on bpp, FIXME static bpp value, FIXME alpha value correct?
  	    case IMGFMT_RGB15:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 15, 31, 992, 31744, 0))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 763,766 ----
***************
*** 784,789 ****
  	    break;	
  	    case IMGFMT_BGR15:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 15, 31744, 992, 31, 0))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 769,772 ----
***************
*** 792,797 ****
  	    break;	
  	    case IMGFMT_RGB16:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 16, 31, 2016, 63488, 0))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 775,778 ----
***************
*** 800,805 ****
  	    break;	
  	    case IMGFMT_BGR16:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 16, 63488, 2016, 31, 0))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 781,784 ----
***************
*** 808,813 ****
  	    break;	
  	    case IMGFMT_RGB24:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 24, 0x0000FF, 0x00FF00, 0xFF0000, 0))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 787,790 ----
***************
*** 816,821 ****
  	    break;	
  	    case IMGFMT_BGR24:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 24, 0xFF0000, 0x00FF00, 0x0000FF, 0))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 793,796 ----
***************
*** 824,829 ****
  	    break;	
  	    case IMGFMT_RGB32:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 799,802 ----
***************
*** 832,837 ****
  	    break;	
  	    case IMGFMT_BGR32:
- 		if (priv->rgbsurface)
- 			SDL_FreeSurface(priv->rgbsurface);
  		if (!(priv->rgbsurface = SDL_CreateRGBSurface (SDL_SRCCOLORKEY, width, height, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000))) {
  			printf ("SDL: Couldn't create a RGB surface: %s\n", SDL_GetError());
--- 805,808 ----
***************
*** 841,846 ****
  	    default:
  		/* Initialize and create the YUV Overlay used for video out */
- 		if (priv->overlay)
- 			SDL_FreeYUVOverlay(priv->overlay);
  		if (!(priv->overlay = SDL_CreateYUVOverlay (width, height, sdl_format, priv->surface))) {
  			printf ("SDL: Couldn't create a YUV overlay: %s\n", SDL_GetError());
--- 812,815 ----
***************
*** 856,862 ****
  	
  	if(priv->mode) {
! #ifdef SDL_DIRECT_BLIT
! 	if(verbose) printf("SDL: using direct surface blitting, no depth/colorspace-conversion/scaling possible.\n");
! #endif		
  		priv->framePlaneRGB = width * height * priv->rgbsurface->format->BytesPerPixel;
  		priv->stridePlaneRGB = width * priv->rgbsurface->format->BytesPerPixel;
--- 825,829 ----
  	
  	if(priv->mode) {
! 		if((priv->format&0xFF) != priv->bpp) printf("SDL: using depth/colorspace conversion, this will slow things down (%ibpp -> %ibpp).\n", priv->format&0xFF, priv->bpp);
  		priv->framePlaneRGB = width * height * priv->rgbsurface->format->BytesPerPixel;
  		priv->stridePlaneRGB = width * priv->rgbsurface->format->BytesPerPixel;
***************
*** 926,968 ****
  	case IMGFMT_RGB32:
  	case IMGFMT_BGR32:
! #ifdef SDL_DIRECT_BLIT		
! 		/*if(SDL_MUSTLOCK(priv->surface)) {
! 	    		if (SDL_LockSurface (priv->surface)) {
! 				if(verbose) printf("SDL: Couldn't lock RGB surface\n");
! 				return -1;
! 	    		}
! 		}*/
! 		dst = (uint8_t *) priv->surface->pixels;
! 	    	if(priv->flip) {
! 	    		mysrc+=priv->framePlaneRGB;
! 			for(i = 0; i < priv->height; i++) {
! 				mysrc-=priv->stridePlaneRGB;
! 				memcpy (dst, mysrc, priv->stridePlaneRGB);
! 				dst+=priv->stridePlaneRGB;
  			}
! 		}
! 		else memcpy (dst, src[0], priv->framePlaneRGB);
! 		/*if(SDL_MUSTLOCK(priv->surface)) 
! 			SDL_UnlockSurface (priv->surface);*/
! #else			
! 		/*if(SDL_MUSTLOCK(priv->rgbsurface)) {
! 	    		if (SDL_LockSurface (priv->rgbsurface)) {
! 				if(verbose) printf("SDL: Couldn't lock RGB surface\n");
! 				return -1;
! 	    		}
! 		}*/
! 		dst = (uint8_t *) priv->rgbsurface->pixels;
! 	    	if(priv->flip) {
! 	    		mysrc+=priv->framePlaneRGB;
! 			for(i = 0; i < priv->height; i++) {
! 				mysrc-=priv->stridePlaneRGB;
! 				memcpy (dst, mysrc, priv->stridePlaneRGB);
! 				dst+=priv->stridePlaneRGB;
  			}
  		}
- 		else memcpy (dst, src[0], priv->framePlaneRGB);
- 		/*if(SDL_MUSTLOCK(priv->rgbsurface)) 
- 			SDL_UnlockSurface (priv->rgbsurface);*/
- #endif			
  		break;
  
--- 893,935 ----
  	case IMGFMT_RGB32:
  	case IMGFMT_BGR32:
! 		if((priv->format&0xFF) == priv->bpp) {
! 			/*if(SDL_MUSTLOCK(priv->surface)) {
! 				if (SDL_LockSurface (priv->surface)) {
! 					if(verbose) printf("SDL: Couldn't lock RGB surface\n");
! 					return -1;
! 				}
! 			}*/
! 			dst = (uint8_t *) priv->surface->pixels;
! 			if(priv->flip) {
! 				mysrc+=priv->framePlaneRGB;
! 				for(i = 0; i < priv->height; i++) {
! 					mysrc-=priv->stridePlaneRGB;
! 					memcpy (dst, mysrc, priv->stridePlaneRGB);
! 					dst+=priv->stridePlaneRGB;
! 				}
  			}
! 			else memcpy (dst, src[0], priv->framePlaneRGB);
! 			/*if(SDL_MUSTLOCK(priv->surface)) 
! 				SDL_UnlockSurface (priv->surface);*/
! 		} else {
! 			/*if(SDL_MUSTLOCK(priv->rgbsurface)) {
! 				if (SDL_LockSurface (priv->rgbsurface)) {
! 					if(verbose) printf("SDL: Couldn't lock RGB surface\n");
! 					return -1;
! 				}
! 			}*/
! 			dst = (uint8_t *) priv->rgbsurface->pixels;
! 			if(priv->flip) {
! 				mysrc+=priv->framePlaneRGB;
! 				for(i = 0; i < priv->height; i++) {
! 					mysrc-=priv->stridePlaneRGB;
! 					memcpy (dst, mysrc, priv->stridePlaneRGB);
! 					dst+=priv->stridePlaneRGB;
! 				}
  			}
+ 			else memcpy (dst, src[0], priv->framePlaneRGB);
+ 			/*if(SDL_MUSTLOCK(priv->rgbsurface)) 
+ 				SDL_UnlockSurface (priv->rgbsurface);*/
  		}
  		break;
  
***************
*** 1173,1177 ****
  {
  	struct sdl_priv_s *priv = &sdl_priv;
- 	SDL_Surface *blitconv; // temporary conversion surface
  
  	/* update osd/subtitles */
--- 1140,1143 ----
***************
*** 1190,1200 ****
  	    case IMGFMT_RGB32:
  	    case IMGFMT_BGR32:
! #ifndef SDL_DIRECT_BLIT	    
! 	    	/* blit to the RGB surface */
! 		blitconv = SDL_DisplayFormat(priv->rgbsurface);	
! 		if(SDL_BlitSurface (blitconv, NULL, priv->surface, NULL))
! 			printf("SDL: Blit failed: %s\n", SDL_GetError());
! 		SDL_FreeSurface(blitconv);	
! #endif		
  
  		/* update screen */
--- 1156,1164 ----
  	    case IMGFMT_RGB32:
  	    case IMGFMT_BGR32:
! 		if((priv->format&0xFF) != priv->bpp) {
! 		  	/* blit to the RGB surface */
! 			if(SDL_BlitSurface (priv->rgbsurface, NULL, priv->surface, NULL))
! 				printf("SDL: Blit failed: %s\n", SDL_GetError());
! 		}
  
  		/* update screen */


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list