]> rtime.felk.cvut.cz Git - frescor/demo.git/commitdiff
recorder: Fix framerate calulation
authorMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 17 May 2010 13:12:21 +0000 (15:12 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Mon, 17 May 2010 13:12:21 +0000 (15:12 +0200)
The calculation incorrectly take into account the first frame even
if we didn't calculate interframe interval from it.

src/recorder/ffmpeg.c

index 0336d7821375be0315d1ee079c1092c25f03d7e9..f0ace22ac70119b37e4f013dbf7158abe649a18b 100644 (file)
@@ -1597,13 +1597,13 @@ print_timing(void)
 {
        static struct timespec start = {0,0};
        struct timespec end, d;
-       static int f = 0;       /* number of frames */
+       static int f = -1;      /* number interframe intevals elapsed */
        double ifi;
        static double ifi_avg=0, ifi_var=0;
 
        clock_gettime(CLOCK_MONOTONIC, &end);
        timespec_subtract(&d, &end, &start);
-       if (f++ == 0)
+       if (f++ < 0)
                goto out;       /* First run */
        ifi = (double)d.tv_sec + 1e-9*d.tv_nsec;
 #define SQ(x) ((x)*(x))        
@@ -4018,7 +4018,6 @@ static const OptionDef options[] = {
 };
 
 #ifdef CONFIG_FFMPEG_WITH_FRSH
-
 void *av_encode_thread(void *arg)
 {
     int ret, terror;