Hello all!

I'm trying to get to the raw pixel data contained in AVFrame->data for a
decoded frame and I found a post from Martin that said to access the
pixels with 

pict->data[0][y*pict->linesize[0] + x]

so I tried dumping to a file using:

for(int y=0; y<height; y++){
        for (int x=0; x<width; x++){
                fprintf(pFile, "%i\n", pFrame->data[0][y *
pFrame->linesize[0] + x]);
        }
}

This works great to get the Y values and I can dump them into a PPM file
for a nice grayscale image. Unfortunately I'm new to the YUV format and
I'd like to be able to work with RGB values (preferably r, g and b
independently). First I assumed that U and V data were in data[1] and
data[2] respectively, and tried the same code above, simply substituting
1 and 2 for 0. But that fails with a memory access error on data[2]
usually a couple of frames into a video. I also tried sw_scale() to
convert to an RGB but it tells me that it can't find a proper color
space.

So a couple of questions:

1) Can anyone point me to the proper format or method for decoding the
YUV data please?
2) Any recommendations for a quick and easy method for converting to
RGB?

Thank ya'll for your help!
~~ Chris L
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to