return -1;
}
+int
+timespec_subtract (struct timespec *result,
+ struct timespec *x,
+ struct timespec *y)
+{
+ /* Perform the carry for the later subtraction by updating Y. */
+ if (x->tv_nsec < y->tv_nsec) {
+ int num_sec = (y->tv_nsec - x->tv_nsec) / 1000000000 + 1;
+ y->tv_nsec -= 1000000000 * num_sec;
+ y->tv_sec += num_sec;
+ }
+ if (x->tv_nsec - y->tv_nsec > 1000000000) {
+ int num_sec = (x->tv_nsec - y->tv_nsec) / 1000000000;
+ y->tv_nsec += 1000000000 * num_sec;
+ y->tv_sec -= num_sec;
+ }
+
+ /* Compute the time remaining to wait.
+ `tv_nsec' is certainly positive. */
+ result->tv_sec = x->tv_sec - y->tv_sec;
+ result->tv_nsec = x->tv_nsec - y->tv_nsec;
+
+ /* Return 1 if result is negative. */
+ return x->tv_sec < y->tv_sec;
+}
+
+static void
+print_timing(void)
+{
+ static struct timespec start = {0,0};
+ struct timespec end, d;
+ static int f = 0; /* number of frames */
+ double ifi;
+ static double ifi_avg=0, ifi_var=0;
+
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ timespec_subtract(&d, &end, &start);
+ if (f++ == 0)
+ goto out; /* First run */
+ ifi = (double)d.tv_sec + 1e-9*d.tv_nsec;
+#define SQ(x) ((x)*(x))
+ ifi_var = ifi_var*(f-1)/f + (double)(f-1)/SQ(f)*SQ(ifi-ifi_avg);
+ ifi_avg = ifi_avg*(f-1)/f + (double)ifi/f;
+ printf("%5d: interframe interval = 1/%5.2lf s avg=1/%.2f stddev=1/%3.2f\n",
+ f, 1/ifi, 1/ifi_avg, 1/sqrt(ifi_var));
+out:
+ start = end;
+}
+
/*
* The following code is the main loop of the file converter
*/
goto redo;
}
+ print_timing();
+
discard_packet:
av_free_packet(&pkt);
/* dump report by using the output first video and audio streams */
- print_report(output_files, ost_table, nb_ostreams, 0);
+ //print_report(output_files, ost_table, nb_ostreams, 0);
}
/* at the end of stream, we must flush the decoder buffers */