Web lists-archives.com

[Spca50x-devs] video4linux 1 compatibilty wrapper for video4linux 2 devices




Hi All,

As some of you know using v4l1 apps with v4l2 drivers doesn't work very well, most v4l2 drivers don't implement the VIDIOCGMBUF ioctl at all, and those that do, often only deliver pixelformats which v4l1 applications don't expect / can't handle.

In order to fix this at the kernel level we would need to put conversion from formats like jpeg and bayer to bgr24 or yuv420 in to the kernel, but one of the points of v4l2 is to drop all that conversion code from the kernel and do it in userspace where it belongs.

Trying to not do conversion in the kernel, but still make apps think its done in the kernel. leads to IMHO overly complex solutions like this:
http://www.linuxtv.org/v4lwiki/index.php/V4L2UserspaceLibrary

Thus inspired by similar solutions for using applications which want to output sound to oss with arts, I've created a c-library wrapper which intercepts the following calls to video4linux2 devices:

open
close
read
ioctl
mmap

And emulates v4l1, including doing format conversions where necessary. I've tested this with my pac207 v4l2 driver and the uvc driver.

Using ekiga and spcaview in both mmap and read modus. And read modus even works on the uvc driver (which doesn't support read), as the wrapper emulates it using mmap

To give this a try:
tar xvfz v4l1-compat-0.1.tar.gz
cd v4l1-compat
make
export LD_PRELOAD=`pwd`/v4l1-compat.so
<run v4l1 application>

---

Future plans:
1) bugfix where necessary
2) maybe add v4l2 -> v4l2 emulating more supported formats (iow do conversion)
   so that for example xawtv which wants rgb or yuv, can work with bayer /
   jpg webcams too.


But the biggest future plan is splitting the current wrapper into a real libray called v4l-lib and a wrapper using it. The lib would offer v4l_open, v4l_ioctl, etc which will behave exactly as the real ones, except that it will do things like conversion where necessary. The idea here is that applications can very easily be ported to this new lib (just replace open with v4l_open, etc) and then we have one central place to things like decoding of certain pixformats, but also (in a far future) certain image enhancement algorithm's

Applications which don't want this can keep using the plain open, ioctl, etc. But for applications who do want things like conversion done for them, they can now gain that with little effort.

This would for example make it possible to use camorama with v4l2 cams with very little effort.

Regards,

Hans




Attachment: v4l1-compat-0.1.tar.gz
Description: GNU Zip compressed data

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Spca50x-devs mailing list
Spca50x-devs@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/spca50x-devs