From a2eb1b57ff3c28d93772dc62157e35a18ec881e4 Mon Sep 17 00:00:00 2001 From: Nicolas Dufresne Date: Mon, 29 Jun 2020 13:27:32 -0400 Subject: [PATCH] v4l2slh264dec: Wait on previous pending request in slice mode In slice mode, we'll do one request per slice. In order to recycle bitstream buffer, and not run-out, wait for the last pending request to complete and mark it done. We only wait after having queued the current slice in order to reduce that potential driver starvation and maintain performance (using dual buffering). Part-of: --- sys/v4l2codecs/gstv4l2codech264dec.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/sys/v4l2codecs/gstv4l2codech264dec.c b/sys/v4l2codecs/gstv4l2codech264dec.c index 0f00d5a796..aa2983b079 100644 --- a/sys/v4l2codecs/gstv4l2codech264dec.c +++ b/sys/v4l2codecs/gstv4l2codech264dec.c @@ -948,7 +948,7 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self, GstH264Picture * picture, guint flags) { GstVideoCodecFrame *frame; - GstV4l2Request *request; + GstV4l2Request *prev_request, *request; gsize bytesused; gboolean ret = FALSE; @@ -990,8 +990,6 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self, goto done; } - gst_h264_picture_set_user_data (picture, request, - (GDestroyNotify) gst_v4l2_request_free); frame = gst_video_decoder_get_frame (GST_VIDEO_DECODER (self), picture->system_frame_number); @@ -1026,10 +1024,22 @@ gst_v4l2_codec_h264_dec_submit_bitstream (GstV4l2CodecH264Dec * self, goto done; } + prev_request = gst_h264_picture_get_user_data (picture); + if (prev_request) { + if (!gst_v4l2_codec_h264_dec_wait (self, prev_request)) + goto done; + gst_v4l2_request_set_done (prev_request); + } + + gst_h264_picture_set_user_data (picture, g_steal_pointer (&request), + (GDestroyNotify) gst_v4l2_request_free); ret = TRUE; done: + if (request) + gst_v4l2_request_free (request); gst_v4l2_codec_h264_dec_reset_picture (self); + return ret; }