summaryrefslogtreecommitdiffstats
path: root/libvo/aspect.c
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-10-03 14:41:53 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2001-10-03 14:41:53 +0000
commitabb7153e942b7e7324d8d6d81dd696a366ab944c (patch)
tree05f0aa1a9857766b5c329446ab5610eadfee2720 /libvo/aspect.c
parentd276fe563458936eb81e464ed439e0a2d80b3e69 (diff)
downloadmpv-abb7153e942b7e7324d8d6d81dd696a366ab944c.tar.bz2
mpv-abb7153e942b7e7324d8d6d81dd696a366ab944c.tar.xz
Monitor aspect stuff.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@2054 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo/aspect.c')
-rw-r--r--libvo/aspect.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/libvo/aspect.c b/libvo/aspect.c
new file mode 100644
index 0000000000..b9302614e0
--- /dev/null
+++ b/libvo/aspect.c
@@ -0,0 +1,32 @@
+/* Stuff for correct aspect scaling. */
+#include "aspect.h"
+
+float monitor_aspect=4.0/3.0;
+
+/* aspect is called with the source resolution and the
+ * resolution, that the scaled image should fit into
+ */
+
+rect_t aspect(int srcw, int srch, int fitinw, int fitinh){
+ rect_t r,z;
+ r.w=fitinw;
+ r.x=0;
+ r.h=(int)(((float)fitinw / (float)srcw * (float)srch)
+ * ((float)fitinh/((float)fitinw/monitor_aspect)));
+ r.h+=r.h%2; // round
+ r.y=(fitinh-r.h)/2;
+ z=r;
+ //printf("aspect rez x: %d y: %d wh: %dx%d\n",r.x,r.y,r.w,r.h);
+ if(r.h>fitinh || r.h<srch){
+ r.h=fitinh;
+ r.y=0;
+ r.w=(int)(((float)fitinh / (float)srch * (float)srcw)
+ * ((float)fitinw/((float)fitinh/(1/monitor_aspect))));
+ r.w+=r.w%2; // round
+ r.x=(fitinw-r.w)/2;
+ }
+ if(r.w>fitinw) r=z;
+ //printf("aspect ret x: %d y: %d wh: %dx%d\n",r.x,r.y,r.w,r.h);
+ return r;
+}
+