x264enc: Report latency base on x264 buffer size
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Wed, 18 Apr 2012 20:13:57 +0000 (16:13 -0400)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Mon, 18 Jun 2012 15:01:20 +0000 (16:01 +0100)
ext/x264/gstx264enc.c

index 5c0018e3a57fcd04f6a9dfadc920ef192ad8b6ea..ac7e620a8bcd85f5b03ff5b83c3c25587b81fac9 100644 (file)
@@ -1476,6 +1476,15 @@ gst_x264_enc_set_src_caps (GstX264Enc * encoder, GstCaps * caps)
   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
 gst_x264_enc_set_format (GstVideoEncoder * video_enc,
     GstVideoCodecState * state)
@@ -1647,6 +1656,8 @@ gst_x264_enc_set_format (GstVideoEncoder * video_enc,
     return FALSE;
   }
 
+  gst_x264_enc_set_latency (encoder);
+
   return TRUE;
 }
 
@@ -1757,6 +1768,7 @@ gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in,
     encoder->reconfig = FALSE;
     if (x264_encoder_reconfig (encoder->x264enc, &encoder->x264param) < 0)
       GST_WARNING_OBJECT (encoder, "Could not reconfigure");
+    gst_x264_enc_set_latency (encoder);
   }
 
   if (pic_in && input_frame) {