aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2015-12-01 12:44:23 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2015-12-06 02:51:27 +0100
commit460710500e172042144784a3152aa8d1c5c29cf6 (patch)
tree72f300adbfbc945747f6efa2454006e72479b119
parent4d9999705f406b508e4ba017cd804b8688b64d68 (diff)
downloadffmpeg-460710500e172042144784a3152aa8d1c5c29cf6.tar.gz
avutil/mathematics: Do not treat INT64_MIN as positive in av_rescale_rnd
The code expects actual positive numbers and gives completely wrong results if INT64_MIN is treated as positive Instead clip it into the valid range that is add 1 and treat it as negative Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> (cherry picked from commit 25e37f5ea92d4201976a59ae306ce848d257a7e6) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavutil/mathematics.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index 126cffc3f0..b1ffd652de 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -76,8 +76,8 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
rnd -= AV_ROUND_PASS_MINMAX;
}
- if (a < 0 && a != INT64_MIN)
- return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd >> 1) & 1));
+ if (a < 0)
+ return -av_rescale_rnd(-FFMAX(a, -INT64_MAX), b, c, rnd ^ ((rnd >> 1) & 1));
if (rnd == AV_ROUND_NEAR_INF)
r = c / 2;