[Libav-user] Converting mpg file to ARGB frames
Alex Cohn
alexcohn at netvision.net.il
Thu Oct 13 12:53:07 CEST 2011
On Oct 13, 2011 9:12 AM, "Drabner" <drabner at zoobe.com> wrote:
>
> It seems I have found the reason for the weird behaviour.
> It is this line:
>
> *//---------------------------------------------------------*
> memcpy(textureDest,
> [b]_videoFrames->GetFrames()[_videoFramesPassed]->data[/b],
> 4*640*360);
> *//---------------------------------------------------------*
>
> Instead of using ->data of the AVFrame*, you have to use ->data[0], at
least
> when using PIX_FMT_ARGB. data itself is only a pointer to four streams or
> layers or whatever of picture data. And the linesize of AVFrame tells you
> where to look for the data, it also points to four streams/layers.
Good!
The data/data[0] choise is confusing. But usually it causes a compiler
warning. Didn't you notice one
> Of course, you have to find this out on your own and waste a day with it.
> Gotta love the clarity of the library if you've not studied video codecs
;)
>
> However, I still have a problem of some sort...
> The video is blue. As if the B value is always too high. It works well
when
> I fill every pixel of the picture like this:
>
> *//------------------------------------------- --------------*
> int videoSrc[640*360] = {0};
> for (int i = 0; i < (640*360); i++)
> {
> uint8_t* pixel =
> (uint8_t*)(_videoFrames->GetFrames()[_videoFramesPassed]->data[0]+i*4);
> videoSrc[i] = D3DCOLOR_ARGB(pixel[0],
> pixel[1],
> pixel[2],
> pixel[3]);
> }
> memcpy( textureDest, videoSrc, 4*640*360);
> *//---------------------------------------------------------*
Most likely, this is the reverse byte order in ARGB. Try BGRA format in
scale.
Cheers,
Alex
> Yeah I know, you could skip that last memcpy and fill textureDest directly
> within the loop.
> But anyway... Obviously, this goes kinda heavy on the performance compared
> to just one simple memcpy.
>
> If anyone has an idea what's going on there, I'd be grateful :)
>
> --
> View this message in context:
http://libav-users.943685.n4.nabble.com/Converting-mpg-file-to-ARGB-frames-tp3894271p3900749.html
> Sent from the libav-users mailing. list archive at Nabble.com.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111013/fab0381c/attachment.html>
More information about the Libav-user
mailing list