x264enc: Report latency base on x264 buffer size

This commit is contained in:
Nicolas Dufresne 2012-04-18 16:13:57 -04:00 committed by Sebastian Dröge
parent 4fbb1a042e
commit 16ddcae4e3

View file

@ -1476,6 +1476,15 @@ gst_x264_enc_set_src_caps (GstX264Enc * encoder, GstCaps * caps)
return TRUE; return TRUE;
} }
static void
gst_x264_enc_set_latency (GstX264Enc * encoder)
{
GstVideoInfo *info = &encoder->input_state->info;
GstClockTime latency = gst_util_uint64_scale (GST_SECOND * info->fps_d,
x264_encoder_maximum_delayed_frames (encoder->x264enc), info->fps_n);
gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder), latency, latency);
}
static gboolean static gboolean
gst_x264_enc_set_format (GstVideoEncoder * video_enc, gst_x264_enc_set_format (GstVideoEncoder * video_enc,
GstVideoCodecState * state) GstVideoCodecState * state)
@ -1647,6 +1656,8 @@ gst_x264_enc_set_format (GstVideoEncoder * video_enc,
return FALSE; return FALSE;
} }
gst_x264_enc_set_latency (encoder);
return TRUE; return TRUE;
} }
@ -1757,6 +1768,7 @@ gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
encoder->reconfig = FALSE; encoder->reconfig = FALSE;
if (x264_encoder_reconfig (encoder->x264enc, &encoder->x264param) < 0) if (x264_encoder_reconfig (encoder->x264enc, &encoder->x264param) < 0)
GST_WARNING_OBJECT (encoder, "Could not reconfigure"); GST_WARNING_OBJECT (encoder, "Could not reconfigure");
gst_x264_enc_set_latency (encoder);
} }
if (pic_in && input_frame) { if (pic_in && input_frame) {