- 论坛徽章:
- 0
|
10可用积分
近来小弟用Xv extension在Qt下显示ffmpeg解码出来的YUV视频。解码过程是正常的。
使用xvinfo显示我在虚拟机中的显卡支持 YV12 模式的视频。当然YV12 和YUV的差异很小。我使用如下代码来显示。但是得到是一个黑的窗体。也就是什么都没给我显示。请教各位大侠。这是何解。 AVFrame *pFrame;
AVFrame *Frame;
AVPicture pict;
int frameFinished;
pFrame = avcodec_alloc_frame();
Frame = avcodec_alloc_frame();
avcodec_decode_video(avctx,
pFrame,
&frameFinished,
(unsigned char *)pStreamData+12,
pFrameHead->nByteNum);
if(frameFinished)
{
printf("I");
XvImage *image = XvCreateImage(dpy, port, 0x32315659, NULL, avctx->width, avctx->height);
image->data = malloc(image->data_size);
pict.data[0] = image->data+image->offsets[0];
pict.data[1] = image->data+image->offsets[2];
pict.data[2] = image->data+image->offsets[1];
pict.linesize[0] = image->pitches[0];
pict.linesize[1] = image->pitches[2];
pict.linesize[2] = image->pitches[1];
img_convert(&pict,PIX_FMT_YUV420P,
pFrame, PIX_FMT_YUV420P,
avctx->width, avctx->height);
/*
Frame->data[0] = pFrame->data[0];
Frame->data[1] = pFrame->data[2];
Frame->data[2] = pFrame->data[1];
Frame->linesize[0] = pFrame->linesize[0];
Frame->linesize[1] = pFrame->linesize[2];
Frame->linesize[2] = pFrame->linesize[1];
//XvImage *image = XvCreateImage(dpy, port, 0x32315659, Frame->data[0], 640, 480);
XvImage *image = XvShmCreateImage(dpy, port, 0x32315659, avctx->width, avctx->height, NULL);
*/
XvPutImage(dpy,port,win,gc,image,
0,0,avctx->width, avctx->height,
0,0,704,576);
XFlush(dpy);
XFree(image);
}
av_free(Frame);
av_free(pFrame); |
|
|