summaryrefslogtreecommitdiff
path: root/ext/x265
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-02-11 14:16:21 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-02-11 14:16:21 +0100
commit037928dcf675b1c6b360258878ae0e060621c03e (patch)
tree1c1aa293633c6ef940b2cddd6ddb180fb848f120 /ext/x265
parent629b3508061afe3bc89e09a4b89e3a24d5c38a49 (diff)
Improve and fix LATENCY query handling
This now follows the design docs everywhere, especially the maximum latency handling. https://bugzilla.gnome.org/show_bug.cgi?id=744106
Diffstat (limited to 'ext/x265')
-rw-r--r--ext/x265/gstx265enc.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/ext/x265/gstx265enc.c b/ext/x265/gstx265enc.c
index e1621e922..f64480f5f 100644
--- a/ext/x265/gstx265enc.c
+++ b/ext/x265/gstx265enc.c
@@ -824,27 +824,32 @@ static void
gst_x265_enc_set_latency (GstX265Enc * encoder)
{
GstVideoInfo *info = &encoder->input_state->info;
+ gint max_delayed_frames;
+ GstClockTime latency;
- if (info->fps_n) {
- GstClockTime latency;
- gint max_delayed_frames;
-
- // FIXME get a real value from the encoder, this is currently not exposed
+ /* FIXME get a real value from the encoder, this is currently not exposed */
+ if (encoder->tune > 0 && encoder->tune <= G_N_ELEMENTS (x265_tune_names) &&
+ strcmp (x265_tune_names[encoder->tune + 1], "zerolatency") == 0)
+ max_delayed_frames = 0;
+ else
max_delayed_frames = 5;
+
+ if (info->fps_n) {
latency = gst_util_uint64_scale_ceil (GST_SECOND * info->fps_d,
max_delayed_frames, info->fps_n);
-
- GST_INFO_OBJECT (encoder,
- "Updating latency to %" GST_TIME_FORMAT " (%d frames)",
- GST_TIME_ARGS (latency), max_delayed_frames);
-
- gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder), latency,
- latency);
} else {
- /* We can't do live as we don't know our latency */
- gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder),
- 0, GST_CLOCK_TIME_NONE);
+ /* FIXME: Assume 25fps. This is better than reporting no latency at
+ * all and then later failing in live pipelines
+ */
+ latency = gst_util_uint64_scale_ceil (GST_SECOND * 1,
+ max_delayed_frames, 25);
}
+
+ GST_INFO_OBJECT (encoder,
+ "Updating latency to %" GST_TIME_FORMAT " (%d frames)",
+ GST_TIME_ARGS (latency), max_delayed_frames);
+
+ gst_video_encoder_set_latency (GST_VIDEO_ENCODER (encoder), latency, latency);
}
static gboolean