summaryrefslogtreecommitdiff
path: root/libavutil/mathematics.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-02 23:19:23 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-03 00:02:22 +0100
commit740e740895557a3b11715ccb203b7d882496046f (patch)
treec456bed782c88ccdb19797f3acbaa6318863c6cd /libavutil/mathematics.c
parent091ce6bcb21e860cfe726e83f16e99e280c90e1a (diff)
av_rescale: support passing MIN/MAX through
Reviewed-by: Clément Bœsch <ubitux@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil/mathematics.c')
-rw-r--r--libavutil/mathematics.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 6c2f6c04de..f9cf87da80 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -61,7 +61,13 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
int64_t r=0;
av_assert2(c > 0);
av_assert2(b >=0);
- av_assert2((unsigned)rnd<=5 && rnd!=4);
+ av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4);
+
+ if (rnd & AV_ROUND_PASS_MINMAX) {
+ if (a == INT64_MIN || a == INT64_MAX)
+ return a;
+ rnd -= AV_ROUND_PASS_MINMAX;
+ }
if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1));