encoder: mpeg2: use fabsf() instead of abs()
authorVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Fri, 3 Apr 2015 18:27:24 +0000 (20:27 +0200)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Wed, 8 Apr 2015 14:20:55 +0000 (16:20 +0200)
The member value in frame_rate_tab is float, the result of the abs() function
should be float too. But abs() only manages integers.

This patch replaces abs() with fabsf() to handle correctly the possible floats
values.

https://bugzilla.gnome.org/show_bug.cgi?id=747312

gst-libs/gst/vaapi/gstvaapiencoder_mpeg2.c

index 4536365..9747ae1 100644 (file)
@@ -22,6 +22,7 @@
  */
 
 #include "sysdeps.h"
+#include <math.h>
 #include <va/va.h>
 #include <va/va_enc_mpeg2.h>
 #include <gst/base/gstbitwriter.h>
@@ -887,9 +888,9 @@ find_frame_rate_code (const VAEncSequenceParameterBufferMPEG2 * seq_param)
 
   for (i = 0; i < sizeof (frame_rate_tab) / sizeof (frame_rate_tab[0]); i++) {
 
-    if (abs (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value) < delta) {
+    if (fabsf (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value) < delta) {
       code = frame_rate_tab[i].code;
-      delta = abs (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value);
+      delta = fabsf (1000 * frame_rate_tab[i].value - 1000 * frame_rate_value);
     }
   }
   return code;