]> git.sesse.net Git - ffmpeg/blobdiff - libavutil/softfloat.h
avformat/hlsenc: improve hls encrypt get key file operation
[ffmpeg] / libavutil / softfloat.h
index e6d30ad333d7692fdc97bf9797e23fbf5031ed3b..b13d728f308273641aadc1a884cfaa6910314b50 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;
@@ -169,8 +176,10 @@ static inline av_const SoftFloat av_sub_sf(SoftFloat a, SoftFloat b){
 //FIXME log, exp, pow
 
 /**
- * Converts a mantisse and exponent to a SoftFloat
- * @returns a SoftFloat with value v * 2^frac_bits
+ * Converts a mantisse and exponent to a SoftFloat.
+ * This converts a fixed point value v with frac_bits fractional bits to a
+ * SoftFloat.
+ * @returns a SoftFloat with value v * 2^-frac_bits
  */
 static inline av_const SoftFloat av_int2sf(int v, int frac_bits){
     int exp_offset = 0;
@@ -234,12 +243,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;