资源简介
Dxva2解码渲染Demo的VS2013工程,使用ffmpeg和dxva2实现视频的解码和渲染
代码片段和文件信息
#include “stdafx.h“
#include “D3D9VideoRenderChannel.h“
int CD3D9VideoRenderChannel::CreateNew(CD3D9VideoRenderChannel **ppv)
{
if (ppv == nullptr)
return 1;
(*ppv) = new CD3D9VideoRenderChannel();
if ((*ppv) == nullptr)
{
return 1;
}
return 0;
}
void CD3D9VideoRenderChannel::Release()
{
delete this;
}
bool CD3D9VideoRenderChannel::IsOpen()
{
return m_bOpened;
}
int CD3D9VideoRenderChannel::OpenVideoDraw(HWND hWnd uint32_t uWidth uint32_t uHeight)
{
if ((hWnd == nullptr) || (uWidth < 0) || (uWidth > 5000) || (uHeight < 0) || (uHeight > 5000))
return 1;
m_hRenderWnd = hWnd;
m_uWidth = uWidth;
m_uHeight = uHeight;
CloseVideoDraw();
HRESULT hResult = S_OK;
DWORD dwBehaviorFlags = 0;
do
{
m_pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);
CHECK_BREAK(m_pD3D9 == nullptr);
D3DDISPLAYMODE sDisplayMode = { 0 };
hResult = m_pD3D9->GetAdapterDisplayMode(D3DADAPTER_DEFAULT &sDisplayMode);
CHECK_BREAK(FAILED(hResult));
D3DCAPS9 sCaps;
hResult = m_pD3D9->GetDeviceCaps(D3DADAPTER_DEFAULT D3DDEVTYPE_HAL &sCaps);
CHECK_BREAK(FAILED(hResult));
dwBehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE;
if (sCaps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT)
{
dwBehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE;
}
memset(&m_sPresentParams 0 sizeof(m_sPresentParams));
m_sPresentParams.Windowed = TRUE;
m_sPresentParams.BackBufferFormat = sDisplayMode.Format;
m_sPresentParams.BackBufferCount = 0;
m_sPresentParams.hDeviceWindow = m_hRenderWnd;
m_sPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD;
m_sPresentParams.EnableAutoDepthStencil = FALSE;
m_sPresentParams.Flags = D3DPRESENTFLAG_VIDEO;
m_sPresentParams.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
m_sPresentParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
hResult = m_pD3D9->CreateDevice(D3DADAPTER_DEFAULT D3DDEVTYPE_HAL m_hRenderWnd dwBehaviorFlags &m_sPresentParams &m_pD3DDevice9);
CHECK_BREAK(FAILED(hResult));
m_bOpened = true;
} while (false);
if (!m_bOpened)
{
CloseVideoDraw();
}
return m_bOpened ? 0 : 1;
}
void CD3D9VideoRenderChannel::CloseVideoDraw()
{
if (m_pBackBuffer)
{
m_pBackBuffer->Release();
m_pBackBuffer = nullptr;
}
if (m_pD3DDevice9)
{
IDirect3DDevice9_Release(m_pD3DDevice9);
m_pD3DDevice9 = nullptr;
}
if (m_pD3D9)
{
IDirect3D9_Release(m_pD3D9);
m_pD3D9 = nullptr;
}
m_bOpened = false;
}
int CD3D9VideoRenderChannel::ChangeVideoParam(HWND hWnd uint32_t uWidth uint32_t uHeight)
{
CloseVideoDraw();
return OpenVideoDraw(hWnd uWidth uHeight);
}
int CD3D9VideoRenderChannel::RenderData(AVframe *pframe)
{
assert(pframe != nullptr);
int iReturn = 1;
while (m_bOpened)
{
iReturn = 0;
RECT rcViewport;
GetClientRec
相关资源
- pcm音频重采样
- H265(ffmpeg_and_nginx-rtmp).7z
- ffmpeg_cuvid.rar
- opencv 3.1.0 3rdparty\\ffmpeg\\download
- FFmpeg4.3 相关源码及编译后的开发包
- FFmpeg解码
- ffmpeg for Linux
- CEF 3.3497.1817 x86带ffmpeg支持H.264/MP3/AA
-
ffpla
yer-ffmpeg4.2.1-win64.rar - ffmpeg-win64-static
- 用于编译OPENCV-3.4.2版本所需的FFMPEG和
- 以FFmpeg为数据源的NvDecodeD3D9
- Linux Qt、大华摄像机SDK模式、ffmpeg解码
- CEF 3.3396.1785 macOS 64位 带ffmpeg支持H.2
- 使用DirectShow采集摄像头并对视音频进
- ffmpeg windows版
- FFmpeg入门到精通.pdf
- 基于Qt、FFMpeg的音视频播放器
- 利用ffmpeg进行视音频信息提取
- 播放YUV视频文件的工程
- OpenCV第三方库和交叉编译工具
- ffmpeg-20180611-8c20ea8-win64-static.zip
- ffmpeg nvdia硬解封装GPU实现NV12-RGBA
- opencv 3.4.X 编译 ffmpeg和ippicv相关资源
- CEF 3.3396.1782 x86带ffmpeg支持H.264/MP3/MP
- FFmpeg安装包,
- QT + ffmpeg 播放 rtsprtmpudp视频流
- FFmpeg_入门到精通(标准版-完整) .
- opencv_3rdparty中所有ffmpeg库
- 树莓派安装ffmpeg及opencv资料
评论
共有 条评论