• 大小: 22.18MB
    文件类型: .zip
    金币: 2
    下载: 1 次
    发布日期: 2023-06-19
  • 语言: 其他
  • 标签: ffmpeg  dxva2  D3D  

资源简介

ffmpeg实现dxva2硬件加速全工程代码。VS2013平台。

资源截图

代码片段和文件信息

#include “stdafx.h“
#include “D3DVidRender.h“

#pragma comment(lib “d3d9.lib“)
#pragma comment(lib “d3dx9.lib“)

// 使用stdio.h和strsafe.h,可实现类似TRACE的功能
/*void LogTrace(LPCTSTR pszFormat ...)  
{  
va_list pArgs;  

char szMessageBuffer[16380]={0};  
va_start( pArgs pszFormat );  
_vsntprintf( szMessageBuffer 16380 pszFormat pArgs );  
va_end( pArgs );  

OutputDebugString(szMessageBuffer);  
}*/  

CD3DVidRender::CD3DVidRender(void)
{
m_pDirect3D9 = NULL;  
m_pDirect3DDevice = NULL;  
m_pDirect3DSurfaceRender = NULL; 
m_pBackBuffer = NULL;
}

CD3DVidRender::~CD3DVidRender(void)
{
}

void CD3DVidRender::Cleanup()  
{  
if (m_pBackBuffer)
{
m_pBackBuffer->Release();
m_pBackBuffer = NULL;
}
if(m_pDirect3DSurfaceRender) 
{
m_pDirect3DSurfaceRender->Release(); 
m_pDirect3DSurfaceRender = NULL;
}
if(m_pDirect3DDevice)  
{
m_pDirect3DDevice->Release();
m_pDirect3DDevice = NULL;
}
if(m_pDirect3D9)  
{
m_pDirect3D9->Release();
m_pDirect3D9 = NULL;
}
if (m_pD3DXFont)
{
m_pD3DXFont->Release() ;
m_pD3DXFont = NULL ;
}


BOOL CD3DVidRender::InitD3D_RGB32(HWND hwnd int img_width int img_height)
{
HRESULT lRet;

if (m_pDirect3D9)
{
m_pDirect3D9->Release();
m_pDirect3D9 = NULL;
}
m_pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION);  
if(m_pDirect3D9 == NULL) 
{
return FALSE;  
}

ZeroMemory(&d3dpp sizeof(d3dpp)); 
d3dpp.Windowed = TRUE;  
d3dpp.hDeviceWindow = hwnd;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;  
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;  
d3dpp.EnableAutoDepthStencil = FALSE;
d3dpp.Flags = D3DPRESENTFLAG_VIDEO;
d3dpp.FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; 

D3DCAPS9 caps;
DWORD BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED;
HRESULT hr = m_pDirect3D9->GetDeviceCaps ( D3DADAPTER_DEFAULT D3DDEVTYPE_HAL &caps ) ;
if ( SUCCEEDED(hr) )
{
if ( caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT )
{
BehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE;
}
else
{
BehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE;
}
}

if (m_pDirect3DDevice)
{
m_pDirect3DDevice->Release();
m_pDirect3DDevice = NULL;
}
lRet = m_pDirect3D9->CreateDevice(D3DADAPTER_DEFAULT D3DDEVTYPE_HAL hwnd BehaviorFlags &d3dpp &m_pDirect3DDevice);  
if(FAILED(lRet))  
{
return FALSE;  


if (m_pDirect3DSurfaceRender)
{
m_pDirect3DSurfaceRender->Release();
m_pDirect3DSurfaceRender = NULL;
}
lRet = m_pDirect3DDevice->CreateOffscreenPlainSurface(img_width img_height D3DFMT_X8R8G8B8 D3DPOOL_DEFAULT 
&m_pDirect3DSurfaceRender NULL);
if(FAILED(lRet))  
{
return FALSE;  
}

//// create the font
//ZeroMemory(&m_font_desc sizeof(m_font_desc));

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-11-30 10:15  Win32Project1_ffmpeg_dxva2\
     目录           0  2016-11-29 15:58  Win32Project1_ffmpeg_dxva2\Debug\
     文件      100352  2016-11-30 22:10  Win32Project1_ffmpeg_dxva2\Debug\Win32Project1.exe
     文件      480232  2016-11-30 22:10  Win32Project1_ffmpeg_dxva2\Debug\Win32Project1.ilk
     文件     2378752  2016-11-30 22:10  Win32Project1_ffmpeg_dxva2\Debug\Win32Project1.pdb
     文件    24556032  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\avcodec-57.dll
     文件     1310208  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\avdevice-57.dll
     文件     3849216  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\avfilter-6.dll
     文件     4941312  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\avformat-57.dll
     文件      563200  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\avutil-55.dll
     文件           0  2016-11-23 15:13  Win32Project1_ffmpeg_dxva2\Debug\output.yuv
     文件      110592  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\postproc-54.dll
     文件      289792  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\swresample-2.dll
     文件      509440  2016-07-13 23:14  Win32Project1_ffmpeg_dxva2\Debug\swscale-4.dll
     目录           0  2016-11-29 16:12  Win32Project1_ffmpeg_dxva2\Win32Project1\
     文件        4645  2016-09-29 10:36  Win32Project1_ffmpeg_dxva2\Win32Project1\ConsoleAdapter.h
     目录           0  2016-11-22 17:38  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\
     目录           0  2016-11-22 17:38  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\
     文件      243136  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D2D1.h
     文件       25655  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D2D1Helper.h
     文件        3171  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D2DbaseTypes.h
     文件        5555  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D2Derr.h
     文件      233001  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D10.h
     文件       72228  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D10_1.h
     文件       12052  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D10_1shader.h
     文件       71712  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D10effect.h
     文件       31418  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D10shader.h
     文件      373484  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D11.h
     文件      121600  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D11SDKlayers.h
     文件       16294  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3D11Shader.h
     文件       15443  2015-12-10 10:26  Win32Project1_ffmpeg_dxva2\Win32Project1\D3D\include\D3DCSX.h
............此处省略389个文件信息

评论

共有 条评论