From f1e64b4af108e3ff92bbafa8be619301507b50cc Mon Sep 17 00:00:00 2001 From: Kieran Kunhya Date: Tue, 8 Mar 2011 14:45:04 +0000 Subject: [PATCH] Start counting when the first frame is encoded, not when x264_encoder_open is called. --- encoder/speed.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/encoder/speed.c b/encoder/speed.c index 7b5c400a..09917a30 100644 --- a/encoder/speed.c +++ b/encoder/speed.c @@ -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; -- 2.39.2