>From my limited testing, I am pretty sure data[0] points to the entire
video stream. Also, you have to keep in mind that if you are working
with planar YUV data (YUV420P), ALL of the luminance comes first, then
U and V. It's not packed like you'd expect, YUYV,YUYV,YUYV,YUYV over
and over. It's like this:

YYYYYYYY
YYYYYYYY
UUUUUUUU
VVVVVVVV

I hope that helps. I just figured this out recently myself.

Thomas


On Sat, Jan 30, 2010 at 4:00 AM, ·´`·.¸.»ÐëÄdMäñ·´`·.¸.»
<[email protected]> wrote:
> Mark,
>
>>  This would work for chroma subsampling type 411 but not 420.  For 420 there
>> is 1 chroma pixel for ever 4 pixels, 2 in the X direction and 2 in the Y
>> direction.
>>
>> So you need something more like:
>>
>> for (py=0; py < height; py++)
>> for (px =0; px < width; px++) {
>>
>>        y = yptr[px*width+py];
>>        u = uptr[px/2*width/2+py/2];
>>        v = vptr[px/2*width/2+py/2];
>>
>
> Thank you very much for your time and your excellent explanation, okay
> so I tried that and still no luck :
>
>        unsigned char  *yptr = src->data[0];
>        unsigned char  *uptr = src->data[1];
>        unsigned char  *vptr = src->data[2];
>        int i =0;
>
>        for (int py=0; py < height; py++)
>        {
>                for (int px =0; px < width; px++, i+= 3)
>                {
>                y = yptr[px*width+py];
>                u = uptr[px/2*width/2+py/2];
>                v = vptr[px/2*width/2+py/2];
>
>                rgb[i] = y + 1.140 * v;
>                        rgb[i+1]         = y - 0.395 *u - 0.581 *v;
>                        rgb[i+2] = y + 2.032 * u;
>                }
>        }
>
> Then I thought maybe data[0] points to the whole yuv array, so I tried this:
>
>        unsigned char  *yptr = src->data[0];
>        unsigned char  *uptr = yptr + width * height;
>        unsigned char  *vptr = uptr + width/4;
>
> but it still doesn't work any suggestions ?
>
> Thanks again.
> _______________________________________________
> libav-user mailing list
> [email protected]
> https://lists.mplayerhq.hu/mailman/listinfo/libav-user
>
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to