[FFmpeg-cvslog] avutil/softfloat: Fix overflow in av_div_sf()
Michael Niedermayer
git at videolan.org
Sun May 7 00:24:48 EEST 2017
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sat May 6 21:31:49 2017 +0200| [277e397eb5964999bd76909f52d4bd3350289c22] | committer: Michael Niedermayer
avutil/softfloat: Fix overflow in av_div_sf()
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=277e397eb5964999bd76909f52d4bd3350289c22
---
libavutil/softfloat.h | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
index 5d376e438a..32b33d9dfd 100644
--- a/libavutil/softfloat.h
+++ b/libavutil/softfloat.h
@@ -113,8 +113,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;
More information about the ffmpeg-cvslog
mailing list