[Libav-user] JPEG YUV->RGB
Jeremy Mordkoff
jlm at zeevee.com
Thu May 12 16:19:19 CEST 2011
On Thu, 2011-05-12 at 18:09 +0400, Dmitriy K wrote:
> Is there any examples of this conversion?
> I've found YUV_TO_RGB1 and YUV_TO_RGB2 in libavcodec/colorspace.h in documentation, but there is no this file in my system.
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
here's a snippet from our code that does the conversion. Note how we
clamp the range from 0 to 255. Sorry about the integer math. Also be
careful as I'm not positive we're RGB...I have this vague recollection
that the next step in our process expects BGRA data. Your mileage may
vary....
res = ((Y * 1000) + (1574 * Pr)) / 1000;
if ( res > 255 ) res = 255;
if ( res < 0 ) res = 0;
*(bufptr+(i*4)) = res;
res = ((Y * 1000) - (187 * Pb) - (468 * Pr)) / 1000;
if ( res > 255 ) res = 255;
if ( res < 0 ) res = 0;
*(bufptr+(i*4)+1) = res;
res = ((Y * 1000) + (1855 * Pb)) / 1000;
if ( res > 255 ) res = 255;
if ( res < 0 ) res = 0;
*(bufptr+(i*4)+2) = res;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20110512/034d8f77/attachment.html>
More information about the Libav-user
mailing list