[FFmpeg-cvslog] avutil/mathematics: Do not treat INT64_MIN as positive in av_rescale_rnd
Michael Niedermayer
git at videolan.org
Tue Dec 1 13:27:15 CET 2015
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue Dec 1 12:44:23 2015 +0100| [25e37f5ea92d4201976a59ae306ce848d257a7e6] | committer: Michael Niedermayer
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 at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=25e37f5ea92d4201976a59ae306ce848d257a7e6
---
libavutil/mathematics.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index fde460c..689325f 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -71,8 +71,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;
More information about the ffmpeg-cvslog
mailing list