From 0c5bbbb6ca5ff9c262e8a45f0b7f6be9ed4e4213 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Fri, 22 Sep 2017 16:02:40 +0200 Subject: [PATCH] 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 --- omx/gstomxvideoenc.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 89d0871468..7a55feb65e 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))