After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 571772 - Possible issue with v4l2src and libv4l different way of ordering formats
Possible issue with v4l2src and libv4l different way of ordering formats
Status: RESOLVED NOTGNOME
Product: GStreamer
Classification: Platform
Component: gst-plugins-good
0.10.22
Other All
: Normal normal
: NONE
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 583022 (view as bug list)
Depends on:
Blocks: 593764
 
 
Reported: 2009-02-14 19:25 UTC by Glenn Powers
Modified: 2009-09-01 09:15 UTC
See Also:
GNOME target: ---
GNOME version: 2.25/2.26


Attachments
libv4l log (21.06 KB, text/plain)
2009-05-17 07:49 UTC, Filippo Argiolas
Details
gstreamer log (464.77 KB, application/x-bzip)
2009-05-17 08:06 UTC, Filippo Argiolas
Details

Description Glenn Powers 2009-02-14 19:25:26 UTC
Please describe the problem:
After "upgrading" to Ubuntu Jaunty Alpha2 (with current updates) on my MacBook v4,1 Cheese does not show proper colors or luminosity. I just see a green and magenta image. It worked fine in Intrepid.

Steps to reproduce:
1. Use a MacBook v4,1
2. Install Ubuntu Jaunty (9.04) Alpha2 
3. Install Cheese


Actual results:
I see a green and magenta image

Expected results:
I would like to see colors and luminosity.

Does this happen every time?
Yes.

Other information:
I am 90% sure I'm using the same iSight Firmware.
Comment 1 Filippo Argiolas 2009-03-01 09:33:30 UTC
Nothing changed in the way we handle the webcam between Intrepid and Jaunty.
It is more likely that something changed in your webcam driver.
Comment 2 Filippo Argiolas 2009-05-17 07:45:54 UTC
Daniel, I think this is the very same issue as yours. Did you contact Hans about it?

Just to summarize our findings:
The issue happens when libv4l converts UYVY, the native webcam format, to YV12.
It is likely some issue in libv4l conversion code, but it's triggered by a more tricky issue related to the intimate way gstreamer caps negotiation works:

- libv4l reports a list of supported formats to gstreamer that contains the actual formats supported by the device plus each format it can handle through a conversion.

- as far as I can tell that list is ordered with the actual supported formats on top so that the application can pick just the first reported format and no conversion will happen

- gstreamer sees this as the list of formats supported by the webcam with no particular precedence or meaning in its order.

- it reorders the list with its own rules needed for the way caps negatiotion/fixation works

- with this reordering YV12 is prioritized agains UYVY so that's the format v4l2src asks to libv4l

- the result is that we have a redundant UYVY->YV12 conversion even if it's not really needed since we could have just requested the native UYVY format

Hans can you confirm my findings?
IMHO the easiest way to fix this particular issue would be to fix the UYVY->YV12 conversion code in libv4l (assuming it's actually bugged).

Reassigning to gstreamer so that we can get some feedback there too.

Comment 3 Filippo Argiolas 2009-05-17 07:49:39 UTC
Created attachment 134798 [details]
libv4l log
Comment 4 Filippo Argiolas 2009-05-17 08:06:33 UTC
Created attachment 134799 [details]
gstreamer log
Comment 5 daniel g. siegel 2009-05-17 10:20:52 UTC
a decent workaround is to not use "v4l2src ! ..." but "v4l2src ! videoscale ! ..."

not sure, why that works though...
Comment 6 Hans de Goede 2009-05-17 10:25:50 UTC
I've checked the specific conversion routine and I can confirm that there is a bug in libv4l there, I will make a patched version available later today. This will not solve the unneeded conversion problem, but that is minor compared to the fsck-ed up colors problem.

I have some ideas for the unneeded conversion problem too, but that will take more time.
Comment 7 daniel g. siegel 2009-05-17 10:39:56 UTC
fyi: the last working version was libv4l-0.5.7
Comment 8 Tim-Philipp Müller 2009-05-17 12:55:33 UTC
Why do we let libv4l* do any colourspace conversion at all again? Because ffmpegcolorspace doesn't handle bayer? Any other reasons?
 
Comment 9 Hans de Goede 2009-05-17 13:08:06 UTC
(In reply to comment #8)
> Why do we let libv4l* do any colourspace conversion at all again? Because
> ffmpegcolorspace doesn't handle bayer? Any other reasons?
> 
> 

Because there is nothing else which can handle:
V4L2_PIX_FMT_SN9C10X  v4l2_fourcc('S', '9', '1', '0') /* SN9C10x compression */
V4L2_PIX_FMT_SPCA501  v4l2_fourcc('S', '5', '0', '1') /* YUYV per line */  
V4L2_PIX_FMT_SPCA505  v4l2_fourcc('S', '5', '0', '5') /* YYUV per line */  
V4L2_PIX_FMT_SPCA508  v4l2_fourcc('S', '5', '0', '8') /* YUVY per line */  
V4L2_PIX_FMT_SPCA561  v4l2_fourcc('S', '5', '6', '1') /* compressed GBRG bayer 
V4L2_PIX_FMT_PAC207   v4l2_fourcc('P', '2', '0', '7') /* compressed BGGR bayer 
V4L2_PIX_FMT_MR97310A v4l2_fourcc('M', '3', '1', '0') /* compressed BGGR bayer 
V4L2_PIX_FMT_SQ905C   v4l2_fourcc('9', '0', '5', 'C') /* compressed RGGB bayer 
V4L2_PIX_FMT_PJPG     v4l2_fourcc('P', 'J', 'P', 'G') /* Pixart 73xx JPEG */   
V4L2_PIX_FMT_HM12     v4l2_fourcc('H', 'M', '1', '2') /*  8  YUV 4:2:0 16x16 mac
V4L2_PIX_FMT_SN9C20X_I420 v4l2_fourcc('S', '9', '2', '0') /* sn9c20xcompression

And indeed 4 variants of raw bayer too.

And as we add support for more video grabbing devices the list grows and grows,
so handling this in a single video4linux specific library and then making other
stuff use that, makes perfect sense. I agree we need to extend the API, so
that gstreamer can differentiate between real and emulated formats. And in
cases like this specific one can then prefer a real format over an emulated
one.
Comment 10 Hans de Goede 2009-05-17 13:42:50 UTC
Here is a fixed version of libv4l, which hopefully fixes the messed up colors:

Glenn, can you please give this version a try please ? :
http://people.atrpms.net/~hdegoede/libv4l-0.5.98test.tar.gz

Here are simple installation instructions

Preparation:
1. Download it
2. Check if your current version is installed as
   /usr/lib/libv4l2.so.0
   or:
   /usr/lib64/libv4l2.so.0

Install:
tar xvfz libv4l-0.5.98test.tar.gz
cd libv4l-0.5.97
make

And then depending on wether you have it in lib or lib64 do:
make install PREFIX=/usr LIBDIR=/usr/lib
or:
make install PREFIX=/usr LIBDIR=/usr/lib64

After this try using cheese again and hopefully things are fixed now.
Comment 11 daniel g. siegel 2009-05-17 14:48:31 UTC
i can confirm that it works now on my macbook with the isight. thanks hans!
Comment 12 daniel g. siegel 2009-05-18 08:23:52 UTC
*** Bug 583022 has been marked as a duplicate of this bug. ***
Comment 13 Tim-Philipp Müller 2009-08-01 19:05:44 UTC
Ok, looks to me like we can close this as NOTGNOME, correct? If not, please re-open.

Open action items for libv4l:

 - provide API to differentiate between emulated
   and native formats? (please file new bug once
   that exists)

 - would be nice if there was a .pc file for
   libv4l, so we can require a specific minimum
   version
Comment 14 Hans de Goede 2009-08-02 17:34:56 UTC
(In reply to comment #13)
> Ok, looks to me like we can close this as NOTGNOME, correct? If not, please
> re-open.
> 
> Open action items for libv4l:
> 
>  - provide API to differentiate between emulated
>    and native formats? (please file new bug once
>    that exists)
> 

Since libv4l essentially mimicks the raw v4l2 /dev/video# API I need to coordinate this with upstream I'll put this on my todo list.

>  - would be nice if there was a .pc file for
>    libv4l, so we can require a specific minimum
>    version
> 

There already is a .pc file for libv4l, depending on the API you are using you want to check for either libv4l2 or libv4l1
Comment 15 Hans de Goede 2009-09-01 08:37:54 UTC
(In reply to comment #13)
> Ok, looks to me like we can close this as NOTGNOME, correct? If not, please
> re-open.
> 
> Open action items for libv4l:
> 
>  - provide API to differentiate between emulated
>    and native formats? (please file new bug once
>    that exists)
> 

Done, the new libv4l-0.6.1 release (made minutes ago) now has an API for this:
http://linuxtv.org/hg/~hgoede/libv4l/rev/38927bb366e0
http://linuxtv.org/hg/~hgoede/gspca/rev/58a65a9e65af