我使用ffmpeg函数解码h264帧并在
windows平台上的窗口中显示.我使用的方法如下(从
FFMPEG Frame to DirectX Surface):
AVFrame *frame; avcodec_decode_video(_ffcontext,frame,etc...); lockYourSurface(); uint8_t *buf = getPointerToYourSurfacePixels(); // Create an AVPicture structure which contains a pointer to the RGB surface. AVPicture pict; memset(&pict,sizeof(pict)); avpicture_fill(&pict,buf,PIX_FMT_RGB32,_ffcontext->width,_ffcontext->height); // Convert the image into RGB and copy to the surface. img_convert(&pict,(AVPicture *)frame,_context->pix_fmt,_context->width,_context->height); unlockYourSurface();
在代码中,我使用sws_scale而不是img_convert.
当我将表面数据指针传递给sws_scale时(事实上在avpicture_fill中),似乎数据指针实际上在RAM而不是GPU内存上,当我想显示表面时,似乎数据被移动到GPU和然后显示.据我所知,在RAM和GPU内存之间复制数据时,cpu利用率很高.
我如何tel ffmpeg直接渲染到GPU内存上的表面(而不是RAM上的数据指针)?