add fps caculation macro
authorWind Yuan <feng.yuan@intel.com>
Tue, 6 Dec 2011 01:19:56 +0000 (20:19 -0500)
committerZhong Cong <congx.zhong@intel.com>
Tue, 5 Feb 2013 07:37:10 +0000 (15:37 +0800)
gst-libs/gst/vaapi/gstvaapidebug.h
gst/vaapi/gstvaapiupload.c

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 */
index f91f148..5a07ba5 100644 (file)
@@ -423,7 +423,7 @@ gst_vaapiupload_transform(
             if (!gst_vaapi_surface_put_image(surface, image))
                 goto error_put_image;
         }
-        return GST_FLOW_OK;
+        goto flow_ok;
     }
 
     image = gst_vaapi_video_pool_get_object(upload->images);
@@ -435,6 +435,9 @@ gst_vaapiupload_transform(
     gst_vaapi_video_pool_put_object(upload->images, image);
     if (!success)
         goto error_put_image;
+
+flow_ok:
+    FPS_CALCULATION(vaapiconvert);
     return GST_FLOW_OK;
 
 error_put_image: