Euphoria Audio wrote:
> 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.
That is because with YUV420P, for U and V you need to use width/2 and
height/2. And avoid writing YUV for YUV420P when to many people it means
YUV444P.
> 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?
sw_scale. If your code doesnt work but you dont publish it, we cant help.
>
> Thank ya'll for your help!
> ~~ Chris L
--
Michel Bardiaux
http://www.mediaxim.com/
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user