On 30/01/2010, at 11:00 PM, (*)·´`·.¸.»ÐëÄdMäñ·´`·.¸.»(*) 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];
One other thing I forgot, I must remember that I'm using libav here
and not mjpegutils...
There is additional data at the end of each line of an AVFrame, (I
assume AVPicture is the same) so we
cannot use width as the multiplier.
see changes below...
I also see that I swapped the px and py around in my previous version,
that would definitely cause problems.
Hopefully this one works.
Mark
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[py*src->linesize[0]+px];
u = uptr[py/2*src->linesize[1]+px/2];
v = vptr[py/2*src->linesize[2]+px/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