diff options
author | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-05 22:54:11 +0000 |
---|---|---|
committer | arpi <arpi@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2002-10-05 22:54:11 +0000 |
commit | 18e342e06c5e756bfa8e2de056ab716bd590a5a9 (patch) | |
tree | 27c63d0585da17077234c76483540119919c044b /libaf/af.c | |
parent | 8c465db5773df58f4e0a6529f05dbcdd181fe2df (diff) | |
download | mpv-18e342e06c5e756bfa8e2de056ab716bd590a5a9.tar.bz2 mpv-18e342e06c5e756bfa8e2de056ab716bd590a5a9.tar.xz |
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
Diffstat (limited to 'libaf/af.c')
-rw-r--r-- | libaf/af.c | 24 |
1 files changed, 11 insertions, 13 deletions
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<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 |