summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2015-02-11 13:56:48 +0100
committerSebastian Dröge <sebastian@centricular.com>2015-02-11 13:56:48 +0100
commit7dc03df3ded9ce1edbb81d72fea0ceeba3252820 (patch)
treeacb40538602384e46b22fe1fe71ac47171311f59
parent5dd1a289061974ce635ae4d74147e6d19ac5d575 (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
-rw-r--r--ext/x264/gstx264enc.c28
-rw-r--r--gst/asfdemux/gstasfdemux.c3
2 files changed, 16 insertions, 15 deletions
diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c
index 0a2280bb..11616532 100644
--- a/ext/x264/gstx264enc.c
+++ b/ext/x264/gstx264enc.c
@@ -1728,25 +1728,27 @@ static void
gst_x264_enc_set_latency (GstX264Enc * encoder)
{
GstVideoInfo *info = &encoder->input_state->info;
+ gint max_delayed_frames;
+ GstClockTime latency;
+
+ max_delayed_frames = x264_encoder_maximum_delayed_frames (encoder->x264enc);
if (info->fps_n) {
- GstClockTime latency;
- gint max_delayed_frames;
- max_delayed_frames = x264_encoder_maximum_delayed_frames (encoder->x264enc);
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,
- GST_CLOCK_TIME_NONE);
} 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
diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c
index 417e569c..ea2f14d8 100644
--- a/gst/asfdemux/gstasfdemux.c
+++ b/gst/asfdemux/gstasfdemux.c
@@ -4335,8 +4335,7 @@ gst_asf_demux_handle_src_query (GstPad * pad, GstObject * parent,
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
GST_OBJECT_LOCK (demux);
- if (min != -1)
- min += demux->latency;
+ min += demux->latency;
if (max != -1)
max += demux->latency;
GST_OBJECT_UNLOCK (demux);