summaryrefslogtreecommitdiffstats
path: root/libavutil
diff options
context:
space:
mode:
authorClément Bœsch <cboesch@gopro.com>2017-09-02 19:17:45 +0200
committerClément Bœsch <u@pkh.me>2017-09-08 18:51:05 +0200
commit9c0d823a7c2c29560f298a007289b9a63d0e3b87 (patch)
tree83e415cd342ca75c33f9f7624daadb8be9d99ce1 /libavutil
parente0d56f097f42bcdbe6c3b2f57df62a4da63f2094 (diff)
downloadffmpeg-streaming-9c0d823a7c2c29560f298a007289b9a63d0e3b87.zip
ffmpeg-streaming-9c0d823a7c2c29560f298a007289b9a63d0e3b87.tar.gz
lavu/timer.h: factor out timer report
This commit is meant to reduce the diff in the following one.
Diffstat (limited to 'libavutil')
-rw-r--r--libavutil/timer.h27
1 files changed, 15 insertions, 12 deletions
diff --git a/libavutil/timer.h b/libavutil/timer.h
index ed3b047..da0761b 100644
--- a/libavutil/timer.h
+++ b/libavutil/timer.h
@@ -60,23 +60,17 @@
# define FF_TIMER_UNITS "UNITS"
#endif
-#ifdef AV_READ_TIME
-#define START_TIMER \
- uint64_t tend; \
- uint64_t tstart = AV_READ_TIME(); \
-
-#define STOP_TIMER(id) \
- tend = AV_READ_TIME(); \
+#define TIMER_REPORT(id, tdiff) \
{ \
static uint64_t tsum = 0; \
static int tcount = 0; \
static int tskip_count = 0; \
static int thistogram[32] = {0}; \
- thistogram[av_log2(tend - tstart)]++; \
- if (tcount < 2 || \
- tend - tstart < 8 * tsum / tcount || \
- tend - tstart < 2000) { \
- tsum+= tend - tstart; \
+ thistogram[av_log2(tdiff)]++; \
+ if (tcount < 2 || \
+ (tdiff) < 8 * tsum / tcount || \
+ (tdiff) < 2000) { \
+ tsum += (tdiff); \
tcount++; \
} else \
tskip_count++; \
@@ -90,6 +84,15 @@
av_log(NULL, AV_LOG_ERROR, "\n"); \
} \
}
+
+#ifdef AV_READ_TIME
+#define START_TIMER \
+ uint64_t tend; \
+ uint64_t tstart = AV_READ_TIME(); \
+
+#define STOP_TIMER(id) \
+ tend = AV_READ_TIME(); \
+ TIMER_REPORT(id, tend - tstart)
#else
#define START_TIMER
#define STOP_TIMER(id) { }
OpenPOWER on IntegriCloud