msdkdec: set lockable flag
authorHaihao Xiang <haihao.xiang@intel.com>
Thu, 26 Sep 2019 01:52:14 +0000 (09:52 +0800)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Mon, 30 Sep 2019 18:15:38 +0000 (18:15 +0000)
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

index 742aaa4..59fe744 100644 (file)
@@ -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;
 }