该如何利用FFmpeg对yuv图片进行deinterlace,resize 操作?

qiujian5628 2010-05-11 01:36:26
........................................
yuv_media_frame_t *pYUV = (yuv_media_frame_t *)pFrame->GetData();
const u_int8_t* pY = pYUV->y;
const u_int8_t* pU = pYUV->u;
const u_int8_t* pV = pYUV->v;
u_int16_t yStride = pYUV->y_stride;
u_int16_t uvStride = pYUV->uv_stride;

u_int8_t* mallocedYuvImage = NULL;

// crop to desired aspect ratio (may be a no-op)
const u_int8_t* yImage = pY + m_videoSrcYCrop;
const u_int8_t* uImage = pU + m_videoSrcUVCrop;
const u_int8_t* vImage = pV + m_videoSrcUVCrop;

// this has to be rewritten to not mess with the original YUV,
// since it has to be done after the resizer.
if (m_videoFilter != VF_NONE)
{
AVPicture src;
avpicture_fill(&src, (uint8_t *)yImage, PIX_FMT_YUV420P,
m_videoSrcWidth, m_videoSrcHeight);
avpicture_deinterlace(&src, &src, PIX_FMT_YUV420P,
m_videoSrcWidth, m_videoSrcHeight);
}
// resize image if necessary
if (m_videoYResizer)
{
u_int8_t* resizedYUV = (u_int8_t*)Malloc(m_videoDstYUVSize);
u_int8_t* resizedY = resizedYUV;
u_int8_t* resizedU = resizedYUV + m_videoDstYSize;
u_int8_t* resizedV = resizedYUV + m_videoDstYSize +
m_videoDstUVSize;

static struct SwsContext *img_convert_ctx;
if(img_convert_ctx == NULL)
{
int w = m_videoSrcWidth;
int h = m_videoSrcHeight;
img_convert_ctx = sws_getContext(w, h,
PIX_FMT_YUV420P,
w, h, PIX_FMT_YUV420P, SWS_BICUBIC,
NULL, NULL, NULL);
if(img_convert_ctx == NULL)
{
fprintf(stderr, "Cannot initialize the conversion context!\n");
exit(1);
}
}
AVPicture src,dst;
avpicture_fill(&src, (uint8_t *)yImage, PIX_FMT_YUV420P,
m_videoSrcWidth, m_videoSrcHeight);
avpicture_fill(&dst, (uint8_t *)resizedY, PIX_FMT_YUV420P,
m_videoDstWidth, m_videoDstHeight);

sws_scale(img_convert_ctx, src.data,
src.linesize, 0,
m_videoDstHeight,
dst.data, dst.linesize);

if (mallocedYuvImage) free(mallocedYuvImage);

// switch over to resized version
mallocedYuvImage = resizedYUV;
yImage = resizedY;
uImage = resizedU;
vImage = resizedV;
yStride = m_videoDstWidth;
uvStride = yStride / 2;
}
..................................

上段代码中,ffmpeg操作那块该如何修改?主要是 avpicture_fill这块,如何将yuv的数据填充到AVPicture 中?
是否需要分别对yImage,uImage,vImage进行deinterlace和resize?
...全文
1236 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
CyberLogix 2010-05-18
  • 打赏
  • 举报
回复
是否需要分别对yImage,uImage,vImage进行deinterlace和resize?
你到底想干什么啊,不是就要DI吗?

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧