From 18e342e06c5e756bfa8e2de056ab716bd590a5a9 Mon Sep 17 00:00:00 2001 From: arpi Date: Sat, 5 Oct 2002 22:54:11 +0000 Subject: af_calc_insize_constrained() rounding changes, works better for me this way git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7604 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'libaf/af.c') diff --git a/libaf/af.c b/libaf/af.c index 78dc574709..8190948478 100644 --- a/libaf/af.c +++ b/libaf/af.c @@ -430,28 +430,26 @@ int af_calc_insize_constrained(af_stream_t* s, int len, 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 1) - return in; - - // Input parameters are probably incorrect - return -1; + return in; } /* Helper function called by the macro with the same name this -- cgit v1.2.3