[Mplayer-cvslog] CVS: main/libvo aspect.h,1.2,1.3 aspect.c,1.5,1.6 vo_xv.c,1.36,1.37 vo_sdl.c,1.57,1.58 vo_xmga.c,1.33,1.34 vo_gl.c,1.13,1.14 vo_gl2.c,1.2,1.3
Atmosfear
atmos4 at mplayer.dev.hu
Thu Oct 18 04:42:37 CEST 2001
Update of /cvsroot/mplayer/main/libvo
In directory mplayer:/var/tmp.root/cvs-serv2807
Modified Files:
aspect.h aspect.c vo_xv.c vo_sdl.c vo_xmga.c vo_gl.c vo_gl2.c
Log Message:
Update to new (cleaner, more bugfree, better) aspect api. vo_gl vo_gl2 and vo_xmga are untested!
Index: aspect.h
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/aspect.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- aspect.h 3 Oct 2001 15:31:51 -0000 1.2
+++ aspect.h 18 Oct 2001 02:42:20 -0000 1.3
@@ -2,7 +2,16 @@
#define __ASPECT_H
/* Stuff for correct aspect scaling. */
-void aspect(int *srcw, int *srch, int fitinw, int fitinh);
+void aspect_save_orig(int orgw, int orgh);
+
+void aspect_save_prescale(int prew, int preh);
+
+void aspect_save_screenres(int scrw, int scrh);
+
+#define A_ZOOM 1
+#define A_NOZOOM 0
+
+void aspect(int *srcw, int *srch, int zoom);
#endif
Index: aspect.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/aspect.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- aspect.c 15 Oct 2001 17:22:41 -0000 1.5
+++ aspect.c 18 Oct 2001 02:42:20 -0000 1.6
@@ -1,5 +1,7 @@
/* Stuff for correct aspect scaling. */
-//#define ASPECT_DEBUG
+#include "aspect.h"
+
+#define ASPECT_DEBUG
#ifdef ASPECT_DEBUG
#include <stdio.h>
@@ -7,39 +9,69 @@
float monitor_aspect=4.0/3.0;
+static struct {
+ int orgw; // real width
+ int orgh; // real height
+ int prew; // prescaled width
+ int preh; // prescaled height
+ int scrw; // horizontal resolution
+ int scrh; // vertical resolution
+} aspdat;
+
+void aspect_save_orig(int orgw, int orgh){
+ aspdat.orgw = orgw;
+ aspdat.orgh = orgh;
+}
+
+void aspect_save_prescale(int prew, int preh){
+ aspdat.prew = prew;
+ aspdat.preh = preh;
+}
+
+void aspect_save_screenres(int scrw, int scrh){
+ aspdat.scrw = scrw;
+ aspdat.scrh = scrh;
+}
+
/* aspect is called with the source resolution and the
* resolution, that the scaled image should fit into
*/
-void aspect(int *srcw, int *srch, int fitinw, int fitinh){
- int srcwcp, srchcp, tmp;
- srcwcp=*srcw; srchcp=*srch;
- srcwcp=fitinw;
+void aspect(int *srcw, int *srch, int zoom){
+ int tmpw;
+
#ifdef ASPECT_DEBUG
- printf("aspect(0) fitin: %dx%d \n",fitinw,fitinh);
- printf("aspect(1) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
+ printf("aspect(0) fitin: %dx%d zoom: %d \n",aspdat.scrw,aspdat.scrh,zoom);
+ printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
#endif
- srchcp=(int)(((float)fitinw / (float)*srcw * (float)*srch)
- * ((float)fitinh / ((float)fitinw / monitor_aspect)));
- srchcp+=srchcp%2; // round
+ if(zoom){
+ *srcw = aspdat.scrw;
+ *srch = (int)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh)
+ * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
+ }else{
+ *srcw = aspdat.prew;
+ *srch = (int)((float)aspdat.preh
+ * ((float)aspdat.scrh / ((float)aspdat.scrw / monitor_aspect)));
+ }
+ *srch+= *srch%2; // round
#ifdef ASPECT_DEBUG
- printf("aspect(2) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
+ printf("aspect(2) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
#endif
- if(srchcp>fitinh || srchcp<*srch){
- tmp=(int)(((float)fitinh / (float)*srch * (float)*srcw)
- * ((float)fitinw / ((float)fitinh / (1/monitor_aspect))));
- if(srcwcp>fitinw){
- srchcp=fitinh;
- srcwcp=tmp;
- srcwcp+=srcwcp%2; // round
+ if(*srch>aspdat.scrh || *srch<aspdat.orgh){
+ if(zoom)
+ tmpw = (int)(((float)aspdat.scrh / (float)aspdat.preh * (float)aspdat.prew)
+ * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
+ else
+ tmpw = (int)((float)aspdat.prew
+ * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
+ if(tmpw<=aspdat.scrw && tmpw>=aspdat.orgw){
+ *srch = zoom?aspdat.scrh:aspdat.preh;
+ *srcw = tmpw;
+ *srcw+= *srcw%2; // round
}
}
#ifdef ASPECT_DEBUG
- printf("aspect(3) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
-#endif
- *srcw=srcwcp; *srch=srchcp;
-#ifdef ASPECT_DEBUG
- printf("aspect(4) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch);
+ printf("aspect(3) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
#endif
}
Index: vo_xv.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xv.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- vo_xv.c 3 Oct 2001 15:31:50 -0000 1.36
+++ vo_xv.c 18 Oct 2001 02:42:20 -0000 1.37
@@ -132,6 +132,9 @@
XSetWindowAttributes xswa;
unsigned long xswamask;
+ aspect_save_orig(width,height);
+ aspect_save_prescale(d_width,d_height);
+
image_height = height;
image_width = width;
image_format=format;
@@ -142,11 +145,12 @@
#endif
mFullscreen=flags&1;
- dwidth=d_width; dheight=d_height;
num_buffers=vo_doublebuffering?NUM_BUFFERS:1;
if (!vo_init()) return -1;
+ aspect_save_screenres(vo_screenwidth,vo_screenheight);
+
#ifdef HAVE_NEW_GUI
if ( vo_window == None )
{
@@ -155,6 +159,8 @@
hint.y = 0;
hint.width = d_width;
hint.height = d_height;
+ aspect(&d_width,&d_height,A_NOZOOM);
+
if ( mFullscreen )
{
hint.width=vo_screenwidth;
@@ -167,13 +173,11 @@
* irritated for now (and send lots o' mails ;) ::atmos
*/
- {
- aspect(&d_width,&d_height,vo_screenwidth,vo_screenheight);
- dwidth=d_width; dheight=d_height;
- }
+ aspect(&d_width,&d_height,A_ZOOM);
#endif
}
+ dwidth=d_width; dheight=d_height; //XXX: what are the copy vars used for?
hint.flags = PPosition | PSize;
XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs);
depth=attribs.depth;
Index: vo_sdl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_sdl.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- vo_sdl.c 13 Oct 2001 13:38:59 -0000 1.57
+++ vo_sdl.c 18 Oct 2001 02:42:20 -0000 1.58
@@ -555,35 +555,26 @@
static void set_fullmode (int mode) {
struct sdl_priv_s *priv = &sdl_priv;
SDL_Surface *newsurface = NULL;
- int newwidth = priv->dstwidth,
- newheight= priv->dstheight;
/* if we haven't set a fullmode yet, default to the lowest res fullmode first */
if(mode < 0)
mode = priv->fullmode = findArrayEnd(priv->fullmodes) - 1;
+ aspect_save_screenres(priv->fullmodes[mode]->w, priv->fullmodes[mode]->h);
+
/* calculate new video size/aspect */
if(!priv->mode) {
if(priv->fulltype&FS) {
#ifdef HAVE_X11
- aspect(&newwidth, &newheight, priv->XWidth ? priv->XWidth : priv->dstwidth, priv->XHeight ? priv->XHeight : priv->dstheight);
-#else
- aspect(&newwidth, &newheight, priv->dstwidth, priv->dstheight);
-#endif
- } else
- if(priv->fulltype&VM) {
-#ifdef HAVE_X11
- aspect(&newwidth, &newheight, priv->dstwidth, (int)((float)priv->dstwidth*((float)priv->XHeight / (float)priv->XWidth)));
-#else
- aspect(&newwidth, &newheight, priv->dstwidth, priv->dstheight);
+ aspect_save_screenres(priv->XWidth, priv->XHeight);
#endif
- } else {
- aspect(&newwidth, &newheight, priv->fullmodes[mode]->w, priv->fullmodes[mode]->h);
}
+ aspect(&priv->dstwidth, &priv->dstheight, A_ZOOM);
+
}
/* try to change to given fullscreenmode */
- newsurface = SDL_SetVideoMode(newwidth, newheight, priv->bpp, priv->sdlfullflags);
+ newsurface = SDL_SetVideoMode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlfullflags);
/* if creation of new surface was successfull, save it and hide mouse cursor */
if(newsurface) {
@@ -615,7 +606,8 @@
static Display *XDisplay;
static int XScreen;
#endif
- int newwidth, newheight;
+ aspect_save_orig(width,height);
+ aspect_save_prescale(d_width,d_height);
sdl_format = format;
switch(format){
@@ -701,17 +693,16 @@
priv->height = height;
priv->dstwidth = d_width ? d_width : width;
priv->dstheight = d_height ? d_height : height;
- newwidth = priv->dstwidth;
- newheight = priv->dstheight;
/*priv->width = res.w;
priv->height = res.h;*/
priv->format = format;
#ifdef HAVE_X11
- aspect(&newwidth, &newheight, priv->dstwidth, (int)((float)priv->dstwidth*((float)priv->XHeight / (float)priv->XWidth)));
+ aspect_save_screenres(priv->XWidth,priv->XHeight);
+ aspect(&priv->dstwidth,&priv->dstheight,A_NOZOOM);
#endif
- priv->windowsize.w = newwidth;
- priv->windowsize.h = newheight;
+ priv->windowsize.w = priv->dstwidth;
+ priv->windowsize.h = priv->dstheight;
/* bit 0 (0x01) means fullscreen (-fs)
* bit 1 (0x02) means mode switching (-vm)
@@ -726,15 +717,14 @@
}
if(flags&FS) {
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 or -zoom to switch to best resolution.\n");
priv->fulltype = FS;
set_fullmode(priv->fullmode);
/*if((priv->surface = SDL_SetVideoMode (d_width, d_height, priv->bpp, priv->sdlfullflags)))
SDL_ShowCursor(0);*/
} else
if(flags&VM) {
- if(verbose) printf("SDL: setting nonzoomed fullscreen with modeswitching\n");
- printf("SDL: Info - please use -zoom switch to scale video\n");
+ if(verbose) printf("SDL: setting zoomed fullscreen with modeswitching\n");
priv->fulltype = VM;
set_fullmode(priv->fullmode);
/*if((priv->surface = SDL_SetVideoMode (d_width ? d_width : width, d_height ? d_height : height, priv->bpp, priv->sdlfullflags)))
@@ -742,18 +732,16 @@
} else
if(flags&ZOOM) {
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");
priv->fulltype = ZOOM;
set_fullmode(priv->fullmode);
}
else {
if((strcmp(priv->driver, "x11") == 0) || ((strcmp(priv->driver, "aalib") == 0) && priv->X)) {
if(verbose) printf("SDL: setting windowed mode\n");
- priv->surface = SDL_SetVideoMode (newwidth, newheight, priv->bpp, priv->sdlflags);
+ priv->surface = SDL_SetVideoMode (priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags);
}
else {
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");
priv->fulltype = ZOOM;
set_fullmode(priv->fullmode);
}
@@ -1092,20 +1080,17 @@
}
else if ( keypressed == SDLK_n ) {
- int newwidth = priv->dstwidth, newheight = priv->dstheight;
#ifdef HAVE_X11
- aspect(&newwidth, &newheight, priv->dstwidth, (int)((float)priv->dstwidth*((float)priv->XHeight / (float)priv->XWidth)));
-#else
- aspect(&newwidth, &newheight, priv->dstwidth, priv->dstheight);
+ aspect(&priv->dstwidth, &priv->dstheight,A_NOZOOM);
#endif
- if (priv->surface->w != newwidth || priv->surface->h != newheight) {
- priv->surface = SDL_SetVideoMode(newwidth, newheight, priv->bpp, priv->sdlflags);
+ if (priv->surface->w != priv->dstwidth || priv->surface->h != priv->dstheight) {
+ priv->surface = SDL_SetVideoMode(priv->dstwidth, priv->dstheight, priv->bpp, priv->sdlflags);
priv->windowsize.w = priv->surface->w;
priv->windowsize.h = priv->surface->h;
if(verbose > 1) printf("SDL: Normal size\n");
} else
- if (priv->surface->w != newwidth * 2 || priv->surface->h != newheight * 2) {
- priv->surface = SDL_SetVideoMode(newwidth * 2, newheight * 2, priv->bpp, priv->sdlflags);
+ if (priv->surface->w != priv->dstwidth * 2 || priv->surface->h != priv->dstheight * 2) {
+ priv->surface = SDL_SetVideoMode(priv->dstwidth * 2, priv->dstheight * 2, priv->bpp, priv->sdlflags);
priv->windowsize.w = priv->surface->w;
priv->windowsize.h = priv->surface->h;
if(verbose > 1) printf("SDL: Double size\n");
Index: vo_xmga.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_xmga.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- vo_xmga.c 3 Oct 2001 17:27:13 -0000 1.33
+++ vo_xmga.c 18 Oct 2001 02:42:20 -0000 1.34
@@ -230,11 +230,14 @@
if (!vo_init()) return -1;
+ aspect_save_orig(width,height);
+ aspect_save_prescale(d_width,d_height);
+ aspect_save_screenres(vo_screenwidth,vo_screenheight);
+
mvWidth=width; mvHeight=height;
wndX=0; wndY=0;
wndWidth=d_width; wndHeight=d_height;
- dwidth=d_width; dheight=d_height;
#ifdef HAVE_NEW_GUI
// mdwidth=d_width; mdheight=d_height;
mdwidth=width; mdheight=height;
@@ -250,6 +253,7 @@
default: printf( "Sorry, this (%d) color depth not supported.\n",vo_depthonscreen ); return -1;
}
+ aspect(&d_width,&d_height,A_NOZOOM);
#ifdef HAVE_NEW_GUI
if ( vo_window == None )
{
@@ -259,10 +263,10 @@
wndWidth=vo_screenwidth;
wndHeight=vo_screenheight;
#ifdef X11_FULLSCREEN
- aspect(&d_width,&d_height,vo_screenwidth,vo_screenheight);
- dwidth=d_width; dheight=d_height;
+ aspect(&d_width,&d_height,A_ZOOM);
#endif
}
+ dwidth=d_width; dheight=d_height;
XGetWindowAttributes( mDisplay,DefaultRootWindow( mDisplay ),&attribs );
mDepth=attribs.depth;
Index: vo_gl.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- vo_gl.c 3 Oct 2001 17:27:13 -0000 1.13
+++ vo_gl.c 18 Oct 2001 02:42:20 -0000 1.14
@@ -99,7 +99,6 @@
init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
// int screen;
- int dwidth,dheight;
unsigned int fg, bg;
char *hello = (title == NULL) ? "OpenGL rulez" : title;
// char *name = ":0.0";
@@ -118,13 +117,16 @@
if (X_already_started) return -1;
if(!vo_init()) return -1;
+ aspect_save_orig(width,height);
+ aspect_save_prescale(d_width,d_height);
+ aspect_save_screenres(vo_screenwidth,vo_screenheight);
+
X_already_started++;
- dwidth=d_width; dheight=d_height;
+ aspect(&d_width,&d_height,A_NOZOOM);
#ifdef X11_FULLSCREEN
if( flags&0x01 ){ // (-fs)
- aspect(&d_width,&d_height,vo_screenwidth,vo_screenheight);
- dwidth=d_width; dheight=d_height;
+ aspect(&d_width,&d_height,A_ZOOM);
}
#endif
hint.x = 0;
Index: vo_gl2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_gl2.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- vo_gl2.c 7 Oct 2001 21:39:47 -0000 1.2
+++ vo_gl2.c 18 Oct 2001 02:42:20 -0000 1.3
@@ -395,7 +395,6 @@
init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
{
// int screen;
- int dwidth,dheight;
unsigned int fg, bg;
char *hello = (title == NULL) ? "OpenGL rulez" : title;
// char *name = ":0.0";
@@ -414,13 +413,16 @@
if (X_already_started) return -1;
if(!vo_init()) return -1;
+ aspect_save_orig(width,height);
+ aspect_save_prescale(d_width,d_height);
+ aspect_save_screenres(vo_screenwidth,vo_screenheight);
+
X_already_started++;
- dwidth=d_width; dheight=d_height;
+ aspect(&d_width,&d_height,A_NOZOOM);
#ifdef X11_FULLSCREEN
if( flags&0x01 ){ // (-fs)
- aspect(&d_width,&d_height,vo_screenwidth,vo_screenheight);
- dwidth=d_width; dheight=d_height;
+ aspect(&d_width,&d_height,A_ZOOM);
}
#endif
hint.x = 0;
More information about the MPlayer-cvslog
mailing list