[gst-devel] VideoFilter(transformation element) implementation

Stefan Kost ensonic at hora-obscura.de
Fri Apr 2 09:27:46 CEST 2010


Am 02.04.2010 00:17, schrieb alex:
> Hello to all.
> 
> I'm a novice in gstreamer plugins writing, so the question to "novice".
> I'm using debian squeeze with gstreamer-0.10.28 from distribution.
> 
> I need to implement element which can be described as 
> video_coverter/video_filter.
> Unfortunately there are no such example in PWG(as for now i don't read 
> it to the end, just finished chapter 2), there is only gsttransform.c 
> element and gstplugin.c . Particularly my element must have independent 
> input and output buffers, because of kind of processing happening.

There are lot of examples in the atual plugins. Also
gst-plugins-base/gst-libs/gst/video has a GstVideoFilter baseclass.

For transform type of filters there are two modes: in place where you modyfy the
received bufffer and push that further and not in place. When operating not in
place, you allocate a new buffer (gst_pad_alloc_new_and_set_caps()) process
input, putting the result into the new buffer, then you copy buffer metadata
over (gst_buffer_copy_metadata()). FInally you unref the input-buffer and push
the new buffer.

Stefan

> 
> At first I tried to realize this on base of gstplugin code with creation 
> of additional GstBuffer (which act as output) but this causes memory 
> leak, because i can't free memory before pass data to output.
> 
> 2-nd try was to create a temporary buffer directly using glib memory 
> management function g_memdup() with copy of input GstBuffer data, then 
> modify something, then copy data back to GstBuffer, free allocated 
> memory and output modified GstBuffer to element sink pad. In this case i 
> haven't troubles with memory but it can be seen (i see for example 
> blinking(black - orig, red - after modify) square) that, as i understand 
> that outputted data overwritten by inputted sometimes, as element has 
> one buffer.
> 
> Finally, as i understand there is no pre-made class for video-filters, 
> so i must derive my plugin from GstBaseTransform (so use gsttransform.c 
> template). As all that i try to do earlier - stupid.
> 
> In gstreamer-libs documentation i found that i need to implement 
> "prepare_output_buffer" function where output buffer must be created:
> ==============================================================
> Normal mode
>      *      always_in_place flag is not set, or there is no transform_ip 
> function
>      *      Element will receive an input buffer and output buffer to 
> operate on.
>      *      Output buffer is allocated by calling the 
> prepare_output_buffer function.
> Example elements
>      * Videoscale, ffmpegcolorspace, audioconvert when doing 
> scaling/conversions
> 
> Special output buffer allocations
>      *      Elements which need to do special allocation of their output 
> buffers other than what gst_buffer_pad_alloc allows should implement a 
> prepare_output_buffer method, which calls the parent implementation and 
> passes the newly allocated buffer.
> ===============================================================
> 
> But i'm found no example on how to implement such function.
> Can anyone be so kind and give implementation example or some direction 
> where i can learn how to write video transformation element that work in 
> "Normal mode"
> 
> P.S. If you need any additional info please ask. And I tried to look at 
> "Example elements" which pointed in docs (videoscale, ffmpegcolorspace), 
> but they are at least complicated and overloaded by concrete 
> case|implementation, and so not clear for novice like me.
> 
> I found solution with temporary buffer that works (in gstplugin.c case), 
> so now I'm not sure that my try with  g_memdup()/g_free() was totally wrong.
> 
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel





More information about the gstreamer-devel mailing list