GNOME Bugzilla – Bug 521392
Proposed patches for bayer2rgb encoding
Last modified: 2008-04-17 18:13:30 UTC
I wanted to use this plugin for decoding the data produced by a v4l2 camera (a very cheap USB model) and found it didn't work. When I looked into the code, I found that reason it wasn't working was because the routine assumed a format of RGGB, but the (standard) output from v4l2 is BGGR. Additionally, the conversion being done did not include any interpolation, and there were several areas which were not really a "finished product". On the first point (format), I spent some time searching the internet to find out what common formats were used for streaming (video) data. The conclusion I came to was that the v4l2 format V4L2_PIX_FMT_SBGGR8 is the only one with any common usage. The v4l2 project has assigned a fourcc code of BA81 for this. In order to allow gstreamer to properly handle this format, I am attaching a .tgz file containing two proposed patches. The first is a trivial patch to videotestsrc.c which changes its output for this format, as well as the fourcc code which it produces. The second is a very substantial patch to gstbayer2rgb.c which replaces all of the previous conversion logic with routines to transform with interpolation. There are a large number of comments within the patched code to describe what I (think I) am doing. The code is not particularly clever or efficient, but it seems to be working well, and has been extensively tested with a combination of gdb and valgrind using test data from my patched version of videotestsrc, as well as with my (cheap) camera. In view of the fact that this format is certainly not widely used, and it is unlikely that the transformation efficiency will be a constraint, I didn't feel it would be worthwhile to spend more time improving that. I also cleaned up all of the areas of the routine which I found questionable, and added the ability to produce a wide variety of RGB formats. If others feel that some improvement is needed, or other features really should be added, I would be happy to do any further work that is required. Otherwise, I feel the enclosed patch is a substantial improvement to the existing code, and would urge that it be adopted.
Created attachment 106910 [details] [review] patches to videotestsrc.c and gstbayer2rgb.c to change to BGGR
The attachment is just garbage. Could you try that again?
Created attachment 107107 [details] [review] Trivial patch to change bayer output to BGGR format
Created attachment 107108 [details] [review] Patch for gstbayer2rgb.c for interpolated BGGR format
Both applied, thanks.