Mercurial > mplayer.hg
annotate libvo/aspect.c @ 2209:a59f952fad34
applied patch by Joy Winter <joy@pingfm.org>
author | arpi |
---|---|
date | Mon, 15 Oct 2001 11:17:19 +0000 |
parents | 7f27b212e07b |
children | a98d5300f5e9 |
rev | line source |
---|---|
2053 | 1 /* Stuff for correct aspect scaling. */ |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
2 #undef ASPECT_DEBUG |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
3 |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
4 #ifdef ASPECT_DEBUG |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
5 #include <stdio.h> |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
6 #endif |
2053 | 7 |
8 float monitor_aspect=4.0/3.0; | |
9 | |
10 /* aspect is called with the source resolution and the | |
11 * resolution, that the scaled image should fit into | |
12 */ | |
13 | |
2055
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2053
diff
changeset
|
14 void aspect(int *srcw, int *srch, int fitinw, int fitinh){ |
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2053
diff
changeset
|
15 int srcwcp, srchcp; |
f5146118777e
Simplified aspect() for the loss of some functionality to get ansi compatibility.
atmos4
parents:
2053
diff
changeset
|
16 srcwcp=*srcw; srchcp=*srch; |
2058
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
17 srcwcp=fitinw; |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
18 #ifdef ASPECT_DEBUG |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
19 printf("aspect(0) fitin: %dx%d \n",fitinw,fitinh); |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
20 printf("aspect(1) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch); |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
21 #endif |
2058
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
22 srchcp=(int)(((float)fitinw / (float)*srcw * (float)*srch) |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
23 * ((float)fitinh / ((float)fitinw / monitor_aspect))); |
2058
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
24 srchcp+=srchcp%2; // round |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
25 #ifdef ASPECT_DEBUG |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
26 printf("aspect(2) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch); |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
27 #endif |
2058
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
28 if(srchcp>fitinh || srchcp<*srch){ |
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
29 srchcp=fitinh; |
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
30 srcwcp=(int)(((float)fitinh / (float)*srch * (float)*srcw) |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
31 * ((float)fitinw / ((float)fitinh / (1/monitor_aspect)))); |
2058
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
32 srcwcp+=srcwcp%2; // round |
2053 | 33 } |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
34 #ifdef ASPECT_DEBUG |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
35 printf("aspect(3) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch); |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
36 #endif |
2058
b840d0913383
Fix case where srch, srcw and fitinw and fitinh are really the same variables.
atmos4
parents:
2055
diff
changeset
|
37 *srcw=srcwcp; *srch=srchcp; |
2071
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
38 #ifdef ASPECT_DEBUG |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
39 printf("aspect(4) wh: %dx%d (org: %dx%d)\n",srcwcp,srchcp,*srcw,*srch); |
7f27b212e07b
Add debug printfs to aspect(), add aspect() usage to vo_sdl.
atmos4
parents:
2058
diff
changeset
|
40 #endif |
2053 | 41 } |
42 |