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