X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=x264_encoder.cpp;h=66c06344f4ce7710919241be4d9dd9e7d449b60c;hp=ccf6942e1813ef7aa4748b45b531d108dd06d64f;hb=982a1d295c56f0398d69263947b50475aee64b34;hpb=52067673f1649e995881331b111f891e1a83e286 diff --git a/x264_encoder.cpp b/x264_encoder.cpp index ccf6942..66c0634 100644 --- a/x264_encoder.cpp +++ b/x264_encoder.cpp @@ -343,7 +343,12 @@ void X264Encoder::encode_frame(X264Encoder::QueuedFrame qf) } if (speed_control) { - speed_control->before_frame(float(free_frames.size()) / X264_QUEUE_LENGTH, X264_QUEUE_LENGTH, 1e6 * qf.duration / TIMEBASE); + float queue_fill_ratio; + { + lock_guard lock(mu); + queue_fill_ratio = float(free_frames.size()) / X264_QUEUE_LENGTH; + } + speed_control->before_frame(queue_fill_ratio, X264_QUEUE_LENGTH, 1e6 * qf.duration / TIMEBASE); } dyn.x264_encoder_encode(x264, &nal, &num_nal, input_pic, &pic); if (speed_control) {