From 71ff8236b53094cf6121552f687c383da6d063d2 Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Thu, 26 Sep 2019 09:52:14 +0800 Subject: [PATCH] msdkdec: set lockable flag When postpone_free_surface is TRUE, the output buffer is not writable, however the base decoder needs a writable buffer as output buffer, otherwise it will make a copy of the output buffer. As the underlying memory is always lockable, so we may set the LOCKABLE flag for this buffer to avoid buffer copy in the base class. The refcount of the output buffer is 1 when postpone_free_surface is FALSE, so needn't set the LOCKABLE flag for this case. --- sys/msdk/gstmsdkdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/msdk/gstmsdkdec.c b/sys/msdk/gstmsdkdec.c index 742aaa4331..59fe7441bb 100644 --- a/sys/msdk/gstmsdkdec.c +++ b/sys/msdk/gstmsdkdec.c @@ -140,6 +140,10 @@ allocate_output_buffer (GstMsdkDec * thiz, GstBuffer ** buffer) *buffer = gst_buffer_ref (frame->output_buffer); gst_buffer_replace (&frame->output_buffer, NULL); gst_video_codec_frame_unref (frame); + + if (thiz->postpone_free_surface) + GST_MINI_OBJECT_FLAG_SET (*buffer, GST_MINI_OBJECT_FLAG_LOCKABLE); + return GST_FLOW_OK; }