diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2017-05-06 21:31:49 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2017-05-17 20:35:19 +0200 |
commit | c99e86556c0ddf3eae9c77fdca85c2ff44352ec1 (patch) | |
tree | 642c6ccb74dd6f26d626a4e015dbd1f4798d0b4f /libavutil | |
parent | a5c7c22c66ccace0f056531be853327115dc2412 (diff) | |
download | ffmpeg-c99e86556c0ddf3eae9c77fdca85c2ff44352ec1.tar.gz |
avutil/softfloat: Fix overflow in av_div_sf()
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 277e397eb5964999bd76909f52d4bd3350289c22)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/softfloat.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h index 8e28a0e6ee..b4fce57906 100644 --- a/libavutil/softfloat.h +++ b/libavutil/softfloat.h @@ -110,8 +110,15 @@ static inline av_const SoftFloat av_mul_sf(SoftFloat a, SoftFloat b){ * @return Will not be more denormalized than a. */ static inline av_const SoftFloat av_div_sf(SoftFloat a, SoftFloat b){ + int64_t temp = (int64_t)a.mant * (1<<(ONE_BITS+1)); + temp /= b.mant; a.exp -= b.exp; - a.mant = ((int64_t)a.mant<<(ONE_BITS+1)) / b.mant; + a.mant = temp; + while (a.mant != temp) { + temp /= 2; + a.exp--; + a.mant = temp; + } a = av_normalize1_sf(a); if (!a.mant || a.exp < MIN_EXP) return FLOAT_0; |