[FFmpeg-devel] [PATCH] libavutil/softfloat: Fix normalizations.

Nedeljko Babic nedeljko.babic at imgtec.com
Wed Jun 3 16:17:39 CEST 2015


av_normalize_sf doesn't properly address case when negative numbers are out
of defined range.

av_normalize1_sf doesn't properly address border case when mantis is
exactly 0x40000000.

This patch solves both of these problems.

Signed-off-by: Nedeljko Babic <nedeljko.babic at imgtec.com>
---
 libavutil/softfloat.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h
index 8097d28..182e517 100644
--- a/libavutil/softfloat.h
+++ b/libavutil/softfloat.h
@@ -47,7 +47,7 @@ static const SoftFloat FLOAT_0999999    = { 0x3FFFFBCE,   0};
 static av_const SoftFloat av_normalize_sf(SoftFloat a){
     if(a.mant){
 #if 1
-        while((a.mant + 0x20000000U)<0x40000000U){
+        while((FFABS(a.mant) + 0x20000000U)<0x40000000U){
             a.mant += a.mant;
             a.exp  -= 1;
         }
@@ -68,7 +68,7 @@ static av_const SoftFloat av_normalize_sf(SoftFloat a){
 
 static inline av_const SoftFloat av_normalize1_sf(SoftFloat a){
 #if 1
-    if((int32_t)(a.mant + 0x40000000U) < 0){
+    if((int32_t)(a.mant + 0x40000000U) <= 0){
         a.exp++;
         a.mant>>=1;
     }
-- 
1.8.2.1



More information about the ffmpeg-devel mailing list