[Libav-user] Color space conversion
Jasleen Kaur
Jasleen at beesys.com
Tue Oct 28 06:02:28 CET 2014
I am using sws_scale to change the color space of the image buffer.
Source data is in BGRA and destination color space is YUV420(12 bit).
The code snippet for conversion is -
void Convert(int iWidth, int iHeight, BYTE* pBGRABuff)
{
int ystride = iWidth;
int uvstride = iWidth / 2;
int ysize = ystride * iHeight;
int vusize = uvstride * ( iHeight / 2 );
int size = ysize + ( 2 * vusize );
if(g_sws_ctx == NULL)
{
g_sws_ctx = sws_getContext(iWidth,
iHeight,
AV_PIX_FMT_BGRA,
iWidth, iHeight,
AV_PIX_FMT_YUV420P,
SWS_FAST_BILINEAR, 0, 0, 0);
m_picture_buf = (uint8_t*)malloc(size);
}
uint8_t *plane[] = { m_picture_buf, m_picture_buf + ysize, m_picture_buf + ysize + vusize, 0 };
int stride[] = { ystride, uvstride, uvstride, 0 };
uint8_t *inData[1] = { pARGBBuff };
int inLinesize[1] = { 4 * iWidth};
sws_scale(g_sws_ctx, inData, inLinesize, 0, iHeight, plane, stride );
}
The problem I am facing is that the colours are not right in the converted image.
What is the problem with the above code?
Attaching the snapshot of the source and destination images.
-Jasleen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141028/5e4c0f67/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Convert.png
Type: image/png
Size: 200800 bytes
Desc: Convert.png
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20141028/5e4c0f67/attachment.png>
More information about the Libav-user
mailing list