summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2017-09-22 16:02:40 +0200
committerTim-Philipp Müller <tim@centricular.com>2018-01-22 17:04:27 +0000
commit0c5bbbb6ca5ff9c262e8a45f0b7f6be9ed4e4213 (patch)
treee6f9c1d7af86b4c5cbc2df1dd4ba9c272c45d101
parentfdf3b39dd4d634297c9a2effaea00f4dd0e71c52 (diff)
downloadgst-omx-0c5bbbb6ca5ff9c262e8a45f0b7f6be9ed4e4213.tar.gz
omxvideoenc: drop late input frames if QoS is enabled
Make use of the new GstVideoEncoder QoS API to drop late input frames. This may help a live pipeline to catch up if it's being late and all frames end up being dropped at the sink. https://bugzilla.gnome.org/show_bug.cgi?id=792783
-rw-r--r--omx/gstomxvideoenc.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index 89d0871..7a55feb 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -1716,6 +1716,7 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
GstOMXPort *port;
GstOMXBuffer *buf;
OMX_ERRORTYPE err;
+ GstClockTimeDiff deadline;
self = GST_OMX_VIDEO_ENC (encoder);
@@ -1726,6 +1727,16 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
return self->downstream_flow_ret;
}
+ deadline = gst_video_encoder_get_max_encode_time (encoder, frame);
+ if (deadline < 0) {
+ GST_WARNING_OBJECT (self,
+ "Input frame is too late, dropping (deadline %" GST_TIME_FORMAT ")",
+ GST_TIME_ARGS (-deadline));
+
+ /* Calling finish_frame with frame->output_buffer == NULL will drop it */
+ return gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (self), frame);
+ }
+
if (!self->started) {
if (gst_omx_port_is_flushing (self->enc_out_port)) {
if (!gst_omx_video_enc_enable (self, frame->input_buffer))