永发信息网

DirectDraw 怎么显示RGB24啊yv12如何转rgb32

答案:2  悬赏:20  手机版
解决时间 2021-01-29 12:43
DirectDraw 怎么显示RGB24啊yv12如何转rgb32
最佳答案
提供简单例子如下

static void CopyDataFromYV12ToYUV420P(uint8_t* pDst, const uint8_t* pSrc, int nWidth, int nHeight)
{
int nYSize = nWidth * nHeight;
int nVSize = nYSize / 4;
int nUSize = nYSize / 4;

int nSrcUOffset = nYSize;
int nSrcVOffset = nSrcUOffset + nUSize;

int nDstVOffset = nYSize;
int nDstUOffset = nDstVOffset + nVSize;
memcpy(pDst, pSrc, nYSize);
memcpy((void*)((int)pDst + nDstVOffset), (void*)((int)pSrc + nSrcVOffset), nVSize);
memcpy((void*)((int)pDst + nDstUOffset), (void*)((int)pSrc + nSrcUOffset), nUSize);
}

void GetRGB888FromYV12(const char* pYV12, const int nWidthIn, const int nHeightIn, \
char** pBufferOut, const int nWidthOut, const int nHeightOut)
{
SwsContext* pConvert_ctx = NULL;
AVFrame* pFrameIn = NULL;
AVFrame* pFrameOut = NULL;
uint8_t* pFrameBufferOut = NULL;
int nFrameOutBufferSize = 0;
uint8_t* pBufferIn = NULL;
int nFrameInBufferSize = 0;

pFrameIn = avcodec_alloc_frame();
nFrameInBufferSize = avpicture_get_size(AV_PIX_FMT_YUV420P, nWidthIn, nHeightIn);
pBufferIn = (uint8_t*)av_malloc(nFrameInBufferSize * sizeof(uint8_t));
CopyDataFromYV12ToYUV420P(pBufferIn, (const uint8_t*)pYV12, nWidthIn, nHeightIn);
avpicture_fill((AVPicture*)pFrameIn, (uint8_t*)pBufferIn, AV_PIX_FMT_YUV420P, nWidthIn, nHeightIn);

pFrameOut = avcodec_alloc_frame();
nFrameOutBufferSize = avpicture_get_size(PIX_FMT_RGB24, nWidthOut, nHeightOut);
pFrameBufferOut = (uint8_t*)av_malloc(nFrameOutBufferSize * sizeof(uint8_t));
avpicture_fill((AVPicture*)pFrameOut, pFrameBufferOut, PIX_FMT_RGB24, nWidthOut, nHeightOut);

pConvert_ctx = sws_getContext(nWidthIn, nHeightIn, AV_PIX_FMT_YUV420P, \
nWidthOut, nHeightOut, PIX_FMT_RGB24, \
SWS_BICUBIC, NULL, NULL, NULL);
sws_scale(pConvert_ctx, (const uint8_t* const*)pFrameIn->data, pFrameIn->linesize, 0,\
nHeightIn, pFrameOut->data, pFrameOut->linesize);
*pBufferOut = (char*)pFrameBufferOut;

av_free(pBufferIn);
av_free(pFrameOut);
sws_freeContext(pConvert_ctx);
}
全部回答
搜一下:DirectDraw 怎么显示RGB24啊yv12如何转rgb32
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
圆通快递(凤冈县分部)地址在什么地方,想过去
王者荣耀什么英雄适合新手上分
某商业企业(一般纳税人)月初购进一批饮料,取
申通快递广告设计地址好找么,我有些事要过去
苍狗白云的意思是什么啊?知道的请说下!
word里面怎么设置阴影部分?
单选题下列行为能体现公平合作意识的是A.为生
我女朋友说 无法面对,该怎么解决
姓曲,男孩,君字辈~求个名字!!请各位帮帮
凤冈申通快递业务代办点地址在哪,我要去那里
警车出任务有没有规定几人执行任务
【田的笔顺怎么写】田字的正确笔划书写怎么写
脸部经常涂抹一些凡士林是不是就可以去掉眼部
女生跳HIP HOP的控制力怎样练?
美的全自动面包机用500g高筋面粉能做多少个面
推荐资讯
癌细胞有全能性吗?那造血干细胞呢?全能型?分
台州香滋恋小吃培训怎么去啊,我要去那办事
地球椭球的意思是什么啊?知道的请说下!
毛边书的意思是什么啊?知道的请说下!
弹簧的弹力与其形变量的关系,图像是一条一次
家人不同意我和比我大8岁男友结婚连见家人一
分解因式(1)ax2-16ay2(2)-2a3+12a2-18a
电脑开机慢是硬件问题吗新电脑就是这样开机要
怎样才能使qq在桌面上锁定
华为p8青春版用什么软件进行流量监控
可以帮忙打一个凉栀嘛?
南蔡村派出所地址在哪,我要去那里办事
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?