[gst-devel] plan to write a bayer filter

Benjamin Otte in7y118 at public.uni-hamburg.de
Mon Jan 10 06:16:05 CET 2005


General comment: We need a good intro on what link and getcaps functions
do, since a lot of people have a hard time understanding what this part of
a plugin does.

On Sun, 9 Jan 2005, Bertrik Sikken wrote:

> Bertrik Sikken wrote:
>  > Hi all,
>  >
>  > I'd like to announce that I plan to write a filter plugin
>  > for the Bayer format. Having a bayer filter should improve
>  > support for some webcams that export the format through V4L2
>  > (the webcam kernel drivers are no longer allowed to do the
>  > bayer conversion in kernel space).
>  >
>  > I already have the basic interpolation algorithm, but I'm
>  > completely new to gstreamer development (so it may take a
>  > while...)
>
> A couple more questions:
>
> I'm having trouble writing the get_caps and link functions.
> Basically I am not able to make the pipeline work properly,
> seeing various failure phenomena.
> For example the pipeline won't link (in gst-editor) and I have
> no clear idea how to debug it.
> Gst-launch complains about an erroneous pipeline, then tries
> to run it anyway. In some cases this produces and unkillable
> gdb process ('kill -9' as root cannot kill it), which is keeping
> my v4l2 device busy and I am forced to reboot. This makes the whole
> development process kind of troublesome.
>
It might be useful to dump some output to a file (via 4vlsrc ! filesink or
whatever) and use that. This is easy if Bayer frames are fixed size.
Just run the pipeline like this:
gst-launch gnomevfssrc location=/path/to/frames bytesperread=$framesize !
bayerdec ! ...
(You need to use gnomevfssrc here because filesrc's blocksizes need to be
multiples of 2 iirc.)

Off Topic: This trick works nicely for raw video dumps, too. Just run
something like
gst-launch gnomevfssrc location=/path/to/frames bytesperread=153600 !
video/x-raw-yuv,width=320,height=240,framerate=25.0,format=\(fourcc\)I420
! xvimagesink
and you can view it.

> I used the median filter plugin as an example for my bayer plugin
> (because it looked like a simple plugin with not-to-much code)
> This was perhaps not such a good idea, since the bayer plugin
> takes one video format and transforms it into another, while
> the median filter uses the same video format for input and
> output.
> Is there an existing gstreamer plugin that is better suitable
> to use as an example for my bayer plugin?
> (I can provide details on the bayer format if required)
>
Maybe have a look at a simple video decoder (if we have those - do we have
simple ones, I can only come up with mpeg2dec and ffmpeg and they're both
not simple) or colorspace transformation plugins (I believe there's an
alpha plugin somewhere that does I420=>AYUV or so?)
Anyway, some tips I find useful when doing caps stuff:

1) the simplest solution to get a plugin working first and not need
to care about link and getcaps is to only decode a fixed format. Elements
that only decode a fixed format don't need link or getcaps functions, they
specify the supported format in their fixed pad templates. Fixed caps can
easily be found: They don't contain ranges ("[x, y]") or lists ("{x, y,
...}").

2) when implementing caps stuff, particularly caps negotiation, the
GST_PADS debugging category is important. So running your app with
--gst-debug=GST_PADS:5 might clue you in on quite some stuff.
It might also be useful for general understanding to just watch what
happens when you run simple GStreamer pipelines with that debugging
output, like gst-launch videotestsrc ! xvimagesink --gst-debug=GST_PADS:5
or gst-launch v4lsrc ! xvimagesink --gst-debug=GST_PADS:5

3) Get to know gst-launch filtercaps syntax. It's very helpful if you can
just force a particular caps.

Benjamin





More information about the gstreamer-devel mailing list