aboutsummaryrefslogtreecommitdiffhomepage
path: root/libvo/aspect.c
blob: 59e099294435ac87eacc4e0ff0dbfcad3cb801c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* Stuff for correct aspect scaling. */

float monitor_aspect=4.0/3.0;

/* 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;
  srcwcp=*srcw; srchcp=*srch;
  *srcw=fitinw;
  *srch=(int)(((float)fitinw / (float)srcwcp * (float)srchcp)
            * ((float)fitinh/((float)fitinw/monitor_aspect)));
  *srch+=*srch%2; // round
  //printf("aspect rez wh: %dx%d\n",*srcw,*srch);
  if(*srch>fitinh || *srch<srchcp){
    *srch=fitinh;
    *srcw=(int)(((float)fitinh / (float)srchcp * (float)srcwcp)
              * ((float)fitinw/((float)fitinh/(1/monitor_aspect))));
    *srcw+=*srcw%2; // round
  }
  //printf("aspect ret wh: %dx%d\n",*srcw,*srch);
}