Added flipped video support and activate/deactivate screensaver under X.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@773 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
atmosfear 2001-05-11 21:36:30 +00:00
parent f68556b70c
commit 9e701e74c4
1 changed files with 67 additions and 18 deletions

View File

@ -108,6 +108,11 @@
#include "fastmemcpy.h" #include "fastmemcpy.h"
#include "sub.h" #include "sub.h"
#ifdef HAVE_X11
#include <X11/Xlib.h>
#include "x11_common.h"
#endif
LIBVO_EXTERN(sdl) LIBVO_EXTERN(sdl)
extern int verbose; extern int verbose;
@ -171,6 +176,10 @@ static struct sdl_priv_s {
/* RGB ints */ /* RGB ints */
int framePlaneRGB; int framePlaneRGB;
int stridePlaneRGB;
/* Flip image */
int flip;
int width,height; int width,height;
int format; int format;
@ -453,11 +462,16 @@ static void set_fullmode (int mode)
**/ **/
static uint32_t static uint32_t
init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t fullscreen, char *title, uint32_t format) init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
//static int sdl_setup (int width, int height) //static int sdl_setup (int width, int height)
{ {
struct sdl_priv_s *priv = &sdl_priv; struct sdl_priv_s *priv = &sdl_priv;
unsigned int sdl_format; unsigned int sdl_format;
#ifdef HAVE_X11
static Display *XDisplay;
#endif
//priv->flip = 1; // debugging only
sdl_format = format; sdl_format = format;
switch(format){ switch(format){
@ -514,6 +528,14 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
} }
sdl_open (NULL, NULL); sdl_open (NULL, NULL);
#ifdef HAVE_X11
if(getenv("DISPLAY")) {
if(verbose) printf("SDL: deactivating XScreensaver/DPMS\n");
XDisplay = XOpenDisplay(getenv("DISPLAY"));
saver_off(XDisplay);
XCloseDisplay(XDisplay);
}
#endif
/* Set output window title */ /* Set output window title */
SDL_WM_SetCaption (".: MPlayer : F = Fullscreen/Windowed : C = Cycle Fullscreen Resolutions :.", "SDL Video Out"); SDL_WM_SetCaption (".: MPlayer : F = Fullscreen/Windowed : C = Cycle Fullscreen Resolutions :.", "SDL Video Out");
@ -532,37 +554,44 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
/* bit 0 (0x01) means fullscreen (-fs) /* bit 0 (0x01) means fullscreen (-fs)
* bit 1 (0x02) means mode switching (-vm) * bit 1 (0x02) means mode switching (-vm)
* bit 2 (0x04) enables software scaling (-zoom) * bit 2 (0x04) enables software scaling (-zoom)
* bit 3 (0x08) enables flipping (-flip)
*/ */
// printf("SDL: fullscreenflag is set to: %i\n", fullscreen); #define FS 0x01
#define VM 0x02
#define ZOOM 0x04
#define FLIP 0x08
// printf("SDL: flags are set to: %i\n", flags);
// printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height); // printf("SDL: Width: %i Height: %i D_Width %i D_Height: %i\n", width, height, d_width, d_height);
switch(fullscreen){ if(flags&FLIP) { // flipping flag set, use it
case 0x01: if(verbose) printf("SDL: using flipped video (only with RGB/BGR)\n");
case 0x05: priv->flip = 1;
}
if(flags&FS) {
priv->width = width; priv->width = width;
priv->height = height; priv->height = height;
if(verbose) printf("SDL: setting zoomed fullscreen without modeswitching\n"); 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"); printf("SDL: Info - please use -vm (unscaled) or -zoom (scaled) for best fullscreen experience\n");
if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags))) if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)))
SDL_ShowCursor(0); SDL_ShowCursor(0);
break; } else
case 0x02: if(flags&VM) {
if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n"); if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n");
printf("SDL: Info - please use -zoom switch to scale video\n"); printf("SDL: Info - please use -zoom switch to scale video\n");
if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags))) if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags)))
SDL_ShowCursor(0); SDL_ShowCursor(0);
break; } else
case 0x04: if(flags&ZOOM) {
case 0x06:
if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n"); 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"); printf("SDL: Info - please use -vm switch instead if you don't want scaled video\n");
priv->surface=NULL; priv->surface=NULL;
set_fullmode(priv->fullmode); set_fullmode(priv->fullmode);
break; }
default: else {
if(verbose) printf("SDL: setting windowed mode\n"); if(verbose) printf("SDL: setting windowed mode\n");
if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlflags)) if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlflags))
&& (strcmp(priv->driver, "dga") == 0)) SDL_ShowCursor(0); //TODO: other sdl drivers that are fullscreen only? && (strcmp(priv->driver, "dga") == 0)) SDL_ShowCursor(0); //TODO: other sdl drivers that are fullscreen only?
} }
if(!priv->surface) { // cannot SetVideoMode if(!priv->surface) { // cannot SetVideoMode
printf("SDL: failed to set video mode: %s\n", SDL_GetError()); printf("SDL: failed to set video mode: %s\n", SDL_GetError());
return -1; return -1;
@ -639,6 +668,7 @@ init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint3
if(priv->mode) { if(priv->mode) {
priv->framePlaneRGB = width * height * priv->rgbsurface->format->BytesPerPixel; priv->framePlaneRGB = width * height * priv->rgbsurface->format->BytesPerPixel;
priv->stridePlaneRGB = width * priv->rgbsurface->format->BytesPerPixel;
} }
return 0; return 0;
} }
@ -656,6 +686,8 @@ static uint32_t draw_frame(uint8_t *src[])
{ {
struct sdl_priv_s *priv = &sdl_priv; struct sdl_priv_s *priv = &sdl_priv;
uint8_t *dst; uint8_t *dst;
int i;
uint8_t *mysrc = src[0];
switch(priv->format){ switch(priv->format){
case IMGFMT_YV12: case IMGFMT_YV12:
@ -701,7 +733,15 @@ static uint32_t draw_frame(uint8_t *src[])
} }
}*/ }*/
dst = (uint8_t *) priv->rgbsurface->pixels; dst = (uint8_t *) priv->rgbsurface->pixels;
memcpy (dst, src[0], priv->framePlaneRGB); 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)) /*if(SDL_MUSTLOCK(priv->rgbsurface))
SDL_UnlockSurface (priv->rgbsurface);*/ SDL_UnlockSurface (priv->rgbsurface);*/
break; break;
@ -996,6 +1036,15 @@ get_info(void)
static void static void
uninit(void) uninit(void)
{ {
#ifdef HAVE_X11
static Display *XDisplay;
if(getenv("DISPLAY")) {
if(verbose) printf("SDL: activating XScreensaver/DPMS\n");
XDisplay = XOpenDisplay(getenv("DISPLAY"));
saver_on(XDisplay);
XCloseDisplay(XDisplay);
}
#endif
sdl_close(); sdl_close();
} }