Tizen 2.0 Release
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapidebug.h
1 /*
2  *  gstvaapidebug.h - VA-API debugging utilities
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public License
8  *  as published by the Free Software Foundation; either version 2.1
9  *  of the License, or (at your option) any later version.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free
18  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA 02110-1301 USA
20  */
21
22 #ifndef GST_VAAPI_DEBUG_H
23 #define GST_VAAPI_DEBUG_H
24
25 #include <gst/gstinfo.h>
26 #include <sys/time.h>
27 #include <stdio.h>
28 #include <gst/gst.h>
29 #include <gst/vaapi/gstvaapidisplay.h>
30
31 #if DEBUG
32 GST_DEBUG_CATEGORY_EXTERN(gst_debug_vaapi);
33 #define GST_CAT_DEFAULT gst_debug_vaapi
34 #endif
35 /* FPS Calculation for DEBUG */
36 #define FPS_CALCULATION(objname)                     \
37     do{                                              \
38         static guint num_frame = 0;                  \
39         static struct timeval last_sys_time;         \
40         static struct timeval first_sys_time;        \
41         static int b_last_sys_time_init = FALSE;     \
42         if (!b_last_sys_time_init) {                 \
43           gettimeofday (&last_sys_time, NULL);       \
44           gettimeofday (&first_sys_time, NULL);      \
45           b_last_sys_time_init = TRUE;               \
46         } else {                                     \
47           if ((num_frame%50)==0) {                   \
48             double total, current;                   \
49             struct timeval cur_sys_time;             \
50             gettimeofday (&cur_sys_time, NULL);      \
51             total = (cur_sys_time.tv_sec - first_sys_time.tv_sec)*1.0f +       \
52                    (cur_sys_time.tv_usec - first_sys_time.tv_usec)/1000000.0f; \
53             current = (cur_sys_time.tv_sec - last_sys_time.tv_sec)*1.0f +      \
54                     (cur_sys_time.tv_usec - last_sys_time.tv_usec)/1000000.0f; \
55             printf("%s Current fps: %.2f, Total avg fps: %.2f\n",              \
56                     #objname, (float)50.0f/current, (float)num_frame/total);   \
57             last_sys_time = cur_sys_time;            \
58           }                                          \
59         }                                            \
60         ++num_frame;                                 \
61     }while(0)
62
63
64 #endif /* GST_VAAPI_DEBUG_H */