[Mplayer-cvslog] CVS: main/libaf af.c,1.7,1.8

Arpi of Ize arpi at mplayerhq.hu
Sun Oct 6 00:54:14 CEST 2002


Update of /cvsroot/mplayer/main/libaf
In directory mail:/var/tmp.root/cvs-serv21354

Modified Files:
	af.c 
Log Message:
af_calc_insize_constrained() rounding changes, works better for me this way


Index: af.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- af.c	5 Oct 2002 11:07:23 -0000	1.7
+++ af.c	5 Oct 2002 22:54:11 -0000	1.8
@@ -430,28 +430,26 @@
     mul.d *= af->mul.d;
     af=af->next;
   }while(af);
-  in = t * (((len/t) * mul.d)/mul.n);
+  in = t * (((len/t) * mul.d - 1)/mul.n);
+  
+  if(in>max_insize) in=t*(max_insize/t);
 
   // Try to meet constraint nr 3. 
-  out = t * (((in/t)*mul.n + 1)/mul.d);
-  while(in <= max_insize && out <= max_outsize){
-    if(out > len)
-      return in;
-    out = t * (((in/t)*mul.n + 1)/mul.d);
+  while((out=t * (((in/t+1)*mul.n - 1)/mul.d)) <= max_outsize){
+    if( (t * (((in/t)*mul.n))/mul.d) >= len) return in;
     in+=t;
   }
   
+//  printf("Could no meet constraint nr 3.  in=%d out=%d len=%d max_in=%d max_out=%d",
+//      in,out,len,max_insize,max_outsize);
+  
   // Could no meet constraint nr 3.
-  while((out > max_outsize || in > max_insize) && in > 1)
-  {
+  while(out > max_outsize || in > max_insize){
     in-=t;
+    if(in<t) return -1; // Input parameters are probably incorrect
     out = t * (((in/t)*mul.n + 1)/mul.d);
   }
-  if(in > 1)
-    return in;
-
-  // Input parameters are probably incorrect
-  return -1;
+  return in;
 }
 
 /* Helper function called by the macro with the same name this




More information about the MPlayer-cvslog mailing list