changeset 25917:afd170654f62

Make aspect adjustment calculation simpler and more flexible.
author reimar
date Sat, 02 Feb 2008 17:21:19 +0000
parents 19e79d9cc3f1
children 35698e5aa40c
files libvo/aspect.c
diffstat 1 files changed, 19 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/aspect.c	Sat Feb 02 11:26:25 2008 +0000
+++ b/libvo/aspect.c	Sat Feb 02 17:21:19 2008 +0000
@@ -66,44 +66,27 @@
  * resolution, that the scaled image should fit into
  */
 
-void aspect(int *srcw, int *srch, int zoom){
+void aspect_fit(int *srcw, int *srch, int fitw, int fith){
   int tmpw;
 
-  if( !zoom && geometry_wh_changed ) {
-#ifdef ASPECT_DEBUG
-    printf("aspect(0) no aspect forced!\n");
-#endif
-    return; // the user doesn't want to fix aspect
-  }
-
 #ifdef ASPECT_DEBUG
-  printf("aspect(0) fitin: %dx%d zoom: %d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
-      zoom,monitor_aspect);
+  printf("aspect(0) fitin: %dx%d screenaspect: %.2f\n",aspdat.scrw,aspdat.scrh,
+      monitor_aspect);
   printf("aspect(1) wh: %dx%d (org: %dx%d)\n",*srcw,*srch,aspdat.prew,aspdat.preh);
 #endif
-  if(zoom){
-    *srcw = aspdat.scrw;
-    *srch = (int)(((float)aspdat.scrw / (float)aspdat.prew * (float)aspdat.preh)
+    *srcw = fitw;
+    *srch = (int)(((float)fitw / (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",*srcw,*srch,aspdat.prew,aspdat.preh);
 #endif
   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
+      tmpw = (int)(((float)fith / (float)aspdat.preh * (float)aspdat.prew)
                 * ((float)aspdat.scrw / ((float)aspdat.scrh / (1.0/monitor_aspect))));
     tmpw+= tmpw%2; // round
     if(tmpw<=aspdat.scrw /*&& tmpw>=aspdat.orgw*/){
-      *srch = zoom?aspdat.scrh:aspdat.preh;
+      *srch = fith;
       *srcw = tmpw;
     }else{
 #ifndef ASPECT_TEST
@@ -119,6 +102,18 @@
 #endif
 }
 
+void aspect(int *srcw, int *srch, int zoom){
+  int fitw = zoom ? aspdat.scrw : aspdat.prew;
+  int fith = zoom ? aspdat.scrh : aspdat.preh;
+  if( !zoom && geometry_wh_changed ) {
+#ifdef ASPECT_DEBUG
+    printf("aspect(0) no aspect forced!\n");
+#endif
+    return; // the user doesn't want to fix aspect
+  }
+  aspect_fit(srcw, srch, fitw, fith);
+}
+
 void panscan_init( void )
 {
  vo_panscan_x=0;