nRet = av_image_alloc(pSrcBuff,nLines,nSrcWidth,nSrcHeight,AV_PIX_FMT_YUV420P,16) ;
nDstBuffLen = av_image_alloc(pDstBuff,nDstLines,nSrcWidth,nSrcHeight,AV_PIX_FMT_RGB24,1) ;
if (nDstBuffLen<=0)
{
return -1 ;
}
SwsContext *sws_ctx;
sws_ctx = sws_getContext(nSrcWidth, nSrcHeight, AV_PIX_FMT_YUV420P,
nSrcWidth, nSrcHeight, AV_PIX_FMT_RGB24,
SWS_BILINEAR, NULL, NULL, NULL);
HGFile srcFile,dstFile;
bFlag = srcFile.OpenFile("yuv800600.yuv",FALSE,&dError) ;
srcFile.ReadFile(pBuffer,nSrcHeight*nSrcWidth*3/2,dRead,NULL) ;
if (dRead!=(nSrcWidth*nSrcHeight*3/2))
{
return -1 ;
}
av_image_fill_arrays(pSrcBuff,nLines,pBuffer,AV_PIX_FMT_YUV420P,nSrcWidth,nSrcHeight,16) ;
int nTemp = sws_scale(sws_ctx, (const uint8_t * const*)pSrcBuff,
nLines, 0, nSrcHeight, pDstBuff,nDstLines);
BYTE *pTemp = NULL ;
dstFile.OpenFile("yrgb0.rgb",TRUE,NULL) ;
dstFile.WriteFile(pDstBuff[0],nDstBuffLen,dRead,NULL) ;
i want to convert the color format frome yuv420p to rgb24
and i used the ffmpeg swscal.lib
something was wrong with the result
the picture shows blue
but if i set the dst format as rgb32
the result is right
is anybody who can give me some advice?
thank you very much !