gpt4 book ai didi

c++ - FFMPEG 帧到 DirectX 表面

转载 作者:搜寻专家 更新时间:2023-10-31 01:23:58 26 4
gpt4 key购买 nike

从 FFMPEG 的 avcodec_decode_video() 函数中获得指向 AVFrame 的指针,我如何将图像复制到 DirectX 表面? (假设我有一个指向适当大小的 DX X8R8G8B8 表面的指针。)

谢谢。

约翰。

最佳答案

您可以使用 FFMPEG 的 img_convert() 函数同时将图像复制到您的表面并将其转换为 RGB 格式。这是从我最近的一个项目中粘贴的几行代码,它做了类似的事情(尽管我使用的是 SDL 而不是 DirectX):

    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, 0, 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, PIX_FMT_RGB32, (AVPicture *)frame,
_context->pix_fmt, _context->width, _context->height);


unlockYourSurface();

关于c++ - FFMPEG 帧到 DirectX 表面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/321298/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com