免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 4599 | 回复: 0
打印 上一主题 下一主题

请教达人,如何使用Xv extension。显示ffmpeg解码出来的视频。 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-10-08 09:14 |只看该作者 |倒序浏览
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);

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP