Thanks Aviad, Then I should be able to transmit sws_tar[0] directly to the openGL function without any other conversion if I got it right. I am also wondering, I have read that RGB32 is quite similar to RGB24 format, except that the 4th byte, always 0, was some way linked to bytes alignment and it improved the speed of conversion, but here can it be used also as an alpha channel?
Cheers, Thibault. -----Original Message----- From: [EMAIL PROTECTED] on behalf of aviad rozenhek Sent: Mon 12/1/2008 10:30 PM To: Libav* user questions and discussions Subject: Re: [libav-user] sws_scale usage, once more... On Mon, Dec 1, 2008 at 7:52 AM, Thibault Daoulas < [EMAIL PROTECTED]> wrote: > Hi, > I know there has been several questions about how sws_scale works, > and I thought I had it clear. However even after reading some examples > in swscale-example.c and ffmpeg.c, I do not manage to make my YUV420p -> > RGB conversion work. > Basically I have a raw data stored in YUV420p format (in a u_char*), but > in order to use it as a texture on my OpenGL primitive, I want do the > conversion to RGB. > Here is what I do : > > sws_src_stride[0] = width_; > sws_src_stride[1] = sws_src_stride[2] = width_/2; > sws_tar_stride[0] = outw_*bytes_per_pixel; > sws_tar_stride[1] = sws_tar_stride[2] = 0; > > sws_tar[0] = pixbuf_; > sws_tar[1] = sws_tar[2] = NULL; you might find the function avpicture_fill<http://www.irisa.fr/texmex/people/dufouil/ffmpegdoxy/imgconvert_8c.html#2884d6046e625b2b6eb3561ee87f8abc>usefull as it fills the strides for you > > > sws_context = sws_getContext(width_, height_, PIX_FMT_YUV420P, outw_, > outh_, PIX_FMT_RGB32, flags, NULL, NULL, NULL); > > sws_src[0] = (uint8_t*)frm; > sws_src[1] = sws_src[0] + framesize_; > sws_src[2] = sws_src[1] + framesize_/4; > > sws_scale(sws_context, sws_src, sws_src_stride, 0, height_, sws_tar, > sws_tar_stride); > > Then my question is, how does sws_tar contain the RGB data ? And > consequently how should it be transferred to my opengl texture loading > function ? > Thanks for any help, I do not have it quite clear what the fields of the > u_int * dst[]; in the libavcodec stand for, and I doubt they represent > each of them one channel r, g, b... > > Thibault. > RGB32 is a packed format. this means that sws_tar[0] will contain the pointer to the entire RGB data. the data is packed like so (exceprt from www.fourcc.org ) top 8 bits of each u_int32 unused, and the RGB is accessed using this mask > Red 0x00FF0000 Green 0x0000FF00 Blue 0x000000FF _______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
<<winmail.dat>>
_______________________________________________ libav-user mailing list [email protected] https://lists.mplayerhq.hu/mailman/listinfo/libav-user
