]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/softfloat.h
avcodec/asvdec: Check buf_size
[ffmpeg] / libavutil / softfloat.h
index e6d30ad333d7692fdc97bf9797e23fbf5031ed3b..32b33d9dfd6b3457d9f908003ba9b09402130a33 100644 (file)
@@ -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;
@@ -234,12 +241,12 @@ static av_unused void av_sincos_sf(int a, int *s, int *c)
     int st, ct;
 
     idx = a >> 26;
-    sign = (idx << 27) >> 31;
+    sign = (int32_t)((unsigned)idx << 27) >> 31;
     cv = av_costbl_1_sf[idx & 0xf];
     cv = (cv ^ sign) - sign;
 
     idx -= 8;
-    sign = (idx << 27) >> 31;
+    sign = (int32_t)((unsigned)idx << 27) >> 31;
     sv = av_costbl_1_sf[idx & 0xf];
     sv = (sv ^ sign) - sign;