]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-11922: [core] improve switch_calc_bitrate
authorMike Jerris <mike@signalwire.com>
Mon, 8 Jul 2019 23:09:50 +0000 (19:09 -0400)
committerAndrey Volk <andywolk@gmail.com>
Wed, 17 Jul 2019 20:53:14 +0000 (00:53 +0400)
src/include/switch_utils.h

index 59cf898f64927756b7443cf32887dbdddd6be7b1..a810bf07f15e0d0907c0f150f867738a52efd442 100644 (file)
@@ -1056,19 +1056,27 @@ SWITCH_DECLARE(char *) switch_util_quote_shell_arg_pool(const char *string, swit
 #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK || status == SWITCH_STATUS_INUSE)
 
 
-static inline int32_t switch_calc_bitrate(int w, int h, int quality, double fps)
-{
-       int r;
+static inline int32_t switch_calc_bitrate(int w, int h, float quality, double fps)
+{   
+    int r;
 
-       /* KUSH GAUGE*/
+    if (quality == 0) {
+        quality = 1;
+    }
 
-       if (!fps) fps = 15;
+    /* KUSH GAUGE*/
 
-       r = (int32_t)((double)(w * h * fps * (quality ? quality : 1)) * 0.07) / 1000;
+    if (!fps) fps = 15;
 
-       if (!quality) r /= 2;
+    r = (int32_t)((double)(w * h * fps * quality) * 0.07) / 1000;
 
-       return r;
+    if (!quality) r /= 2;
+
+    if (quality < 0.0f) {
+        r = (int) ((float)r * quality);
+    }
+
+    return r;
 
 }