]> git.sesse.net Git - x264/commitdiff
Start counting when the first frame is encoded, not when x264_encoder_open is called.
authorKieran Kunhya <kieran@kunhya.com>
Tue, 8 Mar 2011 14:45:04 +0000 (14:45 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 23 Apr 2016 10:05:45 +0000 (12:05 +0200)
encoder/speed.c

index 7b5c400a292bb94d7371296fcfa1501e1bd0cb7a..09917a305a538cfdbd46914917fc60038ca3b393 100644 (file)
@@ -21,7 +21,10 @@ struct x264_speedcontrol_t
     float dither;
     x264_param_t user_param;
 
-    struct {
+    int first;
+
+    struct
+    {
         int64_t min_buffer, max_buffer;
         double avg_preset;
         int den;
@@ -52,6 +55,7 @@ void x264_speedcontrol_new( x264_t *h )
     sc->stat.min_buffer = sc->buffer_size;
     sc->stat.max_buffer = 0;
     sc->user_param = h->param;
+    sc->first = 1;
 }
 
 void x264_speedcontrol_delete( x264_t *h )
@@ -157,7 +161,14 @@ void x264_speedcontrol_frame( x264_t *h )
     x264_emms();
 
     // update buffer state after encoding and outputting the previous frame(s)
-    t = x264_mdate();
+    if( sc->first )
+    {
+        t = sc->timestamp;
+        sc->first = 0;
+    }
+    else
+        t = x264_mdate();
+
     delta_f = h->i_frame - sc->prev_frame;
     delta_t = t - sc->timestamp;
     delta_buffer = delta_f * sc->spf / h->param.sc.f_speed - delta_t;