apps/astreamer/helper.h

Go to the documentation of this file.
00001 #ifndef __H_HELPER__
00002 #define __H_HELPER__
00003 
00004 #include <sys/time.h>
00005 
00006 inline long time_delta_us(const struct timeval &tv_1, const struct timeval &tv_2) {
00007         long tu = tv_1.tv_usec;
00008         if(tv_1.tv_sec != tv_2.tv_sec)
00009                 tu += (tv_1.tv_sec - tv_2.tv_sec) * 1000000;
00010         tu -= tv_2.tv_usec;
00011         return tu;
00012 }
00013 
00014 inline struct timeval time_plus(struct timeval tv_1, const struct timeval &tv_2) {
00015         tv_1.tv_sec += tv_2.tv_sec;
00016         tv_1.tv_usec += tv_2.tv_usec;
00017         if(tv_1.tv_usec >= 1000000) {
00018                 tv_1.tv_sec++;
00019                 tv_1.tv_usec -= 1000000;
00020         }
00021         return tv_1;
00022 }
00023 
00024 inline struct timeval time_minus(struct timeval tv_1, const struct timeval &tv_2) {
00025         tv_1.tv_sec -= tv_2.tv_sec;
00026         tv_1.tv_usec += 1000000;
00027         tv_1.tv_usec -= tv_2.tv_usec;
00028         if(tv_1.tv_usec >= 1000000) {
00029                 tv_1.tv_usec -= 1000000;
00030         } else {
00031                 tv_1.tv_sec--;
00032         }
00033         return tv_1;
00034 }
00035 
00036 #endif

Generated on Fri Nov 28 00:06:21 2008 for elphel by  doxygen 1.5.1