mirror of
https://github.com/mpv-player/mpv
synced 2025-01-28 02:23:06 +00:00
Simplified aspect() for the loss of some functionality to get ansi compatibility.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2056 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
5a2e880711
commit
4d053a65c0
@ -1,5 +1,4 @@
|
|||||||
/* Stuff for correct aspect scaling. */
|
/* Stuff for correct aspect scaling. */
|
||||||
#include "aspect.h"
|
|
||||||
|
|
||||||
float monitor_aspect=4.0/3.0;
|
float monitor_aspect=4.0/3.0;
|
||||||
|
|
||||||
@ -7,26 +6,20 @@ float monitor_aspect=4.0/3.0;
|
|||||||
* resolution, that the scaled image should fit into
|
* resolution, that the scaled image should fit into
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rect_t aspect(int srcw, int srch, int fitinw, int fitinh){
|
void aspect(int *srcw, int *srch, int fitinw, int fitinh){
|
||||||
rect_t r,z;
|
int srcwcp, srchcp;
|
||||||
r.w=fitinw;
|
srcwcp=*srcw; srchcp=*srch;
|
||||||
r.x=0;
|
*srcw=fitinw;
|
||||||
r.h=(int)(((float)fitinw / (float)srcw * (float)srch)
|
*srch=(int)(((float)fitinw / (float)srcwcp * (float)srchcp)
|
||||||
* ((float)fitinh/((float)fitinw/monitor_aspect)));
|
* ((float)fitinh/((float)fitinw/monitor_aspect)));
|
||||||
r.h+=r.h%2; // round
|
*srch+=*srch%2; // round
|
||||||
r.y=(fitinh-r.h)/2;
|
//printf("aspect rez wh: %dx%d\n",*srcw,*srch);
|
||||||
z=r;
|
if(*srch>fitinh || *srch<srchcp){
|
||||||
//printf("aspect rez x: %d y: %d wh: %dx%d\n",r.x,r.y,r.w,r.h);
|
*srch=fitinh;
|
||||||
if(r.h>fitinh || r.h<srch){
|
*srcw=(int)(((float)fitinh / (float)srchcp * (float)srcwcp)
|
||||||
r.h=fitinh;
|
|
||||||
r.y=0;
|
|
||||||
r.w=(int)(((float)fitinh / (float)srch * (float)srcw)
|
|
||||||
* ((float)fitinw/((float)fitinh/(1/monitor_aspect))));
|
* ((float)fitinw/((float)fitinh/(1/monitor_aspect))));
|
||||||
r.w+=r.w%2; // round
|
*srcw+=*srcw%2; // round
|
||||||
r.x=(fitinw-r.w)/2;
|
|
||||||
}
|
}
|
||||||
if(r.w>fitinw) r=z;
|
//printf("aspect ret wh: %dx%d\n",*srcw,*srch);
|
||||||
//printf("aspect ret x: %d y: %d wh: %dx%d\n",r.x,r.y,r.w,r.h);
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,14 +2,7 @@
|
|||||||
#define __ASPECT_H
|
#define __ASPECT_H
|
||||||
/* Stuff for correct aspect scaling. */
|
/* Stuff for correct aspect scaling. */
|
||||||
|
|
||||||
typedef struct {
|
void aspect(int *srcw, int *srch, int fitinw, int fitinh);
|
||||||
int x; /* x,y starting coordinate */
|
|
||||||
int y; /* of upper left corner */
|
|
||||||
int w; /* width */
|
|
||||||
int h; /* height */
|
|
||||||
} rect_t;
|
|
||||||
|
|
||||||
rect_t aspect(int srcw, int srch, int fitinw, int fitinh);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -121,7 +121,6 @@ static void draw_alpha_null(int x0,int y0, int w,int h, unsigned char* src, unsi
|
|||||||
static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format)
|
static uint32_t 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 screen;
|
||||||
// int myx,myy;
|
|
||||||
char *hello = (title == NULL) ? "Xv render" : title;
|
char *hello = (title == NULL) ? "Xv render" : title;
|
||||||
// char *name = ":0.0";
|
// char *name = ":0.0";
|
||||||
XSizeHints hint;
|
XSizeHints hint;
|
||||||
@ -169,9 +168,8 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
rect_t newres = aspect(d_width,d_height,vo_screenwidth,vo_screenheight);
|
aspect(&d_width,&d_height,vo_screenwidth,vo_screenheight);
|
||||||
dwidth=d_width=newres.w; dheight=d_height=newres.h;
|
dwidth=d_width; dheight=d_height;
|
||||||
//myx=newres.x; myy=newres.y;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -286,12 +284,12 @@ static uint32_t init(uint32_t width, uint32_t height, uint32_t d_width, uint32_t
|
|||||||
|
|
||||||
if ( mFullscreen )
|
if ( mFullscreen )
|
||||||
{
|
{
|
||||||
drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2; /* =myx; */
|
drwX=( vo_screenwidth - (dwidth > vo_screenwidth?vo_screenwidth:dwidth) ) / 2;
|
||||||
drwcX+=drwX;
|
drwcX+=drwX;
|
||||||
drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2; /* =myy; */
|
drwY=( vo_screenheight - (dheight > vo_screenheight?vo_screenheight:dheight) ) / 2;
|
||||||
drwcY+=drwY;
|
drwcY+=drwY;
|
||||||
drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth); /* =dwidth */
|
drwWidth=(dwidth > vo_screenwidth?vo_screenwidth:dwidth);
|
||||||
drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight); /* =dheight */
|
drwHeight=(dheight > vo_screenheight?vo_screenheight:dheight);
|
||||||
printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
|
printf( "[xv-fs] dcx: %d dcy: %d dx: %d dy: %d dw: %d dh: %d\n",drwcX,drwcY,drwX,drwY,drwWidth,drwHeight );
|
||||||
}
|
}
|
||||||
#ifdef HAVE_NEW_GUI
|
#ifdef HAVE_NEW_GUI
|
||||||
|
Loading…
Reference in New Issue
Block a user