add fps caculation macro
[profile/ivi/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapidebug.h
index d743c74..09ad7ef 100644 (file)
 GST_DEBUG_CATEGORY_EXTERN(gst_debug_vaapi);
 #define GST_CAT_DEFAULT gst_debug_vaapi
 #endif
+/* FPS Calculation for DEBUG */
+#define FPS_CALCULATION(objname)                     \
+    do{                                              \
+        static guint num_frame = 0;                  \
+        static struct timeval last_sys_time;         \
+        static struct timeval first_sys_time;        \
+        static int b_last_sys_time_init = FALSE;     \
+        if (!b_last_sys_time_init) {                 \
+          gettimeofday (&last_sys_time, NULL);       \
+          gettimeofday (&first_sys_time, NULL);      \
+          b_last_sys_time_init = TRUE;               \
+        } else {                                     \
+          if ((num_frame%50)==0) {                   \
+            double total, current;                   \
+            struct timeval cur_sys_time;             \
+            gettimeofday (&cur_sys_time, NULL);      \
+            total = (cur_sys_time.tv_sec - first_sys_time.tv_sec)*1.0f +       \
+                   (cur_sys_time.tv_usec - first_sys_time.tv_usec)/1000000.0f; \
+            current = (cur_sys_time.tv_sec - last_sys_time.tv_sec)*1.0f +      \
+                    (cur_sys_time.tv_usec - last_sys_time.tv_usec)/1000000.0f; \
+            printf("%s Current fps: %.2f, Total avg fps: %.2f\n",              \
+                    #objname, (float)50.0f/current, (float)num_frame/total);   \
+            last_sys_time = cur_sys_time;            \
+          }                                          \
+        }                                            \
+        ++num_frame;                                 \
+    }while(0)
+
 
 #endif /* GST_VAAPI_DEBUG_H */