[libavg-devel] v4l branch code review

OXullo Intersecans x at 02l.net
Mon Jul 23 15:53:23 CEST 2007


Dear Uli,
we've just committed an update version of V4LCamera, following as  
best as we could your guidelines.
We're going to clean up the other tainted sources as well.

Il giorno 22/lug/07, alle ore 20:30, Ulrich von Zadow ha scritto:

> OXullo Intersecans schrieb:
>
>>> - Bitmap.cpp, 832ff: Have you benchmarked this code to make sure it
>>> isn't eating up too much cpu time? It looks slow.
>>
>> That code needs some optimization, indeed. However, if you think that
>> profiling breakdown is quite reliable, it seems that it's not so much
>> time consuming, comparing to other formats.
>
> Um - I just noticed something else: You can get much better results by
> interpolating the U and V values. YUV422toBGR32Line() does this for
> rows, for instance. Have a look at this page to see what I mean:
> http://en.wikipedia.org/wiki/Chroma_subsampling#4:2:0.

I tried to catch some techies about this mess.
The most remarkable difference between YUV411, YUV422 with YUV420p is  
that the latter is a planar format, with the same chroma subsampling  
ratio of YUV411 (1:4).
Looking at your YUV411toBGR32Line() function, you make a weighted  
average of chroma values:

U0-Y-Y-V0-Y-Y, U-Y(a)-Y(b)-V-Y(c)-Y(d), U1-Y-Y-V1-Y-Y

point a: 100% U ; 50% V0 + 50% V
point b: 75% U + 25% U1 ; 25% V0 + 75% V
point c: 50% U + 50% U1 ; 100% V
point d: 25% U + 75% U1 ; 75% V + 25% V1

That's good for that interleaved format and suitable for progressive  
images.

In YUV420p it's quite the same situation, but each u,v couple belongs  
to a 2x2 block instead of a stripe of 4 points. That expose the  
averaging choices to a practical problem: interlacing.
When you're able to process line by line, you can surely get no such  
care to field format, but in this case, talking about V4L which  
usually acquire from interlaced video formats, we should take care of  
our intentions.

Does anyone know TheRightWay(R) on how chroma data can be interpolated?


PS: by now, we're going to improve the actual conversion snippet  
speed and leave it as is, waiting for suggestions!


--
OXullo Intersecans

0 2 L > Outside Standing Level
http://www.02L.net






More information about the libavg-devel mailing list