<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 2013-08-12 19:55, Stirling Westrup
wrote:<br>
</div>
<blockquote
cite="mid:CAJt7KB_d2ZFSn6gEFB8BCWnptqGtWG5eHX745g=-+et-0u9vdQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div>I've never before had to delve into the depths on how
gstreamer allocates and passes video buffers along, but its
looking like I will soon need to know this.<br>
<br>
</div>
I am assisting in porting OpenCL to gstreamer 1.0, and we'll
need some method of allocating and passing around OpenCL
buffers. Ideally, for my purposes, we'll want to build a
pipeline that passes a single unchanging buffer pointer, but
attaches different metadata to describe transformations. When
someone needs an actual frame of data, we'll combine the
transformations and perform them with an OpenCL kernel that
writes to a standard memory buffer.<br>
<br>
</div>
The documentation on how memory allocation and passing works in
gstreamer is kinda scant though, and I was hoping folks could
point me to useful tutorials and/or example code that I can
learn from.<br clear="all">
<div>
<div>
<div>
<div><br>
-- <br>
Stirling Westrup<br>
Programmer, Entrepreneur.<br>
<a moz-do-not-send="true"
href="https://www.linkedin.com/e/fpf/77228"
target="_blank">https://www.linkedin.com/e/fpf/77228</a><br>
<a moz-do-not-send="true"
href="http://www.linkedin.com/in/swestrup"
target="_blank">http://www.linkedin.com/in/swestrup</a><br>
<a moz-do-not-send="true"
href="http://technaut.livejournal.com" target="_blank">http://technaut.livejournal.com</a><br>
<a moz-do-not-send="true"
href="http://sourceforge.net/users/stirlingwestrup"
target="_blank">http://sourceforge.net/users/stirlingwestrup</a>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
gstreamer-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a>
</pre>
</blockquote>
<br>
Hello, I have recently written a plugin which also passes around
hardware buffers, so here are my comments.<br>
<br>
You need these components: a buffer pool, an allocator, a metadata
type, and a memory type.<br>
<br>
The memory type is derived from GstMemory, and extends it by
whatever you need for the OpenCL buffers (id's, addresses etc.)<br>
The allocator is used to allocate your custom memory blocks.<br>
The metadata is necessary to let downstream elements know that the
buffers you are sending them contain OpenCL specific stuff.<br>
The buffer pool uses the allocator to allocate memory with your
allocator. In GStreamer 1.0 , a GstBuffer (which is what a buffer
pool produces) is a container for metadata and memory blocks. You
allocate one memory block with your allocator, and append it to the
GstBuffer. You also create the OpenCL metadata, and add it to the
buffer.<br>
<br>
Now you can use the buffer pool to create GstBuffers. The buffer
pool logic takes care of reclaiming buffers that are no longer used
etc. One important limitation of buffer pools is that they can only
be used for buffers with the same total memory size (= the sum of
all of the buffer memory block sizes) and the same caps. If this
limitation is unacceptable, omit the buffer pool, and manually
create buffers + append memory blocks to them.<br>
<br>
Keep in mind that memory blocks may be shared. This typically
happens when subbuffers are created. Decide whether or not this is
something you want to allow.<br>
<br>
cheers<br>
</body>
</html>