Re: Webcam (V4L-V4L2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Colin Shaw wrote:

> > > What about YUV420 to RGB565 fast conversion routines? Any hints?
>
> > That depends what you mean by fast. My stuff is all C++ but uses
> > precomputed lookup tables to achieve pretty good speed. I havn't
> > benchmarked it against any of the MMX implementations - if you want one
> > of those then any of the MPEG or DVD players is going to include
> > optimized conversion code.
>
> It is clear that a table lookup from, say YUV420 to any of the RGB formats
> would be pretty small, but what do you do about the size of a table for
> converting from say RGB888 to YUV420 where the space spanned by the result
> is significantly smaller than that of the original.  It would appear that
> this lookup table would require about 2^24 entries and would only map to
> 64 possible YUV420 colors.  Do you apply granularity to the RGB888
> pointers so that it doesn't hog so much memory?  Are there any obvious
> shortcuts that I am overlooking?

:-)

The secret is to break down the conversion such that you can express each of
the r/g/b (or y/u/v) conversions as a sum of lookups into mutliple tables
indexed by 8bit values. Thus the table sizes are very small with no loss of
accuracy, and you've still replaced a bunch of nasty floating point equations
with a few array accesses and integer additions.

Check out rgb2yuv.h/cpp in my tarball at:

http://planeta.terra.com.br/informatica/gleicon/video4linux/

Ben






[Index of Archives]     [Linux DVB]     [Video Disk Recorder]     [Asterisk]     [Photo]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Free Photo Albums]     [Fedora Users]     [Fedora Women]     [ALSA Users]     [ALSA Devel]     [Linux USB]

Powered by Linux