From: Edward Hervey Date: Sat, 4 Jun 2016 07:51:17 +0000 (+0200) Subject: videodecoder: Drain out keyframes in TRICK_MODE_KEY_UNITS X-Git-Tag: 1.19.3~511^2~2822 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=183e94b2d3ee830f196d45756563f4572c9954f7;p=platform%2Fupstream%2Fgstreamer.git videodecoder: Drain out keyframes in TRICK_MODE_KEY_UNITS When asked to just decode keyframe, if we got a keyframe drain out the decoder straight away. This avoids having to wait for the next frame and reduces delay even more. https://bugzilla.gnome.org/show_bug.cgi?id=767232 --- diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 5f463bd..ebcd7f2 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -2191,7 +2191,9 @@ gst_video_decoder_chain_forward (GstVideoDecoder * decoder, priv->input_offset += gst_buffer_get_size (buf); if (priv->packetized) { + gboolean was_keyframe = FALSE; if (!GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DELTA_UNIT)) { + was_keyframe = TRUE; GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (priv->current_frame); } @@ -2204,6 +2206,11 @@ gst_video_decoder_chain_forward (GstVideoDecoder * decoder, ret = gst_video_decoder_decode_frame (decoder, priv->current_frame); } priv->current_frame = NULL; + /* If in trick mode and it was a keyframe, drain decoder to avoid extra + * latency */ + if (was_keyframe + && (decoder->output_segment.flags & GST_SEEK_FLAG_TRICKMODE_KEY_UNITS)) + gst_video_decoder_drain_out (decoder, FALSE); } else { gst_adapter_push (priv->input_adapter, buf);